<div dir="ltr"><div><div><div>Hi Julien,<br><br></div>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.<br><br></div>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.  <br><br></div><div>This doesn't mean that either the State::bindElementBufferObject(..) or the DrawElements could should not be fixed though.<br><br></div><div>Are you seeing a crash?<br></div><div><br></div><div>Robert.<br></div><div><br></div>Robert.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 7 September 2015 at 18:45, Julien Valentin <span dir="ltr"><<a href="mailto:julienvalentin51@gmail.com" target="_blank">julienvalentin51@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all<br>
I notice strange code at l231 of PrimitiveSet.cpp:<br>
<br>
Code:<br>
if (useVertexBufferObjects)<br>
    {<br>
        GLBufferObject* ebo = getOrCreateGLBufferObject(state.getContextID());<br>
        state.bindElementBufferObject(ebo);<br>
        if (ebo)<br>
        {<br>
            if (_numInstances>=1) state.glDrawElementsInstanced(mode, size(), GL_UNSIGNED_SHORT, (const GLvoid *)(ebo->getOffset(getBufferIndex())), _numInstances);<br>
            else glDrawElements(mode, size(), GL_UNSIGNED_SHORT, (const GLvoid *)(ebo->getOffset(getBufferIndex())));<br>
        }<br>
        else<br>
        {<br>
            if (_numInstances>=1) state.glDrawElementsInstanced(mode, size(), GL_UNSIGNED_SHORT, &front(), _numInstances);<br>
            else glDrawElements(mode, size(), GL_UNSIGNED_SHORT, &front());<br>
        }<br>
    }<br>
    else<br>
<br>
<br>
<br>
Does state.bindElementBufferObject(ebo); shouldn't be included in the if(ebo) test in case theres no index for the geometry?<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
Julien[/code]<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=65052#65052" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=65052#65052</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div><br></div>