Sign in to follow this  
Driv3MeFar

Vertex Buffer question

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this