I think your problem is at the 5th parameter (AlignedByteOffset). This is the number of bytes that the data for that element is stored-> so for the POSITION element this number should be 0, since it is the 1st element, for NORMAL this number should be 12 (how did I get 12? Very easy: the POSITION element is of type DXGI_FORMAT_R32G32B32_FLOAT, this means it has 3 floats (R,G,B; aka XYZ) and since one float is 4 bytes you multiply that by the number of floats and you get 12), and for TEXCOORD it should be 24 (why 24? because it has POSITION and NORMAL before it and POSITION and NORMAL both take 12 bytes you just sum it up :P )
I'll try to explain some parameters (what I think you should know for this):
LPCSTR SemanticName: you will access the data in the shader by this name
UINT SemanticIndex: I haven't used these so I can't tell you much, just put it to 0
DXGI_FORMAT Format: the format
UINT InputSlot: put it to 0
UINT AlignedByteOffset: the number of bytes from the beginning of the vertex structure to this element
It isn't much of an explanation...
Here is how i create my input layout (note: "die" stands for "desc-input-element" :P )
| m_numElem=3; |
| |
| die=new D3D10_INPUT_ELEMENT_DESC[m_numElem]; |
| |
| die[0].AlignedByteOffset=0; |
| die[0].Format=DXGI_FORMAT_R32G32B32_FLOAT; |
| die[0].InputSlot=0; |
| die[0].InputSlotClass=D3D10_INPUT_PER_VERTEX_DATA; |
| die[0].InstanceDataStepRate=0; |
| die[0].SemanticIndex=0; |
| die[0].SemanticName="POSITION"; |
| |
| die[1].AlignedByteOffset=12; |
| die[1].Format=DXGI_FORMAT_R32G32B32_FLOAT; |
| die[1].InputSlot=0; |
| die[1].InputSlotClass=D3D10_INPUT_PER_VERTEX_DATA; |
| die[1].InstanceDataStepRate=0; |
| die[1].SemanticIndex=0; |
| die[1].SemanticName="NORMAL"; |
| |
| die[2].AlignedByteOffset=24; |
| die[2].Format=DXGI_FORMAT_R32G32_FLOAT; |
| die[2].InputSlot=0; |
| die[2].InputSlotClass=D3D10_INPUT_PER_VERTEX_DATA; |
| die[2].InstanceDataStepRate=0; |
| die[2].SemanticIndex=0; |
| die[2].SemanticName="TEXCOORD"; |
| |
| device->CreateInputLayout(die,m_numElem,passDesc.pIAInputSignature,passDesc.IAInputSignatureSize,&IL); |