[osg-users] bug in primitiveset.cpp?

Julien Valentin julienvalentin51 at gmail.com
Mon Sep 7 12:14:26 PDT 2015


Yes, it's a crash changing usevertexbufferobject at runtime that leads me to this observation:
bindElementBufferObject(0) crashes at if(ebo->isDirty())

Code:
inline void bindElementBufferObject(osg::GLBufferObject* ebo)
        {
            if (ebo == _currentEBO) return;
            if (ebo->isDirty()) ebo->compileBuffer();
            else ebo->bindBuffer();
            _currentEBO = ebo;
        }




robertosfield wrote:
> Hi Julien,
> 
> 
> I've just looked at the State::bindElementBufferObject(..) implementation and it looks like it attempts to access the ebo even if the ptr is 0 which will cause a crash.
> 
> 
> I'm guess this probably doesn't happen if the osg::Geometry is set up correctly as the EBO should be created, as if useVertexBufferObjects is true then the ebo "should" be non zero.  
> 
> 
> This doesn't mean that either the State::bindElementBufferObject(..) or the DrawElements could should not be fixed though.
> 
> 
> Are you seeing a crash?
> 
> 
> 
> Robert.
> 
> 
> 
> Robert.
> 
> 
> On 7 September 2015 at 18:45, Julien Valentin < ()> wrote:
> 
> > Hello all
> > I notice strange code at l231 of PrimitiveSet.cpp:
> > 
> > Code:
> > if (useVertexBufferObjects)
> >     {
> >         GLBufferObject* ebo = getOrCreateGLBufferObject(state.getContextID());
> >         state.bindElementBufferObject(ebo);
> >         if (ebo)
> >         {
> >             if (_numInstances>=1) state.glDrawElementsInstanced(mode, size(), GL_UNSIGNED_SHORT, (const GLvoid *)(ebo->getOffset(getBufferIndex())), _numInstances);
> >             else glDrawElements(mode, size(), GL_UNSIGNED_SHORT, (const GLvoid *)(ebo->getOffset(getBufferIndex())));
> >         }
> >         else
> >         {
> >             if (_numInstances>=1) state.glDrawElementsInstanced(mode, size(), GL_UNSIGNED_SHORT, &front(), _numInstances);
> >             else glDrawElements(mode, size(), GL_UNSIGNED_SHORT, &front());
> >         }
> >     }
> >     else
> > 
> > 
> > 
> > Does state.bindElementBufferObject(ebo); shouldn't be included in the if(ebo) test in case theres no index for the geometry?
> > 
> > Thank you!
> > 
> > Cheers,
> > Julien[/code]
> > 
> > ------------------
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=65052#65052 (http://forum.openscenegraph.org/viewtopic.php?p=65052#65052)
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > osg-users mailing list
> >  ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > 
> 
> 
>  ------------------
> Post generated by Mail2Forum


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








More information about the osg-users mailing list