Hi J-S -- Good discussion. Thanks for responding to my OSG BOF pleas to start discussing GL3 in osg-users. :-)

I have the start of a NodeVisitor that will change all Geometry classes to use generic vertex attributes, as well as switch DLs to buffer objects. See below. I can also set uniform matrix values for the view and projection matrices in the app main loop.

While this is certainly an incomplete solution, it does allow me to use GLSL 1.30 shaders without any deprecated functionality. I currently have a GL3-safe cow running, doing all the transforms, lighting, and texture coord generation in GLSL 1.30 shaders. (One major piece of missing functionality is support for any model transforms buried in the scene graph. But it's a start.)

Ideally, OSG apps should not need to change at all to be compatible with GL3. However, at this point, it's too early to tell whether this will be the case or not. With that in mind, I feel that exploring ways for applications to use OSG in a GL3-safe way is a worthwhile endeavor, especially for new app development. If there are ways for apps to take responsibility for using vertex attribs and setting their own uniforms, we need to research this and make the methods known, so that new development can use these techniques and avoid any porting headaches that might otherwise arise in the future.


class MakeGeneric : public osg::NodeVisitor
{
public:
    MakeGeneric()
      : osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ) {}
    ~MakeGeneric() {}

    void apply( osg::Geode& geode )
    {
        unsigned int idx;
        for( idx=0; idx<geode.getNumDrawables(); idx++ )
        {
            osg::Drawable* draw = geode.getDrawable( idx );
            draw->setUseDisplayList( false );
            draw->setUseVertexBufferObjects( true );

            osg::Geometry* geom = draw->asGeometry();
            if( geom == NULL ) continue;

            geom->setVertexAttribData( 0,
                osg::Geometry::ArrayData( geom->getVertexArray(), osg::Geometry::BIND_PER_VERTEX ) );
            geom->setVertexAttribData( 1,
                osg::Geometry::ArrayData( geom->getNormalArray(), osg::Geometry::BIND_PER_VERTEX ) );
        }
    }

protected:
    const osg::Program& _prog;
};

Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
+1 303 859 9466


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to