DrawPrimitive / Vertex buffers

Started by
5 comments, last by steg 22 years, 3 months ago
Hi, I was wondering what is the best way to store objects - i.e.should they all go in one big vertex buffer and then index into this buffer with DrawPrimitive to draw each one ? Should you limit the number of calls to DrawPrimitive - i.e. is it possible to use DrawPrimitive once to draw all objects in your scene ? Kindest reg''ds, Steve

If it isn't working, take a bath, have a think and try again...

Advertisement
You can''t change texture mid-way through a call to drawprimitive, so you''re going to have to make several calls.

Also keep in mind that although hardware T&L will transform vertices as needed, software T&L will typically transform every vertex in the vertex buffer while drawing.

How you render really depends on the type of scene you have, whether you have a vertex buffer that you will fill dynamically (ie from a BSP or text rendering system), or a vertex buffer & texture per mesh, or any other scheme.
Sorry steg what I''m about to write is not really answering your question but rather a call for more info from what siaspete has already written.

I have already written a BSP tree but the problem I have is whether to create a vertex buffer each time the scene is drawn or if the BSP class itself should do the rendering via a pointer to the d3d device. Are there any efficiency aspects that I should be considering? What is the proper way for doing this?

I''m thinking it would be good to store a character with a BSP tree since about half of the faces are not facing the camera or am I mistaken?
Might be wise not to "Create" a VB each time. Just create one of arbitary size (even Max possible size).
Then lock->refill->unlock it each frame.

I wouldn''t try and get fancy with using a BIG buffer and indexing into it (instead of refilling). D3D will transform ALL vertices from MinIndex value to MinIndex + NumVertices. A real bummer. This may happen for only software though.

Try to avoid DMA when copying data to Vid-Mem - So batch them up into one array first before memcpy into buffer.

Oh as for the design question.
Just keep it consistent and abstract.
Thanks a lot guys,
I think I''ll d9930380 says, create a vertex buffer and
then just lock->copy->unlock instead of creating one each frame.

Reg''ds,
Steve

If it isn't working, take a bath, have a think and try again...

hey, whats a BSP tree -
Binary Search P? Tree ??

whats it good for, when storing vertices?

thanks
Binary Space Partition

Used to work out and classify where polygons are in the scene. Their main use is usually for culling parts of the scene which aren''t visible. Other benefits include being able to render in perfect front to back order (which is good for z buffering and alpha amongst other things). In their pure form they aren''t perfect for all situations though - re partitioning due to deformed geometry for example can take much longer than with other methods such as octrees.

There''s many many tutorials about them out there on the web, a simple google search should generate quite a few hits. I just did a search for BSP+tutorial, it gives 9000 hits. Should be enough to bring you up to speed.

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

This topic is closed to new replies.

Advertisement