Jump to content
  • Advertisement

Archived

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

negcx

(ERROR) :Create Surface: invalid caps3 specified

This topic is 5391 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 am setting up my DirectDraw interfaces with DirectDraw7. However, my call to IDirectDraw7::CreateSurface fails with the error: Direct3D9: (ERROR) :Create surface: invalid caps3 specified Here is the source code:
	HRESULT hResult;
	DDSURFACEDESC2 ddsd;
	DDSCAPS2 ddscaps;

	_hWnd = hWnd;

	if (_Initialized)
		return FALSE;

	hResult = DirectDrawCreateEx (NULL, (LPVOID*) &_DirectDrawPtr, IID_IDirectDraw7, NULL);

	if (FAILED (hResult))
	{
		_DirectDrawPtr = NULL;
		Error (__FILE__, __LINE__);
		return hResult;
	}

	if (Fullscreen)
	{
		hResult = _DirectDrawPtr->SetCooperativeLevel (_hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
		if (FAILED (hResult))
		{
			_DirectDrawPtr->Release ();
			Error (__FILE__, __LINE__);
			return hResult;
		}

		hResult = _DirectDrawPtr->SetDisplayMode (Width, Height, COLOR_DEPTH, 0, 0);
		if (FAILED (hResult))
		{
			_DirectDrawPtr->Release ();
			Error (__FILE__, __LINE__);
			return hResult;
		}
	}
	else
	{
		hResult = _DirectDrawPtr->SetCooperativeLevel (_hWnd, DDSCL_NORMAL);
		if (FAILED (hResult))
		{
			_DirectDrawPtr->Release ();
			Error (__FILE__, __LINE__);
			return hResult;
		}
	}

	ddsd.dwSize = sizeof (ddsd);
	ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
	ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
	ddsd.dwBackBufferCount = 1;

	hResult = _DirectDrawPtr->CreateSurface (&ddsd, &_PrimarySurfacePtr, NULL);
	if (FAILED (hResult))
	{
		_DirectDrawPtr->Release ();
		Error (__FILE__, __LINE__);
		return hResult;
	}

	ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
	hResult = _PrimarySurfacePtr->GetAttachedSurface (&ddscaps, &_BackSurfacePtr);
	if (FAILED (hResult))
	{
		_PrimarySurfacePtr->Release ();
		_DirectDrawPtr->Release ();
		Error (__FILE__, __LINE__);
		return hResult;
	}
Any ideas? Thanks, negcx

Share this post


Link to post
Share on other sites
Advertisement
Figured it out. Turns out I forgot to ZeroMemory() on the structures and they had bogus data in them.

negcx

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!