Jump to content
  • Advertisement
Sign in to follow this  
squicklid

DDERR_INVALIDPARAMS for CreateSurface

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

Hi there. My program worked with this same code... and then I changed the way it stores the surfaces.. and now I get this error: DDERR_INVALIDPARAMS
ddSurface* DirectDraw::createSurface(int width, int height, bool videoMemory, ddSurface* newsurf)
{
	if (!newsurf)
	{
		newsurf = surfaces.add(LLP_BEG);
		if (!newsurf)
			return NULL;
	}

	DDSURFACEDESC2 ddsd;
	ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
	DWORD capflags = DDSCAPS_OFFSCREENPLAIN;
	capflags |= (videoMemory) ? DDSCAPS_VIDEOMEMORY : DDSCAPS_SYSTEMMEMORY;

	ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
	ddsd.ddsCaps.dwCaps = capflags;
	ddsd.dwWidth = width; ddsd.dwHeight = height;
	
	HRESULT res = lpDD->CreateSurface(&ddsd, &newsurf->getSurf(), NULL);

	//recursive call to try again
	if (FAILED(res))
	{
		// failed, maybe lack of video mem?
		if (videoMemory)
		{
			return createSurface(width, height, false, newsurf);
		}
		surfaces.remove(LLP_BEG);
		return NULL;
	}

	return newsurf;
}

See, I used to store the surfaces in an array. but now they are stored in a list. I dont see how that would affect the function call parameters. BTW ddSurface::getSurf() returns LPDIRECTDRAWSURFACE7& .. and I checked what value it returns and it is null.

Share this post


Link to post
Share on other sites
Advertisement
You should install the debug runtime. It'll tell you what parameter is invalid. You're not setting the dwSize member of the structure. Add this line after your ZeroMemory() line:
ddsd.dwSize = sizeof(ddsd);

EDIT: It's been a long time since I used DirectDraw, but don't you need to set the surface format as well?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!