Jump to content

  • Log In with Google      Sign In   
  • Create Account

Zbuffer Initialization problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 nPawn   Members   -  Reputation: 110

Like
Likes
Like

Posted 30 December 1999 - 08:35 AM

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?


Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 30 December 1999 - 08:26 AM

Hi,
Add:

SurfaceDesc.dwSize = sizeof(DDSURFACEDESC2);

Before the call to CreateSurface.

Aldenar


#3 nPawn   Members   -  Reputation: 110

Like
Likes
Like

Posted 30 December 1999 - 08:35 AM

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.

#4 SomeCodeGuy   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 January 2000 - 07:01 PM

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....






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS