ZBuffer problem , help, Thanks.
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"
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
Try lpD3DDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER,0,1,0);
Edited by - Queasy on 4/22/00 4:33:11 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement