Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

#ActualL. Spiro

Posted 30 November 2012 - 02:47 AM

Where do you believe you are “using” your depth buffer?
There is no sign of such use in the code you posted. Are we to assume you have actually created it and it is set?


There are several other problems with your code.
Firstly you should only BeginScene() and EndScene() once per frame.
Secondly don’t make multiple calls to Clear(). Do this:
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(255, 0, 0, 0), 1.0f, 0);
Notice also that the D3DCOLOR_ARGB() is not used correctly in your code. Full alpha = 255, not 1.
If you do actually have a depth buffer and it is bound, there is no code shown that actually “uses” it. You never enabled depth testing via a call to SetRenderState( D3DRS_ZENABLE, TRUE ).
Even though this should be done automatically if you created a depth buffer on the creation of your present parameters, you should call it manually to be sure.


L. Spiro

#1L. Spiro

Posted 29 November 2012 - 09:44 PM

Where do you believe you are “using” your depth buffer?
There is no sign of such use in the code you posted. Are we to assume you have actually created it and it is set?


There are several other problems with your code.
Firstly you should only BeginScene() and EndScene() once per frame.
Secondly don’t make multiple calls to Clear(). Do this:
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(1, 0, 0, 0), 1.0f, 0);
If you do actually have a depth buffer and it is bound, there is no code shown that actually “uses” it. You never enabled depth testing via a call to SetRenderState( D3DRS_ZENABLE, TRUE ).
Even though this should be done automatically if you created a depth buffer on the creation of your present parameters, you should call it manually to be sure.


L. Spiro

PARTNERS