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

DX - Z-buffers

This topic is 5674 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

If I want to use a Z-buffer in my app, I need to set the corresponding values in the PresentationParameter struct. But what about the colorformat set in the displaymode struct, do I also need to use a color mode macro specifying depth information? The same goes with alpha blending. If I''d like to use it do I then need to specify a color format in the displaymode struct with an aplha channel like D3DFMT_A8R8G8B8 (but then there''s no room for Z-buf?!?!)???? Cherioooooooo *********************** A year spent in artificial intelligence is enough to make one believe in God.

Share this post

Link to post
Share on other sites
Hej rart a se nogen fra DK!!
The Z-buffer i a seperate buffer and not part of the frame buffer.
To create a Z-buffer you have to set the folowing params in the D3DPRESENT_PARAMETERS structure before calling CreateDevice

d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
AutoDepthStencilFormat has to be set with an adapter compatible format.

Then you have to enable Z-buffering:
SetRenderState( D3DRS_ZENABLE, true);

If you want to use alpha blending you don''t have to create a backbuffer with alpha like you sugested. To do alpha blending you have to use textures with alpha or you can have a seperate texture with alpha.
You can also use the backbuffer for alpha blending. That can be usefull for multipass blending where you write alpha values to the backbuffer during the first pass and then use those alpha values for blending the second pass.

Good luck!

Share this post

Link to post
Share on other sites