DirectDraw won't init

Started by
2 comments, last by Daishim 22 years, 8 months ago
I am trying to get DirectDraw to work but the following code keeps causing an illeagle operation error immediately at the program start.

bool Init_Graphics(HWND hwnd)
{
	LPDIRECTDRAW lpdd = NULL;
	LPDIRECTDRAW lpdd4 = NULL;

	DirectDrawCreate(NULL, &lpdd, NULL);

	lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *) &lpdd4);

	lpdd->Release();

	lpdd4->SetCooperativeLevel(hwnd, DDSCL_NORMAL);

	lpdd4->Release();

	return true;
}
 
I''m using the DX7 sdk, if it makes a difference.

I know only that which I know, but I do not know what I know.
Advertisement
Hello!

I am not a C-Programmer, but I'm trying to help you.

here's my code:

bool Init_Graphics(HWND hwnd)
{
LPDIRECTDRAW lpdd = NULL;
LPDIRECTDRAW lpdd4 = NULL;
DirectDrawCreate(NULL, &lpdd, NULL);
lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *) &lpdd4);
lpdd4->SetCooperativeLevel(hwnd, DDSCL_NORMAL);
return true;
}


bool Game_Shutdown()
{
if (lpdd4)
{
lpdd4->Release();
lpdd4 = NULL;
return true;
}
}

cu
chlupp2000
Starbyte Developments

Edited by - chlupp2000 on August 3, 2001 1:55:08 AM
quote:Original post by Daishi
bool Init_Graphics(HWND hwnd){	...	lpdd4->Release();	return true;}  



I''m just guessing here, but do you use lpdd4 for anything after calling Init_Graphics? If you do, then I see the problem. You are releasing DirectDraw right after initializing it. Remove the line "lpdd4->Release()" and it should work.
"It tastes like burning..."
LPDIRECTDRAW7 lpdd = NULL;

// Obtain a pointer to an IDirectDraw7 interface
DirectDrawCreateEx(NULL, (VOID**)&lpdd, IID_IDirectDraw7, NULL);

// Set the cooperative level
lpdd->SetCooperativeLevel(hWnd, DDSCL_NORMAL);

This topic is closed to new replies.

Advertisement