Skip to main content
gamedev.net
🔒 Locked

Vertex Buffer question

Started by Driv3MeFar 1 reply 800+ views
Original Post
Driv3MeFar
Driv3MeFar
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.
DXnut
DXnut
Try giving it a usage, like DYNAMIC. Also, in the first parameter you are setting the size for only 1 vertex?
--------------------------Most of what I know came from Frank D. Luna's DirectX books
circlesoft
circlesoft
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.