Archived

This topic is now archived and is closed to further replies.

The C modest god

D3DVERTEXELEMENT9

Recommended Posts

When creating a ID3DXMESH an array of D3DVERTEXELEMENT9 is ruqired. Does that array describe the vertex data? If I have a structure of { D3DVECTOR position; D3DVECTOR normal; } How can the create mesh function tell what is the length of that array? What array I should create to describe it? I would appreaciate help on this matter. Thanks in advance.

Share this post


Link to post
Share on other sites
neneboricua19    634
Remember, vertex declarations are used only for shaders. If you''re not using shaders, then you don''t need a vertex declaration.

struct VERTEX
{
D3DXVECTOR3 position; // vertex position

D3DXVECTOR3 normal; // vertex normal

};

// Define FVF for fixed function pipeline

const DWORD D3DFVF_VERTEX = D3DFVF_XYZ | D3DFVF_NORMAL;

// Create equivalent vertex element structure for this vertex type to be used with vertex and pixel shaders

const D3DVERTEXELEMENT9 vertexDeclaration[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
D3DDECL_END()
};


Hope this helps,
neneboricua

Share this post


Link to post
Share on other sites