Soundbomber's picture


Anybody know why I should get Error:6 (Failed to make context xxxxxx current) when I call OpenTK.GLControl.MakeCurrent ?


Comment viewing options

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

AFAIK, this is a protected method of the System.Windows.Forms.Control class.

However, before you go that way, try upgrading to the latest version from SVN. I have committed some fixes that might take care of "Error: 6".

GhostTyper's picture

i will try this, if it get's not released in a binary within next days/weeks.

but such a method would be quite nice, even if i have to upload all textures again.

the Fiddler's picture

As I pointed out, this method already exists.

I don't know why the WinForms team decided to make it protected, but there probably is a good reason. It is not possible to modify this method's accessibility through OpenTK - you'll just have to inherit from GLControl to call RecreateHandle.

GhostTyper's picture


there must be a userfriendly way without deriving from anything by simply using an already provided method or anything...

error 6 happens if a internal handle dies. this not only happens, if the underlaying windows closes. i'm using multible opentk controls in the same application. and after a few hours one of the controls is dying. (error 6.)

i know this from direct3d for example. all my device contexts may die whenever they want. but using opentk i have nothing i can do (except of deriving from opentk and then overwriting something like explained here: and except of inheritation from glcontrol) against this? or did i miss a thing?

(sorry about my bad english!)

the Fiddler's picture

The error: 6 issue you are seeing is a bug in OpenTK 0.9.7 (related to a device context leak). This has been fixed in SVN - please file a bug if it still occurs.

Even though their symptoms are similar, "error: 6" issue has nothing to do with the "DeviceLost" event from D3D. Their cause is completely different ("error: 6" is caused due to exhausting available device contexts, DeviceLost is caused by an invalid render context). Indeed, OpenGL does not have anything equivalent to the DeviceLost event.

RecreateHandle is a System.Windows.Forms.Control method not an OpenTK.GLControl one. The WinForms team decided to make this method protected - there's nothing OpenTK can do about this. However, even if RecreateHandle was public, it wouldn't help you with "error: 6". If anything, it would make it appear more quickly, by causing OpenTK to execute the buggy (now fixed) code.

Frankly, the only time I have needed to use RecreateHandle was when I implemented FSAA in GLControl*. Even then, you only needed to call it if the user tried to change FSAA level after creating the control.

* This code will appear in OpenTK at some point in the future

GhostTyper's picture

ill've checked out the repository, but there is no *.sln file like described in Build\Instructions.txt.

am i wrong?

the Fiddler's picture

Double click Build.exe, type "vs" and press enter, enter. This will create the .sln file.

I'll update the instructions to be more clear.

GhostTyper's picture

thank you, error 6 doesn't happen anymore, even after 9h of stress tests. :)