Jump to content
  • Advertisement
Sign in to follow this  
b3rs3rk

Repopulating a Vertex Buffer

This topic is 4407 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

i'm writing a bsp compiler. after a node split operation, i have to add the new triangles created to the vertex buffer. The problem is that i haven't a FVF but a vertex declaration that is not mappable. This way i cannot use IDirect3DDevice9::CreateVertexBuffer.. how should i do? this is my vertex declaration:
D3DVERTEXELEMENT9 MeshVertexDeclaration[] =	{
	{ 0, 0,  D3DDECLTYPE_FLOAT3,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION,     0 },//size =12
	{ 0, 12, D3DDECLTYPE_FLOAT3,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL,		 0 },//size =12
	{ 0, 24, D3DDECLTYPE_FLOAT3,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT,		 0 },//size =12
	{ 0, 36, D3DDECLTYPE_FLOAT3,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL,     0 },//size =12
	{ 0, 48, D3DDECLTYPE_FLOAT2,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,     0 },//size =8
	{ 0, 56, D3DDECLTYPE_FLOAT2,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,     1 },//size =8
	D3DDECL_END()
};

is possible to take a mesh vertex buffer and simply reallocate its memory in order to contain more vertices? Or take a mesh vertex buffer, clone it in a new VB and increase its size?

Share this post


Link to post
Share on other sites
Advertisement
i think i've solved. I rewrote my mesh class using fvf instead of vertex declaration. The problem was mapping tangent and binomials. Now i've a generic fvf for all the models, and i have only to create the vb at the end of the bsp process :)

Share this post


Link to post
Share on other sites
Quote:
Original post by b3rs3rk
i think i've solved. I rewrote my mesh class using fvf instead of vertex declaration. The problem was mapping tangent and binomials. Now i've a generic fvf for all the models, and i have only to create the vb at the end of the bsp process :)


Um, that sounds like you're moving backwards - vertex decls are far more flexible than FVF, and don't have anything to do with where or when you create your VBs.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!