OpenGL in MFC application does not work in Windows 8 64 bit - by BongoVR

Status : 


Sign in
to vote
ID 780757 Comments
Status Active Workarounds
Type Bug Repros 3
Opened 3/5/2013 10:22:56 PM
Access Restriction Public


In an MFC project which uses OpenGL the call to wglMakeCurrent fails and GetLastError returns 6 (Invalid Handle). Thus, no OpenGL can be used.
This happens only in 64 bit mode under Windows 8. With Windows 7 64 bit the code runs fine. The 32 bit executable runs fine in all OSes. 
Sign in to post a comment.
Posted by Wenzel Jakob on 1/29/2014 at 4:56 AM
After some more investigation, I was only able to reproduce the issue in a Parallels Virtual Machine. Physical Windows 8.x machines were unaffected, which suggests that the OpenGL virtualization of Parallels may be to blame.
Posted by Wenzel Jakob on 11/21/2013 at 6:59 AM
Please also see the following links to reproduce this issue:

These contain Visual Studio projects and i386/x64 binaries (Debug+Release) of the small problematic example from stackoverflow, compiled using Visual Studio 2010 and 2013. The Visual 2013 x64 version will stop with an error message when run on Windows 8/8.1. In all other cases (using an earlier Windows version, or using the i386 or Visual Studio 2010 builds), the program runs successfully.

Best regards,
Posted by Wenzel Jakob on 11/20/2013 at 6:05 AM

I am also experiencing the same issue in a piece of software I develop. After some investigation, it seems that wglMakeCurrent always fails on Windows 8/8.1 when running 64 bit OpenGL applications compiled with Visual Studio >= 2012. Running the same binary on e.g. Windows 7 works fine. A temporary solution was to either use a 32 bit build or compile for 64 bit using a previous version of Visual Studio (I used 2010).

Obviously, this is not a satisfactory solution. This bug basically breaks OpenGL on Windows 8/8.1 when using an up-to-date development pipeline!

Note that none of this seems to be related to MFC -- I'm not using it in my application, and neither are other people who are ran into this issue. For a nice minimal code example that triggers the bug (and some associated discussion), see

Best regards,
Posted by BongoVR on 6/18/2013 at 7:36 AM
Some news about the issue.
I have also experimented with a pure Win32 project with OpenGL and observed the same behaviour. So, yes, it is not an issue of MFC.

However, when compiling the same programme for x64 using Visual Studio 2010 and running the executable under Windows 8 it worked. The main difference therefore is the C runtime library. The one shipping with Visual Studio 2012 is to blame. There is no other difference because the opengl32.dll is the very same.

Any update on this issue?
Posted by BongoVR on 4/12/2013 at 12:55 AM
Thanks for your response. I have posted this issue in the forum you mentioned but not received answers so far. I also do not believe that this is an MFC bug. wglMakeCurrent gets a valid handle and always returns false - so the problem is in that function. Since this happens only in Windows 8 64 bit with the VERY SAME binary executable that works with Windows 7 64 bit just fine I strongly suppose that this is a bug introduced with Windows 8.
Since the bug is reproducible with the CubeView sample you can investigate the issue together with the Windows team. Please understand that this is sample code from Microsoft showing how to use OpenGL. Now, with Windows 8 this code does not work any more. How should developers set up OpenGL now? Are there any recommendations about how to initialise OpenGL in Windows 8 any differently than in previous OS versions?
Posted by Microsoft on 4/8/2013 at 11:52 AM

Thanks for the report. We have investigated and we do not believe that this is an MFC bug. We recommend you check with OpenGL or with Windows (

Pat Brenner
Visual C++ Libraries Development
Posted by jakka30 on 3/14/2013 at 1:41 PM
We could reproduce the same issue with our application which is being built using MFC, OpenGL.
Posted by Microsoft on 3/14/2013 at 3:03 AM
Thanks for your response. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by BongoVR on 3/6/2013 at 2:51 AM
Please find attached project file. In cubeview.cpp, line 251, I always receive 6 for 64 bit builds under Windows 8.
Posted by Microsoft on 3/6/2013 at 2:19 AM
Hi BongoVR, thank you for submitting feedback on Visual Studio and .NET Framework. Could you upload your sample project please? Thanks.
Posted by Microsoft on 3/5/2013 at 10:51 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(