Jump to content

View more

Image of the Day

Working on an auto spawn system. #gamedev #indiedev #screenshotsaturday https://t.co/Mm2kfekz7b
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

ReleaseDC failing with error code 0

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 Wh0p   Members   

407
Like
0Likes
Like

Posted 22 October 2013 - 01:14 PM

I think the topic title describes the problem sufficiently.

 

Here is the code how I create and release he contexts, however I do nothing else with them at the moment (I reduced everything to just the plain window...)

The error code of GetLastError() is 0 which confuses me in thinking no error occured but the result of ReleaseDC is 0 too....

// Get a Device Context
if (!(_HDC = GetDC(_hWnd)))							
{
	Shutdown();
	Log::Get ().Write (L"Can't create a GL Device Context.");
	return;
}

// Find a matching Pixel Format
GLuint		PixelFormat;
if (!(PixelFormat = ChoosePixelFormat (_HDC, &pfd)))	
{
	Shutdown();	
	Log::Get ().Write (L"Can't find a suitable PixelFormat.");
	return;	
}

// Set the Pixel Format
if(!SetPixelFormat (_HDC,PixelFormat, &pfd))		
{
	Shutdown();
	Log::Get ().Write (L"Can't set the PixelFormat.");
	return;	
}

// Get a Rendering Context
if (!(_HRC = wglCreateContext (_HDC)))				
{
	Shutdown();	
	Log::Get ().Write (L"Can't create a GL Rendering Context.");
	return;	
}

// Activate the Rendering Context
if(!wglMakeCurrent (_HDC, _HRC))					
{
	Shutdown();
	Log::Get ().Write (L"Can't activate the GL Rendering Context.");
return;	
}

ShowWindow (_hWnd, SW_SHOW);
SetForegroundWindow (_hWnd);
SetFocus (_hWnd);
}
if (_HRC)	
{
	if (!wglMakeCurrent (NULL, NULL))
	{	Log::Get ().Write (L"Release Of DC And RC Failed."); }
		if (!wglDeleteContext (_HRC))
	{	Log::Get ().Write (L"Release Rendering Context Failed.");	}
		_HRC = NULL;
}
if (_HDC && !ReleaseDC (_hWnd, _HDC))
{
        DWORD err = GetLastError (); // <<<<<< err == 0 ????
	Log::Get ().Write (L"Release Device Context Failed.");
	_HDC = NULL;
}
}


#2 Wh0p   Members   

407
Like
0Likes
Like

Posted 22 October 2013 - 03:37 PM

Never mind. I have been doing bad stuff during the WM_CLOSE message.

Hope humanity forgives my impulsive "things are not going well" post...






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.