[osg-users] Segfault occuring in -- void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplier) const -- after updating from osg 3.3.1 to the current trunk
Robert Osfield
robert.osfield at gmail.com
Fri May 1 12:56:57 PDT 2015
Hi Curtis,
I haven't had a chance to look at the code yet but from your
description of the fix you've applied it suggests to me that the
normal scene graph mechanism used to inform the scene graph that the
number of contexts and hence range of ContextID's has changed is not
happening as it should be.
When a new context is created what should a happen is that the viewer
should call scenegraph->resizeGLObjectBuffers(maxContextID); For some
reason in your application this doesn't seem to be happening.
Robert.
On 1 May 2015 at 20:49, Curtis Rubel <crubel at compro.net> wrote:
> Hi Robert,
>
> After getting the small example to fail today, I was looking some more and came up with a few changes here that allows me to run.
>
> I am relatively sure that this will not be the final fix, but I am hoping that it will at least get you closer to what is causing the problem. Here is an svn diff listing from my modified Text.cpp
>
>
> Code:
>
> Index: src/osgText/Text.cpp
> ===================================================================
> --- src/osgText/Text.cpp (revision 14858)
> +++ src/osgText/Text.cpp (working copy)
> @@ -726,6 +726,12 @@
> GlyphQuads::Coords2& coords2 = glyphquad._coords;
> GlyphQuads::Coords3& transformedCoords = glyphquad._transformedCoords[contextID];
>
> + if(transformedCoords == NULL)
> + {
> + glyphquad._transformedCoords[contextID] = new osg::Vec3Array;
> + transformedCoords = glyphquad._transformedCoords[contextID];
> + }
> +
> unsigned int numCoords = coords2->size();
> if (numCoords != transformedCoords->size())
> {
> @@ -804,6 +810,12 @@
> for( ; backdrop_index < max_backdrop_index; backdrop_index++)
> {
> GlyphQuads::Coords3& transformedCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
> + if(transformedCoords == NULL)
> + {
> + glyphquad._transformedCoords[contextID] = new osg::Vec3Array;
> + transformedCoords = glyphquad._transformedCoords[contextID];
> + }
> +
> unsigned int numCoords = coords2->size();
> if (numCoords!=transformedCoords->size())
> {
> @@ -1288,7 +1300,7 @@
> if ( !_textureGlyphQuadMap.empty() )
> {
> const GlyphQuads& glyphquad = (_textureGlyphQuadMap.begin())->second;
> - if ( :q)
> + if ( glyphquad._transformedCoords[contextID] == NULL )
> {
> computePositions(contextID);
> }
>
>
>
>
>
> The diff at line 1303 in my source file:
> - if ( glyphquad._transformedCoords[contextID]->empty() )
> + if ( glyphquad._transformedCoords[contextID] == NULL )
>
> The glyphquad._transformedCoords[contextID] call creates an
> empty buffered object entry since the contextID coming in is not present, yet and the buffered_object API automatically resizes the array if it does not contain the value in the [] operator. So now I check for NULL instead of empty() and thereby now calling computePositions(contextID).
>
> The change in the computePositions function down around line 727
> checks to see if the GlyphQuads::Coords3& transformedCoords is NULL,
> if it is we add a new osg::Vec3Array in there that then gets filled with
> what I hope is the correct data...
>
> Anyhow a brief explanation of what I did here to try and get some sort of workaround as I was curious as to what was going on and had some spare time this afternoon to look at it...
>
> Since you are already in the osgText code working maybe with this it will allow you to get an idea of this issue and possibly incorporate both fixes at the same time...well at least I hope so as by no means do I claim to know much about this...hopefully me just trying to help did not confuse you more instead.
>
> I am also attaching the patched version of the file to this post for you as well..
>
>
> ...
>
> Thank you!
>
> Cheers,
> Curtis
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=63602#63602
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
More information about the osg-users
mailing list