[osg-users] How to have access to the active OpenGL context?

Alexandre Vaillancourt alexandre.vaillancourt.list at gmail.com
Mon Jan 25 12:33:05 PST 2016


Hello forum/list!

We're using a 3rd party library that requires an active OpenGL context for
the initialization. Not too much aware of what we were doing, we put the
initialization code in a draw call of a drawable. (On first draw, the 3rd
party initialization code is called because there is an active OpenGL
context at that moment.)

This worked, but some requirements in how our stuff is initialized changed
so we had to move the initialization code earlier.

So we used a GraphicsOperation callback to be called during the viewer ::
realize call. (We were not aware of that before.)

This works, and from what I read, this is the preferred way in this context.

Now, upon destruction, that 3rd party library would also need access the
OpenGL context to be active for cleanup and termination. It's not a HUGE
issue: the library has not a valid context so it can't do its things
correctly: in debug mode it spams the console (it just hushes them in
release).

I read that the usage of GraphicsContext::makeCurrent (and releaseContext)
would probably do the job (gc->makeCurrent(); otherLib->terminate();
gc->releaseContext();), but that it's not the preferred way because the
graphics thread could be in the middle of something.

What would be the clean way to do this?

Thanks!

P.S. Sorry if this looks dumb, we're slowly learning how stuff gets done :)

--
Alexandre Vaillancourt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20160125/631ad0fe/attachment-0002.htm>


More information about the osg-users mailing list