
Failed to make context 131072 current. Error: 6
Posted Tuesday, 27 January, 2009 - 08:58 by Jablo inHi all,
On some PC's a call to MakeCurrent results in 'Failed to make context 131072 current. Error: 6'
The call tree is:
OpenTK.Graphics.GraphicsContextException : Failed to make context 131072 current. Error: 6
bei OpenTK.Platform.Windows.WinGLContext.MakeCurrent(IWindowInfo window)
bei OpenTK.Graphics.GraphicsContext.MakeCurrent(IWindowInfo info)
bei OpenTK.GLControl.MakeCurrent()
What could be the reason, because only some PC's reports this error?
What means Error:6?
Thanks in advance.


Comments
Re: Failed to make context 131072 current. Error: 6
Error 6 means "invalid handle", according to Microsoft's error code list.
Need some more info to debug this:
Re: Failed to make context 131072 current. Error: 6
1) The error typically occurs if the form where the GLControl is embedded is closed.
2) We have max 2 windows with GLControl instanciated (one Dialog, one DockingWindow), But this error occurs even if only the dialog was shown and closed and no DockingWindow was in use.
3) The first occurence happened on several IBM Lenovo R61. This we could fix with an update of the graphic card driver 'Lenovo Grafikkarten Treiber Update - 79d172ww.exe'.
From the other PCs I have to collect some information about graphic cards.
But probably I made a mistake: Can I use the GLControl.OnHandleDestroyed event to clean up in the way below?
protected override void OnHandleDestroyed(EventArgs e)
{
MakeCurrent();
GL.DeleteLists(...);
base.OnHandleDestroyed(e);
}
Thanks
Re: Failed to make context 131072 current. Error: 6
Indeed, the HandleDestroyed event occurs after the context is destroyed. If possible you should place this code in the Closing event of the containing Form (Controls don't offer such an event, unfortunately).
Re: Failed to make context 131072 current. Error: 6
Or you can attach a listener to the GraphicsContext.Destroy event. That's my favourite place for GL cleanup.
Re: Failed to make context 131072 current. Error: 6
Now I am confused!
1. In the HandleDestroyed event I check the GLControl.Context and it seems it is alive.
2. I add for the current context 'gc.Destroy += new DestroyEvent( gc_Destroy );' but the event implementation is never called?
So how to implement cleanup ?
Re: Failed to make context 131072 current. Error: 6
I add for the current context 'gc.Destroy += new DestroyEvent( gc_Destroy );' but the event implementation is never called?
Are you definitely sure the command
gc.Destroy += new DestroyEvent( gc_Destroy );is evaluated?
Re: Failed to make context 131072 current. Error: 6
This is a bug on X11GLContext. Do you mind filing a bug report so it doesn't get lost?
Re: Failed to make context 131072 current. Error: 6
The event registration 'gc.Destroy += new DestroyEvent( gc_Destroy );' is called, the debugger steps into it.
I see a non public member 'dispose_queue' from which the count remains 0 after assigning, but probably it has nothing to do with this event.
If I call DestroyContext() eg. triggered by a key, the handler method 'gc_Destroy' is called !!
This behaviour is 100% reproduceable.
My DevEnv is WindowsXPSP3x86 & Framework3.5, is it possible that it is not only a bug in X11GLContext?