[osg-users] Android: Survive Context Loss without complete reinitialization

Robert Osfield robert.osfield at gmail.com
Mon Jul 22 08:23:47 PDT 2019


HI Martin,

I don't have any Android experience so will defer to others on the
specifics, but one question everyone will probably have is what version of
the OSG are you using?  When you say the OSG's "built in" shaders, which
ones do you actually mean as there isn't any single set of "built in"
shaders - various NodeKits provide their own shaders, and there is a
osgUtil::ShaderGenVisitor that can create shaders for basic fixed function
scene graph, but it's written for desktop rather that GLES2.  For GLES2
applications one normally has to write your own shaders.

Robert.

On Mon, 22 Jul 2019 at 13:17, Martin Siggel <martinsiggel+osg at gmail.com>
wrote:

> Hi @all,
>
> I built a prototypical Android application based on your OSG GLES 2.0
> example. As also users in the OSG forum pointed out, the problem with
> this example application is, that is reinitialized everything, when
> e.g. leaving the app, changing the screen orientation and so on.
>
> I worked around this by just calling again
> 'setUpViewerAsEmbeddedInWindow' instead of creating everything from
> scratch.
>
> This seems to work pretty well, but sometimes - after a EGL context
> loss - the shader programs are somehow lost or invalid, resulting in a
> wrong rendering. This even happens, when using OSG's default shaders.
>
> When debugging OSG, it seems to me, that OSG tries to clean up all GL
> objects - including the shaders and reinitialize everything (also
> compiling the shader objects).
>
> Still, it happens, that the shaders get invalid sometimes and I'll get
> the error:
>
>    s_glUseProgram:2041 GL error 0x501
>
> Which basically means invalid program. Are the shader handled somehow
> differently? What do I have to do, in order to properly cleanup
> everything?
>
> Does anyone of you have any example surviving correctly a context loss
> e.g. due to application switch?
>
> Here are forum entries that describe a similar problem:
>
> http://forum.openscenegraph.org/viewtopic.php?t=11270
> http://forum.openscenegraph.org/viewtopic.php?t=14549 (see point number
> 4.)
>
>
> Best regards,
> Martin
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20190722/c7a18a89/attachment.html>


More information about the osg-users mailing list