• Advertisement
Sign in to follow this  

objects: behind and in front of

This topic is 3166 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. My problem is that the virtual object A (that is behind of the virtual object B in the virtual envroinment) is graphically always in front of the object B. The current settings are the follows:
ZEnable = true;
CullMode = ccw;
AlphaBlendEnable = true;
BlendOp = add;
SrcBlend = srcalpha;
DestBlend = invsrcalpha;

Are theese settings correct ? or incorrect ? And/Or there are also other parameters to set ? The version of DirectX is 9.

Share this post

Link to post
Share on other sites
Yes and no. For opaque translucent objects, you'll need to draw them in back-to-front order, otherwise the translucency won't work properly.

Have you actually created a Z-buffer? What is the depth-stencil format set to in your D3DPRESENT_PARAMETERS?

Share this post

Link to post
Share on other sites

The follow are the parameter for the Z-Buffer (like in the site http://www.toymaker.info/Games/html/z_buffer.html and http://www.toymaker.info/Games/html/render_states.html#Zbuffer):

// D3D present parameters
ZeroMemory(&D3Dpp, sizeof(D3Dpp));
// Fill of the structure D3Dpp
D3Dpp.EnableAutoDepthStencil = true;
D3Dpp.AutoDepthStencilFormat = D3DFMT_D16;

// creation of the device:

and then:

D3DDev->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); // ZEnable

But the object A (behind of the object B) is always in front of the object B.

Are the parametrs correct so ? or not ?

Share this post

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

  • Advertisement