Jump to content
  • Advertisement
Sign in to follow this  
ProgrammingNerd

dumb question

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

Advertisement
You shouldnt have too, you fill the vertex buffer with the correct amount. When you fill it simply take that number.

Share this post


Link to post
Share on other sites
Right, you control what goes into a VB. However, what you put in depends on the type of primitive you'll be using. For example a triangle_strip has fewer verticies than a triangle_list, but both can draw the same object. Actually, you can even mix and match depending on how you're coding, since the draw primitives specify an offset and a length.

What is your trouble, maybe we can help.

Share this post


Link to post
Share on other sites
Quote:
Original post by ProgrammingNerd
How can you easily find how many vertices are in a vertex buffer?

IDirect3DVertexBuffer9::GetDesc() will get you the basic information, in particular you want D3DVERTEXBUFFER_DESC::size and D3DVERTEXBUFFER_DESC::FVF values.

You can then get the number of bytes for a single vertex by feeding the FVF into D3DXGetFVFVertexSize( )

Now simply divide the total size by the single vertex size and you've got your vertex count [grin]

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
Quote:
Original post by ProgrammingNerd
How can you easily find how many vertices are in a vertex buffer?

IDirect3DVertexBuffer9::GetDesc() will get you the basic information, in particular you want D3DVERTEXBUFFER_DESC::size and D3DVERTEXBUFFER_DESC::FVF values.

You can then get the number of bytes for a single vertex by feeding the FVF into D3DXGetFVFVertexSize( )

Now simply divide the total size by the single vertex size and you've got your vertex count [grin]

hth
Jack

Keep in mind this won't work with non-FVF vertex buffers (if you don't pass an FVF while creating it). If you know the declaration, you can calculate the size of each vertex and work it out. If you don't, you can design a simple system where you store such data in the buffer's private data (IDirect3DVertexBuffer9::SetPrivateData/GetPrivateData)

Share this post


Link to post
Share on other sites
Quote:
Original post by Coder
Keep in mind this won't work with non-FVF vertex buffers (if you don't pass an FVF while creating it). If you know the declaration, you can calculate the size of each vertex and work it out. If you don't, you can design a simple system where you store such data in the buffer's private data (IDirect3DVertexBuffer9::SetPrivateData/GetPrivateData)

Good point, didn't think of that [smile]

If using declarations, D3DXFVFFromDeclarator() might well be of use. Get the FVF and you should be able to use the process in my first post still...

D3DXGetDeclVertexSize() might also be of interest.

hth
Jack

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!