Archived

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

DirectDraw won't init

This topic is 5979 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 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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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);

Share this post


Link to post
Share on other sites