Anybody know why I should get Error:6 (Failed to make context xxxxxx current) when I call OpenTK.GLControl.MakeCurrent ?
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.
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.
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).
Multiple GLControls. I have managed to overcome the problem by overriding the controls OnHandleDestroyed event.
Seems to work fine now.
Soundbomber: could you document what you learnt somewhere, for example in your blog?
Certainly. When I get a spare few minutes. :)
Those minutes will never exist. If you don't want to share, just say so :)
I will say so. Cool your boots! :)
I have been pulled on to another project.
It is good to share.
I have now added this to my Blog
@theFiddler: i don't find the GLControl.RecreateHandle(). is there such an method? how may i enforce handle recreation?
Site design by Stefanos A. Icons courtesy of gnome-colors.