Jump to content
  • Advertisement
Sign in to follow this  
Driv3MeFar

Vertex Buffer question

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

Hello, I'm having a problem with my first D3D app. Before I get to the actualy problem, I have a design question: should each game object have its own vertex buffer, or should I use one large buffer and have each object write into its own portion of the buffer? Right now, I have it set up so that each object has its own vertex buffer, but the problem is, my CreateVerexBuffer() call is failing:
if (FAILED(g_Renderer->getDevice()->CreateVertexBuffer(sizeof(sVerts),
           0, D3DFVF_VERTEX, D3DPOOL_DEFAULT, &pVertBuffer, NULL))) 
   {
	   return false;
   }

is always returning false, where g_Renderer is a global pointer to my renderer, getDevice returns the renderers LPDIRECT3DDEVICE9, and sVerts is my struct of vertex data (and I know my FVF is configured correctly). Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Try giving it a usage, like DYNAMIC. Also, in the first parameter you are setting the size for only 1 vertex?

Share this post


Link to post
Share on other sites
Quote:
Original post by Driv3MeFar
Before I get to the actualy problem, I have a design question: should each game object have its own vertex buffer, or should I use one large buffer and have each object write into its own portion of the buffer?


If your application is simple, it will be advantageous to group mesh data together. ATI put out a report a while ago stating that the optimal size for a static vertex buffer is 10-15mb. So what you can do is create a 10mb buffer, fill it, then start a new one, and so on.

The reason why this helps performance is because you reduce the number of SetStreamSource() calls that you have to make, which are very expensive.

Quote:
Right now, I have it set up so that each object has its own vertex buffer, but the problem is, my CreateVerexBuffer() call is failing:

If you haven't already, check the debug runtime output - this will tell you exactly why it is failing. If you haven't used the debug runtimes before, there is a good section on it in the DirectX FAQ.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!