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
I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid
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
Ok, however i did set the zbuffer to true, and sorry for all the mistakes, i've been learning from different sources.
I just don't know if surfaces should have depth or not. It seems like only the pixels get drawn, but aren't stenciled.
It works whenever i have the rendering to back buffer without using any of the render targets, but not when i render to a surface.
Why don’t you post a screenshot or 2 to show what you mean?
Additionally, GetBackBuffer() and GetSurfaceLevel() increase reference counts and Release() must be called afterwards on the respective objects.
Comments in your code would go a long way towards helping us help you. I really can’t understand the point of the code (why StretchRect()??) and there are functions such as objectlist[i].Render() that can only leave us guessing. I assume this call is not related to your problem, but comments would help to know for sure.
L. Spiro
I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid
Why don’t you post a screenshot or 2 to show what you mean?
Additionally, GetBackBuffer() and GetSurfaceLevel() increase reference counts and Release() must be called afterwards on the respective objects.
Comments in your code would go a long way towards helping us help you. I really can’t understand the point of the code (why StretchRect()??) and there are functions such as objectlist.Render() that can only leave us guessing. I assume this call is not related to your problem, but comments would help to know for sure.
L. Spiro
nvm i found out the problem :]
I had the near view plane set to 0.0f. I set it there because i though it would be better, but apparently it broke the depth buffer.