Jump to content
  • Advertisement
Sign in to follow this  
Cleese852

Depth Buffer

This topic is 3425 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, I'm have trouble getting my depth buffer enabled, even though I did it before and succeeded.. These are my present parameters: m_presentParameters.BackBufferWidth = DEFAULT_BACKBUFFER_WIDTH; m_presentParameters.BackBufferHeight = DEFAULT_BACKBUFFER_HEIGHT; m_presentParameters.BackBufferFormat = D3DFMT_X8R8G8B8; m_presentParameters.BackBufferCount = 1; m_presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; m_presentParameters.MultiSampleQuality = 0; m_presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; m_presentParameters.hDeviceWindow = ENGINE->getWindow(); m_presentParameters.Windowed = TRUE; m_presentParameters.EnableAutoDepthStencil = TRUE; m_presentParameters.AutoDepthStencilFormat = D3DFMT_D16; m_presentParameters.Flags = 0; m_presentParameters.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; m_presentParameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; And I also have the renderstates: HR(m_devicePtr->SetRenderState(D3DRS_ZWRITEENABLE, TRUE)); HR(m_devicePtr->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE)); HR(m_devicePtr->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL)); And before I draw I clean my screen with this: HR(m_devicePtr->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, m_backgroundColor, 1.0f, 0 )); Am I forgetting something, because I can't seem to find out why it won't work, I googled for hours, even my teacher at school hasn't found the problem yet :-/ Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
What you've posted there looks okay. Exactly what sort of behavior are you getting?

Also, make sure you're not doing anything that will set render states. For instance ID3DXSprite will set render states, and an ID3DXEffect can set render states as well.

Share this post


Link to post
Share on other sites
Here's a screenshot: http://img16.imageshack.us/img16/3871/zbufferproblem.jpg
I disabled my ID3DXSprite and I'm not setting any renderstates through an ID3DXEffect or my shader. I analyzed my application with PIX (from directX SDK) and it appears my depth buffer is black, except for the text I draw, which is white.

Share this post


Link to post
Share on other sites
You only have a 16-bit Z-buffer, which means you have very limited precision. What are your near and far clip planes set to in your projection matrix? You want your near clip as far as possible (And with a 16-bit Z-buffer you want it >= 1.0f) and your far clip as near as possible (With a 16-bit Z-buffer I wouldn't put it at anything past 1000.0f, and even that is a pretty poor resolution).

Share this post


Link to post
Share on other sites
Ah goddamnit, I found it. Although I was setting my near to 30 and far to 500 for testing, It appeared that I was giving the wrong variables to my createProjection function. So I was using 0-3000 instead for my clip planes -.-
Now it's solved, thanks!

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!