Jablo's picture

Failed to make context 131072 current. Error: 6

Hi 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.


Comment viewing options

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

Error 6 means "invalid handle", according to Microsoft's error code list.

Need some more info to debug this:

  1. Does the error occur on application startup or later on?
  2. Do you use multiple contexts? (e.g. multiple GLControls in the same app)
  3. What kind of video card do these PCs have? (i.e. does the program work on Nvidia but fail on Intel, or something like that?) Sometimes it helps to update the video drivers, if possible.
Jablo's picture

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)

the Fiddler's picture

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).

nythrix's picture

Or you can attach a listener to the GraphicsContext.Destroy event. That's my favourite place for GL cleanup.

Jablo's picture

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 ?

nythrix's picture

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?

the Fiddler's picture

This is a bug on X11GLContext. Do you mind filing a bug report so it doesn't get lost?

Jablo's picture

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?