Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


ReleaseDC failing with error code 0


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   -  Reputation: 340

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;
}
}


Sponsor:

#2 Wh0p   Members   -  Reputation: 340

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.



PARTNERS