Jump to content
  • Advertisement
Sign in to follow this  
whereisumar

VertexBuffer and ZBuffer

This topic is 4416 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi i had a question, in order for the zbuffer to work and hide geometry behind other geometery properly, do you HAVE to use a vertexbuffer? In Direct3D with c# do you always have to have a vertex buffer contain all the vertex data in order for the zbuffer to work properly, or can u draw just using drawprimitives and have seperate objects holding seperate vertex data?

Share this post


Link to post
Share on other sites
Advertisement
Hi whereisumar!

Welcome to GameDev.net. I'll see if I can answer your question. It appears as though you're asking two questions, "Can I render without vertex buffers in DirectX?" and "how can I use zbuffering?" I'll answer your questions separately.

For the first question...yes, you CAN render in Direct3D without using vertex buffers, but its significantly slower. Depending upon which pool of memory you use to create the vertex buffers, the device can create the vertex buffer either in system memory, video memory, or shared memory. By creating the vertex buffer in video memory, and to a degree in shared memory, the device has significantly faster access to the data - and thus, faster renders.

With that being said, Direct3D will allow you to feed it vertex data by using "user data." This is done by calling "DrawUserPrimitives" rather than DrawPrimitives (DrawPrimitives requires a stream be set to an existing vertex buffer).

For your second question, you can use zbuffering with either DrawPrimitives or DrawUserPrimitives, it doesn’t matter. By using zbuffering the device creates a depth buffer which it uses to determine whether a primitive should be drawn in front of, or in back of what's currently on screen by performing a depth test.

To use zbuffering, just enable it on the device with.
Device.SetRenderState(ZEnable, true);

One you do this, make sure to clear the depth buffer during the clear phase.

Cheers!
Jeromy

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!