Hi,

I just wanted to let you know that I fixed my crash with a straight forward implementation of the function that I mentioned earlier today. This is of course by no means a real fix in the osg way but for that I simply don't know all the tiny details of the optimizations.

The problem occured when I reloaded my scene with (a changed version, with vertex attributes, of) precipitation. What I suspect what happened is that a vertex attribute unit was still activated from the previously loaded scene, while it should have been disabled after loading the scene again.

Of course it should be fixed elsewhere, but this is how I fixed it, in a straightforward way, unconditionally: void State::disableVertexAttribPointersAboveAndIncluding( unsigned int index )
{
   if (_glDisableVertexAttribArray)
   {
// Fix by RdV, to avoid a crash when a non-existing vertex array is still bound, 20080530
#if 0
       while (index< _vertexAttribArrayList.size())
       {
           EnabledArrayPair& eap = _vertexAttribArrayList[index];
           if (eap._enabled || eap._dirty)
           {
               eap._enabled = false;
               eap._dirty = false;
               _glDisableVertexAttribArray( index );
           }
           ++index;
       }
#else
     int maximumNoOfVertexAttributes;
     glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maximumNoOfVertexAttributes);
     while (index < maximumNoOfVertexAttributes) {
       _glDisableVertexAttribArray( index );
       index++;
     }
#endif
   }
}

and I needed an unconditional enabling of the vertex attribute unit as well:
void State::setVertexAttribPointer( unsigned int index,
GLint size, GLenum type, GLboolean normalized,
                                   GLsizei stride, const GLvoid *ptr )
{
   if (_glVertexAttribPointer)
   {
if ( index >= _vertexAttribArrayList.size()) _vertexAttribArrayList.resize(index+1);
       EnabledArrayPair& eap = _vertexAttribArrayList[index];

// Fix by RdV, to avoid a crash when a non-existing vertex array is still bound, 20080530
#if 0
       if (!eap._enabled || eap._dirty)
       {
           eap._enabled = true;
           _glEnableVertexAttribArray( index );
       }
#else
       _glEnableVertexAttribArray( index );
#endif
//if (eap._pointer != ptr || eap._normalized!=normalized || eap._dirty)
       {
_glVertexAttribPointer( index, size, type, normalized, stride, ptr );
           eap._pointer = ptr;
           eap._normalized = normalized;
       }
       eap._dirty = false;
   }
} I did this fix in osg-2.2.0 but the func still exists as-is in svn. Hopefully this triggers a fix in the osg way by you.

Cheers
Raymond




Raymond de Vries wrote:
Hi,

I am trying to add vertex attributes to my shader program and I am having a crash when I reload the geometry with vertex attributes.

Now I am looking into the source and came across the func osg::State::disableVertexAttribPointersAboveAndIncluding(). Looking at the func name I would expect that the vertex attribute units would be disabled, but it doesn't count up. I am really new in this area and would like to learn. Is there someone who can explain this piece?

Mike Weiblen, could you take a look maybe, you're a shader expert!

A related question: I see that 'some' vertex attribute units are used in examples like the glsl_confetti.osg. Can any unit be used arbitrarily, without 0 which seems to be used for the vertex coordinates?

thanks a lot for explaining, best regards
Raymond


this is in the svn btw
_______________________________________________
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