Jump to content
  • Advertisement
Sign in to follow this  
Christoph

SetDepthStencilSurface() doesn't work!

This topic is 4527 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 all, I'm currently trying to let some water flow, but already at the point of reflection I had to rummage in forums for hours... Now I see myself forced to tell you my problem. Look at this code:
LPDIRECT3DSURFACE9 oldDepthStencil, newDepthStencil;
device->GetDepthStencilSurface(&oldDepthStencil);
device->GetRenderTarget(0,&(waterEffect->backbuffer));

device->CreateDepthStencilSurface(128*waterEffect->quality,128*waterEffect->quality,D3DFMT_D24S8,D3DMULTISAMPLE_NONE,0,TRUE,&newDepthStencil,NULL);
device->SetDepthStencilSurface(newDepthStencil);	
device->SetRenderTarget(0,waterEffect->projSurface);
device->Clear(0,NULL,D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET,D3DCOLOR_XRGB(255,0,255),1.0f,0);

// draw scene objects
			
device->SetDepthStencilSurface(oldDepthStencil);
device->SetRenderTarget(0,waterEffect->backbuffer);

D3DXSaveTextureToFile("tmp.bmp",D3DXIFF_BMP,waterEffect->projTexture,0);

As you can see, I check the texture I render to by saving it to disc. Here, I can clearly see that NO Z-Buffer is applied at all (meaning newDepthStencil is ineffective). Z-Buffering is enabled by RenderState, I have tried thousands of formats for my DepthStencil-Surface and the "normal" Z-Buffer oldDepthStencil works fine... So do you know what I'm doing wrong? Thanks a lot!!

Share this post


Link to post
Share on other sites
Advertisement
(1) You aren't checking the result codes of any of the IDirect3DDevice9 functions. These functions could be returning failure, but you don't know since you don't check. For example:

if( FAILED( device->CreateDepthStencilSurface( blah blah blah ) ) )
{
// Error handling code
}


(2) Have you checked the debug output for helpful messages the debug runtime may be giving you? If you don't know what this is or how to use it, check the forum FAQ.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!