DD primary surface creation error

Started by
1 comment, last by Aeetes 24 years, 2 months ago
I''ve been able to use DD before with no problem... But I''ve started a new project and for some reason my code to create the primary surface returns a DDERR_INVALIDCAPS result (on the m_lpDD->CreateSurface(...) call). But I don''t know why my surface caps would be wrong... here is the code:

	if (DirectDrawCreateEx(NULL, (void **)&m_lpDD, IID_IDirectDraw7, NULL) != DD_OK)
		return E_FAIL;
	if (m_lpDD->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE / DDSCL_FULLSCREEN) != DD_OK)
		return E_FAIL;
	if (m_lpDD->SetDisplayMode(640, 480, 8, 0, 0) != DD_OK)
		return E_FAIL;
	DDSURFACEDESC2 ddsd;
	ddsd.dwSize = sizeof(ddsd);
	ddsd.dwFlags = DDSD_CAPS / DDSD_BACKBUFFERCOUNT;
	ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE / DDSCAPS_FLIP / DDSCAPS_COMPLEX;
	ddsd.dwBackBufferCount = 1;
	HRESULT hResult = m_lpDD->CreateSurface(&ddsd, &m_lpDDSPrimary, NULL);
	if (hResult != DD_OK)
		return E_FAIL;
 
Any help would be appreciated... Where's my Golden Fleece?
Advertisement

Try adding
memset( &ddscaps, 0, sizeof(ddscaps) );

right after
DDSURFACEDESC2 ddsd;
Thanks. Yeah I figured it out a few hours later while playing N64... I set the dwCaps, but left dwCaps2-4 to be whatever they felt like being...
London polution must have gotten to my head, thanks.

Where's my Golden Fleece?

This topic is closed to new replies.

Advertisement