Call to glCreateProgram() fails

Hi,

I have a problem with two OpenGL-views. Unfortunately the whole application is quite complex, so I strip down the information I give here, to a minimum which can be understood. I know, this also results in a loss of lot of potential useful information, but describing everything which may be involved is way too complex.

So my problem: I have two OpenGL-views which each make use of an own context and an own window they appear in. This is what I’m doing:

  • open the first view → the view works fine and displays everything as expected
  • open the second view in a separate dialogue and with an own context → this view also works fine
  • close the second view and release all related sources (both views do not share any global, common data, at least within the scope of my code, so the second view should not release anything the first one uses)

→ now the first view no longer works, it displays the old data properly, but no more changes are possible. The point is, as soon as the second view was closed, all calls to glCreateProgram() return 0. When this happens, glGetError() returns an error code 0x502.

So my question: what exactly can cause glCreateProgram() - which worked until the second view was used - to fail with GL_INVALID_OPERATION?

Thanks!

According to the specification, glCreateProgram never generates errors (other than the generic rule that any call may generate GL_OUT_OF_MEMORY). Even the language that it returns zero if there is an error creating the program object seems to have been added “just in case” because there shouldn’t be any reason for glCreateProgram` to fail unless the implementation is fundamentally non-functional (out-of-memory, no context bound, memory corruption).

I suggest using a debugger. Either an OpenGL debugger such as RenderDoc or (for Nvidia) Nsight, or use a general purpose debugger to single-step through the process of closing a window (i.e. set a breakpoint at the start of the event handler and step until you start processing the next event for the surviving window).

That’s it! Closing the second view for some reason let’s the context get lost for the first one. Now after re-setting it, everything is working as expected. Thanks! :slight_smile: