Jump to content
  • Advertisement
Sign in to follow this  
Wh0p

ReleaseDC failing with error code 0

This topic is 1674 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 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;
}
}

Share this post


Link to post
Share on other sites
Advertisement

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

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!