GL_INVALID_OPERATON when sharing objects between contexts

I am using Ubuntu 16.4 LTS with proprietary NVIDIA driver 384.111 and cannot get context sharing to work reliably.
In my own application, using glfw 3.1.1, a GL_INVALID_OPERATION error is triggered whenever accessing an object in a context different from the one it was create in. This error is only triggered when the first window is created with an OpenGL version above 3.1.

To see if this was specific to my application, I compiled and tested the sharing example in both glfw 3.1.1 and 3.2.1. However, an GL_INVALID_OPERATION is generated at glEnd() when drawing the quad, regardless of the OpenGL version. ThereforeI could not use the test as a reference.

Now I have two questions:
Was there a change in context handling between OpenGL version 3.1 and 3.2, or is this a bug in the driver/GLFW?
Is the context sharing bidirectional? From the GLFW documentation it is not clear whether it is only the first window(passed into the second glfwCreateWindow) which can access the other window’s objects.

It looks like you’ve added an issue for sharing on X11 to GLFW’s tracker so I’ll link to it here.

1 Like

You mention for the sharing example that:

However I can’t find glEnd() in the current sharing example on Github. Could you check against this example if possible?

It got moved from tests and rewritten for 3.3.

Thanks @elmindreda. I take it it’s still worth trying the revised example (as this shouldn’t raise an error on the deprecated legacy OpenGL glEnd() function)?

Yes, it’s definitely worth trying.

Thanks for the quick replies!
I cloned and compiled the current master with glGetError calls inserted and it did not produce anz errors. When I copied over the new sharing example to version 3.2.1, there is no error as well.
I thought that the sharing test applications were using the default OpenGL version (1.0) and thus should not trigger any legacy warnings. This is however only true for the test in glfw 3.1.1.

From the new sharing example, it seems like sharing is bidirectional. Is that the case in all glfw versions?

Hi @wobak,

GLFW only acts as a platform independent way to setup a context so it shares objects with another, but the behaviour is set by the OpenGL implementation rather than GLFW. The sharing is bi-directional.

See the OpenGL wiki on Object Sharing.



1 Like