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

68 views
Skip to first unread message

Alexandre Vaillancourt

unread,
Jan 25, 2016, 3:33:08 PM1/25/16
to OpenSceneGraph Users
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

Björn Blissing

unread,
Jan 26, 2016, 4:33:39 AM1/26/16
to osg-...@lists.openscenegraph.org
Hi Alexandre,

I have the same problem with my Oculus integration.

See discussion here (and possible solution here):
http://forum.openscenegraph.org/viewtopic.php?t=15186

Regards,
Björn

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66118#66118

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Alexandre Vaillancourt

unread,
Jan 26, 2016, 9:03:42 AM1/26/16
to OpenSceneGraph Users

Hi Björn!

This looks a lot like our situation. I thought there would have been anotner way, similar to the realize opertion. I will probably end up implementing one or both of the solutions described there.

Thanks for the tip!

Reply all
Reply to author
Forward
0 new messages