Jump to content
  • Advertisement
Sign in to follow this  
Batistuta86

Z-buffer problem

This topic is 2828 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

I have problem with order of drawing objects in d3d9 in x64 application, I guess that problem iz in z-buffer but I can't find mistake.

Parts of my code

::ZeroMemory(&d3dpp,sizeof(d3dpp));
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferHeight = m_size.cy;
d3dpp.BackBufferWidth = m_size.cx;
d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.MultiSampleType = (D3DMULTISAMPLE_TYPE)m_multisampling_type;
d3dpp.MultiSampleQuality = m_multisampling_quality;
d3dpp.hDeviceWindow = m_hWnd;
d3dpp.Windowed = TRUE;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;



HRESULT hr = m_device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
IS_OK(SUCCEEDED(hr));

m_pEngine->BeginDraw(m_bSkipMargins, rcInsideRect, m_bVirtualScreenMode, m_totalsize.cx, m_totalsize.cy);

hr = m_device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
IS_OK(SUCCEEDED(hr));

hr = m_device->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, TRUE);
IS_OK(SUCCEEDED(hr));

hr = m_device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
IS_OK(SUCCEEDED(hr));

hr = m_device->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
IS_OK(SUCCEEDED(hr));

hr = m_device->SetRenderState(D3DRS_ZENABLE, TRUE);
IS_OK(SUCCEEDED(hr));

hr = m_device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
IS_OK(SUCCEEDED(hr));

hr = m_device->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
IS_OK(SUCCEEDED(hr));

hr = m_device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
IS_OK(SUCCEEDED(hr));

m_blit_render3d_state.Release();
hr = m_device->CreateStateBlock(D3DSBT_ALL, &m_blit_render3d_state);
IS_OK(SUCCEEDED(hr));

Share this post


Link to post
Share on other sites
Advertisement
Any ideas?

Solved. Clearing Z-Buffer didn't work, so somehow I found the problem on other place in code.

The problem was in 5. parameter (DepthStencil) which was set to FALSE
HRESULT hr = D3DXCreateRenderToSurface(m_device, m_totalsize.cx, m_totalsize.cy, D3DFMT_A8R8G8B8, FALSE, D3DFMT_D16, &m_pRTS);
Later was called m_pRTS->beginScene()... and because of this m_device deattached z-buffer.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!