Depth Buffer
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
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.
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.
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.
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.
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).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement