c3p0's picture

OpenGL: MakeCurrent failed. Problem with MDI application


The above problem has been haunting me for the last couple of months, and I just can't seem to figure out what the problem is.

My application is using the DockPanelSuite "framework" for handling MDI, which seems to be working perfectly for everything but OpenGL.

Googling the problem suggests that there is a multithreading problem. But since I've not multithreaded my application on purpose, I'm not quite sure if that's the real source.
Can automatic multithreading .net generate errors like these?

The error looks like this: "Failed to make context 655360 current. Error: 6".

I'm getting this problem on both my laptop (Nvidia graphics) and my desktop (ati 1950pro). Both of them are now using .net 3.5 and OpenTK 0.9.1

Any suggestions on how to attack this problem would be much appreciated.


I'm attaching myPaint-methods, if that would be of any help :}

OpenGL methods.txt3.73 KB


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

According to the winapi error codes, error 6 means ERROR_INVALID_HANDLE.

The most likely explanation I can think of, is that the control with the rendering context is destroyed at some point. If this is true, the question is when and why it is destroyed and how you can avoid that.

Does the error appear when you do specific actions, for example docking / undocking? Does it appear when you open the application but do nothing? If it is the first, you could try removing / readding the GLControl when this action happens, to ensure it stays intact.

These are simply suggestions to help locate the bug. It would also help if you can write a simple test case that reproduces this behavior.