Jump to content
  • Advertisement
Sign in to follow this  
ChristophR

Non-FVF vertex buffer

This topic is 4655 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I want to create a non-fvf vertex buffer. The DirectX documenatation just says that I have to set the FVF flag of the CreateVertexBuffer method to zero, but it does not say how I can specify the vertex declaration which shall be used for the new vertex buffer. How can I do that? For instance, I have to following array of vertex elements:
D3DVERTEXELEMENT9 vdecl[] = {
	{0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0},
	{0, 16, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0},
	{0, 20, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
	D3DDECL_END()
};
Afterwards I create the vertex declaration:
LPDIRECTION3DVERTEXDECLARATION myVertexDeclaration;
device->CreateVertexDeclaration(vdecl, &myVertexDeclaration);
But how can I tell the CreateVertexBuffer method that it shall use this declaration for the new buffer? Thanks in advance. rgds

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by ChristophR
But how can I tell the CreateVertexBuffer method that it shall use this declaration for the new buffer?

When using Vertex Declarations, you don't tell D3D about the vertex structure until rendering. You don't even use it when you create the VB. So normally, your rendering sequence is something like this:

SetVertexDeclaration()
SetStreamSource()
SetIndices()

DrawIndexedPrimitive()

Share this post


Link to post
Share on other sites
Ok, thanks. Now I have got another problem: when I call SetVertexDeclaration before I render my vertexbuffer it returns D3DERR_INVALIDCALL.


D3DVERTEXELEMENT9 decl[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
D3DDECL_END()
};
device->CreateVertexDeclaration(decl, &myVertexDeclaration);
device->SetVertexDeclaration(myVertexDeclaration);


But myVertexDeclaration is valid (it is not NULL and CreateVertexDeclaration also returned S_OK).

What could be the reason?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!