Skip to main content
GameDev.net gamedev.net
🔒 Locked

Z Buffer Problems

Started by nes8bit Jun 22, 2000 at 6:59 PM 7 replies 450+ views
Original Post
nes8bit
nes8bit
When I turn off the writing to the zbuffer and turn it back on, it doesn''t work. The zbuffer doesn''t go back to normal after that. Any suggestions? This happened on 3 computers so far. ------------------------ Captured Reality
acw83
acw83
You should email nes8bit, he probably knows. Just kidding, is this OpenGL or Direct 3D??? Give some code that you are using.

---
www.crazycrackerz.org
nes8bit
nes8bit
Direct3D

Not much to the code. It''s just setting the renderstate.

If UseZBuffer Then Direct3DDevice.SetRenderstate D3DRENDERSTATE_ZWRITEENABLE, True

''// Draw Particles Here

If UseZBuffer Then Direct3DDevice.SetRenderstate D3DRENDERSTATE_ZWRITEENABLE, False

------------------------
Captured Reality
Eric
Eric
Does pd3dDev->Clear() return ok, or does it by chance give "no z-buffer present"? (And do the z-write render state changes return ok?) What do you mean the z-buff "doesn''t go back to normal"?
nes8bit
nes8bit
I never looked into that.

After I set the renderstate to no writing to the zbuffer, it doesn''t want to go back. I''m wondering if I have to do something when I create the zbuffer surface or if it''s simply a driver problem. I will look into the zbuffer clears when I get back to my computer.

------------------------
Captured Reality
nes8bit
nes8bit
Thanks guys for trying to help, but I found out it was a driver problem. I''m still not sure if its a driver problem, but I fixed it. If you ever get this problem, follow the pseudo code.

int i;

i = D3DDev.GetRenderstate(D3DRENDERSTATE_ZWRITEENABLE)
D3DDev.SetRenderstate(D3DRENDERSTATE_ZWRITEENABLE,False)

// Do particle effects here

D3DDev.SetRenderstate(D3DRENDERSTATE_ZWRITEENABLE,i)

it''s a very simple solution



------------------------
Captured Reality
Facehat
Facehat
Uh, nes, that doesn''t look like a driver issue. It''s more of a logic one .

See this:

quote:

If UseZBuffer Then Direct3DDevice.SetRenderstate D3DRENDERSTATE_ZWRITEENABLE, True

''// Draw Particles Here

If UseZBuffer Then Direct3DDevice.SetRenderstate D3DRENDERSTATE_ZWRITEENABLE, False



Basically what your doing is turning on the Zwriting when you are drawing the particles, then turning it off as soon as your done. (You need to do the opposite )

So instead, do this:


If UseZBuffer Then Direct3DDevice.SetRenderstate D3DRENDERSTATE_ZWRITEENABLE, False

''// Draw Particles Here

If UseZBuffer Then Direct3DDevice.SetRenderstate D3DRENDERSTATE_ZWRITEENABLE, True


--TheGoop
nes8bit
nes8bit
Oh silly me. I didn''t copy the code directly, but it already looks like that. Thanks anyway.

------------------------
Captured Reality

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.