Skip to main content
GameDev.net gamedev.net
🔒 Locked

Dynamic Vertex Buffers

Started by gerbrost Dec 4, 2001 at 7:31 AM 1 replies 250+ views
Original Post
gerbrost
gerbrost
Hello all! I am loading a milkshape 3d file and want to render it. I managed to load all the triangles therein into a vertex buffer and render it with drawprimitive. Now i want to have different materials and textures for the triangle groups in the file. So i need a vertex buffer for every group of trianges. That means i have to create an array of vertex buffers since i dont now in advance how many buffers are needed. How can i do that? LPDIRECT3DVERTEXBUFFER8 *VB; VB = new ... But what is ...? I could do it with a struct like struct ... { LPDIRECT3DVERTEXBUFFER8 vb; } vbstruct; and use VB = new vbstruct. What is the best way? Thank you all
NightShade
NightShade
Hi,

The structure thing would actually work (you might as well make a class for it). It would come in handy, you could for example store group-specific data there also (the texture, material, etc), plus anything you thought of later on. In general your code would be a little clearer and better structured if you went this way.

I think to answer your question though, you could do this:

LPDIRECT3DVERTEXBUFFER8 **Buffers;

Buffers = new LPDIRECT3DVERTEXBUFFER8 * [size];

...then for each new vertex buffer you create...

Dev->CreateVertexBuffer(VertSize * NumVerts, 0, FVFFlags, D3DPOOL_MANAGED, &Buffers[BufferNumber]);

...to release one you do this:
Buffers[BufferNumber]->Release();

...then after you''ve Released them all and are ready to quit:
delete [] Buffers;

-ns-
gerbrost
gerbrost
Im sorry, i did forget to reply to your posting:
It works!
Thank you for your help!!

Topic Locked

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

Sign in to reply to this topic.