Game Development Reference
In-Depth Information
After that you need to define which Input Slot this attribute exists in. You can get
away with setting this to zero in most cases. If you are working with multiple vertex
buffers, you would use this parameter to specify which buffer this attribute applies to.
AlignedByteOffset refers to the offset from the start of the element to the start
of the attribute. If you are defining these attributes sequentially you can use the help-
er D3D11_APPEND_ALIGNED_ELEMENT , which will automatically determine the cor-
rect offset based on the earlier description.
InputSlotClass refers to the D3D11_INPUT_CLASSIFICATION descriptor for
the attribute. Unless you are working with instancing, this will always be
D3D11_INPUT_PER_VERTEX_DATA .
Finally InstanceDataStepRate can just be set to zero if you aren't working with
instancing. This value specifies the number of instances that should be drawn before
advancing to the next element in the instance data buffer.
With all of this information we just need a quick call to the CreateInputLayout()
method on the device and we will have an input layout ready for use. The following
is what that call looks like:
M_d3dDevice->CreateInputLayout(
vertexDesc,
2, // Size of the vertex description array
vsFile->Data,
vsFile->Length,
&m_inputLayout
);
Here we started by passing the array of vertex descriptors, and telling the device
how many descriptors exist within the array. Then we need to pass in the vertex
shader file that this input layout will be mapped to. We need to do this because vertex
shaders may expect different layouts and we need to ensure that everything matches
up; otherwise, there will be a miscommunication and error.
Finally we receive an ID3D11InputLayout* object that we can use when drawing
to specify the layout to be used with the set shader.
Search WWH ::




Custom Search