Archived

This topic is now archived and is closed to further replies.

steg

DrawPrimitive / Vertex buffers

Recommended Posts

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

Share this post


Link to post
Share on other sites
siaspete    208
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.

Share this post


Link to post
Share on other sites
-=Code=-    122
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?

Share this post


Link to post
Share on other sites
d9930380    122
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.

Share this post


Link to post
Share on other sites
steg    390
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
hey, whats a BSP tree -
Binary Search P? Tree ??

whats it good for, when storing vertices?

thanks

Share this post


Link to post
Share on other sites
S1CA    1418
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

Share this post


Link to post
Share on other sites