Soundbomber's picture

Error:6

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


Comments

Comment viewing options

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

I've seen this error come up a couple of times, both in OpenTK and Tao. This is a windows error code that means "Invalid Handle" - there are several references on the internet.

Suggestions: try upgrading your drivers, I know of at least one case where this took care of the issue. Make sure your window handle is valid (e.g. do not close the Form or destroy the handle of the Control and then call MakeCurrent). Try calling Control.Context.MakeCurrent(null) before making the context current.

Some more information would be useful. Are you using multiple contexts and/or multiple threads? When does this error happen (startup, shutdown or randomly)?

Finally, a small test case that reproduces the issue would help - right now, the cause of these errors is quite nebulous.

Soundbomber's picture

I am using a single context with multiple user controls. I do have to close the form and re-open it to produce the error.

the Fiddler's picture

Multiple GLControls or a single GLControl?

It's possible that the window handle is destroyed when you close the Form - can you try hiding it instead of closing it?

Alternatively, you could try to remove the GLControl from the Controls collection before closing the parent Form and reattach it when the form is recreated.

Another solution: try calling Control.RecreateHandle on the relevant GLControl (but this way you will lose all textures and other data you have uploaded to the video card).

Soundbomber's picture

Multiple GLControls. I have managed to overcome the problem by overriding the controls OnHandleDestroyed event.
Seems to work fine now.

objarni's picture

Soundbomber: could you document what you learnt somewhere, for example in your blog?

Soundbomber's picture

Certainly. When I get a spare few minutes. :)

objarni's picture

Those minutes will never exist. If you don't want to share, just say so :)

Soundbomber's picture

I will say so. Cool your boots! :)
I have been pulled on to another project.
It is good to share.

Soundbomber's picture

I have now added this to my Blog

GhostTyper's picture

@theFiddler: i don't find the GLControl.RecreateHandle(). is there such an method? how may i enforce handle recreation?