Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Xeno

ZBuffer problem , help, Thanks.

This topic is 6935 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 got some problem while enabling ZBuffer in d3dim. my program just display a 3d Cube and rotating it a round the y axis and everything is ok, but when i enabling ZBuffer my program just show the edges of the cube and nothing else. hu?? why?? i use this code: LPDIRECTDRAWSURFACE7 g_pddsZBuffer = NULL; DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd,sizeof(ddsd)); DDPIXELFORMAT ddpfZBuffer; g_pD3D->EnumZBufferFormats( *pDeviceGUID, EnumZBufferCallback, (VOID*)&ddpfZBuffer ); // If we found a good zbuffer format, then the dwSize field will be // properly set during enumeration. Else, we have a problem and will exit. if( sizeof(DDPIXELFORMAT) != ddpfZBuffer.dwSize ) return E_FAIL; ddsd.dwSize = sizeof(DDSURFACEDESC2); ddsd.dwFlags = DDSD_CAPS/DDSD_WIDTH/DDSD_HEIGHT/DDSD_PIXELFORMAT; ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; ddsd.dwWidth = 800; ddsd.dwHeight = 600; memcpy( &ddsd.ddpfPixelFormat, &ddpfZBuffer, sizeof(DDPIXELFORMAT) ); // For hardware devices, the z-buffer should be in video memory. For // software devices, create the z-buffer in system memory if( IsEqualIID( *pDeviceGUID, IID_IDirect3DHALDevice ) ) ddsd.ddsCaps.dwCaps /= DDSCAPS_VIDEOMEMORY; else ddsd.ddsCaps.dwCaps /= DDSCAPS_SYSTEMMEMORY; // Create and attach a z-buffer. Real apps should be able to handle an // error here (DDERR_OUTOFVIDEOMEMORY may be encountered). For this // tutorial, though, we are simply going to exit ungracefully. if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pddsZBuffer, NULL ) ) ) return hr; // Attach the z-buffer to the back buffer. if( FAILED( hr = g_pddsBackBuffer->AddAttachedSurface( g_pddsZBuffer ) ) ) return hr; of course , i enabling the z-buffer with setrenderstate. Posted By Xeno. Kobe Bryant- "Just believe in yourself"

Share this post


Link to post
Share on other sites
Advertisement
When you actually do start the render process, make sure the zbuffer is being cleared each time.

Try lpD3DDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER,0,1,0);

Edited by - Queasy on 4/22/00 4:33:11 PM

Share this post


Link to post
Share on other sites

  • 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!