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);
SetDepthStencilSurface() doesn't work!
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:
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!!
(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:
(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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement