Archived

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

nPawn

Zbuffer Initialization problem

Recommended Posts

Thanks, that seems to have done the trick, it was pretty silly to have missed that, but then i guess the Author of the book missed it too, and his little chunk of code also had several syntax errors which further confused me. =) Thanks again.

Share this post


Link to post
Share on other sites
I'm trying to get a ZBuffer going in my 3D program, but it fails when I try to create the surface, the Createsurface call fails with an invalid parameter error code, the code is mostly from 3D programming with C++ by DeGoes. The primary surface and back buffers have all been successfully created. Here's the code:

HRESULT hr;
LPDIRECTDRAWSURFACE7 ZBuffer;
DDSURFACEDESC2 SurfaceDesc;

ZeroMemory(&SurfaceDesc, sizeof(SurfaceDesc));

SurfaceDesc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
SurfaceDesc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | DDSCAPS_VIDEOMEMORY;
SurfaceDesc.dwWidth = m_dwWidth;
SurfaceDesc.dwHeight = m_dwHeight;
SurfaceDesc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
SurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_ZBUFFER;
SurfaceDesc.ddpfPixelFormat.dwZBufferBitDepth = 24;
SurfaceDesc.ddpfPixelFormat.dwZBitMask = 0xFFFFFF;
hr = m_pDD->CreateSurface(&SurfaceDesc, &ZBuffer, NULL);
if (hr != DD_OK)
{
m_ErrorSys.Log("G3D::InitZBuffer, CreateSurface() Failed", hr, true, true);
return false;
}
if( FAILED( hr = m_pBack->AddAttachedSurface( ZBuffer ) ) )
{
m_ErrorSys.Log("G3D::InitZBuffer, Could not attach ZBuffer to back buffer", hr, true, true);
return false;
}
return true;


I have tried several different ZBuffer depths (16, 24, 32) and that doesn't seem to help, same with trying to use video memory or system memory. I'm using a Viper 550 TNT card which I thought could handle ZBuffers? Any ideas as to what is causing the invalid parameter?

Share this post


Link to post
Share on other sites
Thanks people, I was doing exactly the same thing and was having the exact same problem.... silly silly silly...

I was sitting here for 2 hours looking at my code line by line, just couldn''t figure out what the hell was wrong.

My head was ready to explode....

Share this post


Link to post
Share on other sites