Jump to content
  • Advertisement
Sign in to follow this  
gazsux

DirectDraw - CreateSurface for offscreen surface fails

This topic is 4992 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

Hey, I'm just trying out a DirectDraw tutorial as I need to create a 2d game quickly in order to exemplify some networking code I have. However, I have a problem when I call a function to create an offscreen surface - the call to CreateSurface() always fails. Here's my code:
	LPDIRECTDRAWSURFACE surface = NULL;

	// Clear the ddsd memory
	EraseDesc();

	ZeroMemory( &ddsd, sizeof( ddsd ) );
	ddsd.dwSize = sizeof( ddsd );

	// Fill in the surface info
	ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT;
	ddsd.dwWidth = width;
	ddsd.dwHeight = height;
	ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY;

	// Create the surface
	long rval = lpdd->CreateSurface(&ddsd, &surface, NULL);

	if (rval != DD_OK)
	{
		MessageBox(hwnd, "Failed to create offscreen surface", "Error", MB_OK);
		quit = true;
	}
	return surface;
The rval that is returned is: -2147024809 which is not a valid DX error code so that isn't helping. Anyone have an idea what might be causing the function to fail? Cheers!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by gazsux
Hey,

I'm just trying out a DirectDraw tutorial as I need to create a 2d game quickly in order to exemplify some networking code I have. However, I have a problem when I call a function to create an offscreen surface - the call to CreateSurface() always fails.

Here's my code:

LPDIRECTDRAWSURFACE surface = NULL;

// Clear the ddsd memory
EraseDesc();

ZeroMemory( &ddsd, sizeof( ddsd ) );
ddsd.dwSize = sizeof( ddsd );

// Fill in the surface info
ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT;
ddsd.dwWidth = width;
ddsd.dwHeight = height;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY;

// Create the surface
long rval = lpdd->CreateSurface(&ddsd, &surface, NULL);

if (rval != DD_OK)
{
MessageBox(hwnd, "Failed to create offscreen surface", "Error", MB_OK);
quit = true;
}
return surface;


The rval that is returned is: -2147024809 which is not a valid DX error code so that isn't helping.

Anyone have an idea what might be causing the function to fail?

Cheers!


-2147024809 is E_INVALIDARG error code.
I don't know, but don't see any color depth setting.

Share this post


Link to post
Share on other sites
Color depth is set in another function. Does that have to be set before creating the surface?

[EDIT] - No matter, I have it sorted. Thanks

[Edited by - gazsux on March 16, 2005 7:52:57 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

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