HI Nicolas,

The OSG is multi-threaded by default, but OpenGL isn't, you can only call
OpenGL from the thread that has made that OpenGL context current and if you
don't you get errors like you have seen or crashes.

When running milti-threaded the OSG works with the way OpenGL is designed
by having a dedicated osg::GraphicsThread per osg::GraphicsContext (which
wraps up the GL graphics context), once the GraphicsContext the created the
GraphicsThreaded is started and then takes over full responsibility for
issuing OpenGL commands. This solution is both efficient and robust.

There is a but though... libraries like CEGUI aren't designed for
multi-threaded and multi-context usage and can only be used with a library
as powerful and flexible as the OSG if you jump through certain hoops to
hide the fact that there is multiple threads or multiple context happening
in the application.  One of these hoops is calling the CEGUI init within
the Drawable::drawImplementation(),  It may not look elegant, but then
CEGUI designed isn't that great so you have to work with what you have.

Another other possible solution is to bring the OSG down to CEGUI's level
but running the viewer SingleTheaded and making sure that you only ever use
one GraphicsContext.

Finally you could just use one of the OSG's native widget libraries - old
osgWidget and the newer osgUI library.  The later still isn't complete
enough for general usage but it's getting pretty close now.  I have chosen
the osgUI class naming and structure to mirror Qt where I can to assist
with familiarity, but with a twist, it all supports scripting natively so
you can create all your widgets and behaviors (including modify the scene
graph) entirely in scripting, Currently we only have Lua scripting plugin,
but at later date we'll other scripting languages.

Robert.


On 6 September 2014 22:22, Nicolas Mattia <[email protected]> wrote:

> Good evening,
>
> I ran into an OSG/GL problem while trying to work with CEGUI. To draw a
> CEGUI layer, I derived a new Drawable class, CEGUIDrawable. I backup OSG's
> state, make the call to CEGUI, and then pop OSG's state back. On that side,
> everything is working fine.
>
> The problem is where to do the CEGUI initialization, namely where to call
> the function CEGUI::OpenGLRenderer::bootstrapSystem() (a one time call). If
> I call it during the first draw pass, i.e. the first call to my
> CEGUIDrawable's drawImplementation(), it works fine. This is the idea used
> by Rui Wang in his OSG Cookbook, and is implemented here:
> https://github.com/xarray/osgRecipes/blob/master/cookbook/chapter9/ch09_04/CEGUIDrawable.cpp
> .
>
> Since this is not super clean, I wanted to take that boostrapSystem() call
> out of the Drawable's drawImplemention(). Unfortunately, calling
> boostrapSystem() from anywhere else causes an error, and that no matter if
> the viewer was realized or not, or that a thousand frames have been called
> beforehand. This is weird, because the error seems to occur in cases where
> OpenGL hasn't been initialized yet (no OpenGL context). Here's the error  :
>
>
> > OpenGLRenderer failed to initialise the GLEW library. Missing GL version
> >
>
>
> The first sentence is CEGUI realizing that the GLEW library it is using
> wasn't loaded correctly, and the second part (Missing GL version) is GLEW
> itself not being able to get the OpenGL context.
>
> Any idea what causes the problem and how it can be solved without having
> to call the CEGUI initialization (bootstrapSystem()) from within
> drawImplemention()?
>
> Thanks,
>
> Nicolas
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=60968#60968
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to