diff --git a/include/osg/Drawable b/include/osg/Drawable index b7ad13f43..bab190f04 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -66,14 +66,6 @@ class Geometry; class NodeVisitor; class ArrayDispatchers; -// this is defined to alter the way display lists are compiled inside the -// the draw method, it has been found that the NVidia drivers fail completely -// to optimize COMPILE_AND_EXECUTE in fact make it go slower than for no display -// lists, but optimize a separate COMPILE very well?! Define it as default -// the use of a separate COMPILE, then glCallList rather than use COMPILE_AND_EXECUTE. - -#define USE_SEPARATE_COMPILE_AND_EXECUTE - /** Pure virtual base class for drawable geometry. In OSG, everything that can * be rendered is implemented as a class derived from \c Drawable. The * \c Drawable class contains no drawing primitives, since these are provided @@ -235,9 +227,19 @@ class OSG_EXPORT Drawable : public Node inline bool getUseVertexBufferObjects() const { return _useVertexBufferObjects; } - /** Force a recompile on next draw() of any OpenGL display list associated with this geoset.*/ + /** Set whether to use a local VertexArrayObject for this Drawable.*/ + void setUseVertexArrayObject(bool flag); + + /** Return whether to use a local VertexArrayObject for this Drawable.*/ + bool getUseVertexArrayObject() const { return _useVertexArrayObject; } + + + /** Deprecated, use dirtyGLObjects() instead. */ virtual void dirtyDisplayList(); + /** Force a recompile on next draw() of any OpenGL objects associated with this geoset.*/ + virtual void dirtyGLObjects(); + /** Return the estimated size of GLObjects (display lists/vertex buffer objects) that are associated with this drawable. * This size is used a hint for reuse of deleted display lists/vertex buffer objects. */ @@ -254,13 +256,29 @@ class OSG_EXPORT Drawable : public Node * \c virtual). Subclasses should override * \c drawImplementation() instead. */ +#if 0 inline void draw(RenderInfo& renderInfo) const; +#else + void draw(RenderInfo& renderInfo) const; +#endif + + inline void drawInner(RenderInfo& renderInfo) const + { + if (_drawCallback.valid()) + _drawCallback->drawImplementation(renderInfo,this); + else + drawImplementation(renderInfo); + } + /** Immediately compile this \c Drawable into an OpenGL Display List/VertexBufferObjects. * @note Operation is ignored if \c _useDisplayList is \c false or VertexBufferObjects are not used. */ virtual void compileGLObjects(RenderInfo& renderInfo) const; + virtual VertexArrayState* setUpVertexArrayState(RenderInfo& renderInfo, bool usingVBOs) const; + + /** Set whether to use a mutex to ensure ref() and unref() are thread safe.*/ virtual void setThreadSafeRefUnref(bool threadSafe); @@ -466,14 +484,18 @@ class OSG_EXPORT Drawable : public Node bool _useDisplayList; bool _supportsVertexBufferObjects; bool _useVertexBufferObjects; + bool _useVertexArrayObject; typedef osg::buffered_value GLObjectList; mutable GLObjectList _globjList; + typedef buffered_object< osg::ref_ptr > VertexArrayStateList; + mutable VertexArrayStateList _vertexArrayStateList; + ref_ptr _drawCallback; }; - +#if 0 inline void Drawable::draw(RenderInfo& renderInfo) const { #ifdef OSG_GL_DISPLAYLISTS_AVAILABLE @@ -486,36 +508,24 @@ inline void Drawable::draw(RenderInfo& renderInfo) const // get the globj for the current contextID. GLuint& globj = _globjList[contextID]; - // call the globj if already set otherwise compile and execute. - if( globj != 0 ) + if( globj == 0 ) { - glCallList( globj ); - } - else if (_useDisplayList) - { -#ifdef USE_SEPARATE_COMPILE_AND_EXECUTE + // compile the display list globj = generateDisplayList(contextID, getGLObjectSizeHint()); glNewList( globj, GL_COMPILE ); - if (_drawCallback.valid()) - _drawCallback->drawImplementation(renderInfo,this); - else - drawImplementation(renderInfo); - glEndList(); - glCallList( globj); -#else - globj = generateDisplayList(contextID, getGLObjectSizeHint()); - glNewList( globj, GL_COMPILE_AND_EXECUTE ); if (_drawCallback.valid()) _drawCallback->drawImplementation(renderInfo,this); else drawImplementation(renderInfo); + glEndList(); -#endif } - return; + // call the display list + glCallList( globj); + return; } #endif @@ -525,6 +535,7 @@ inline void Drawable::draw(RenderInfo& renderInfo) const else drawImplementation(renderInfo); } +#endif class AttributeFunctorArrayVisitor : public ArrayVisitor { diff --git a/include/osg/Geometry b/include/osg/Geometry index 2f450561c..fba5c187c 100644 --- a/include/osg/Geometry +++ b/include/osg/Geometry @@ -140,8 +140,8 @@ class OSG_EXPORT Geometry : public Drawable method to use OpenGL vertex buffer objects for rendering.*/ virtual void setUseVertexBufferObjects(bool flag); - /** Force a recompile on next draw() of any OpenGL display list associated with this geoset.*/ - virtual void dirtyDisplayList(); + /** Force a recompile on next draw() of any OpenGL objects associated with this geoset.*/ + virtual void dirtyGLObjects(); /** Resize any per context GLObject buffers to specified size. */ @@ -178,14 +178,10 @@ class OSG_EXPORT Geometry : public Drawable /** Set up the vertex arrays for the purpose of rendering, called by drawImplemtation() prior to it calling drawPrimitivesImplementation().*/ - void old_drawVertexArraysImplementation(RenderInfo& renderInfo) const; + void drawVertexArraysImplementation(RenderInfo& renderInfo) const; /** dispatch the primitives to OpenGL, called by drawImplemtation() after calling drawVertexArraysImplementation().*/ - void old_drawPrimitivesImplementation(RenderInfo& renderInfo) const; - - - /** Set up the vertex arrays for the purpose of rendering, called by drawImplemtation() prior to it calling drawPrimitivesImplementation().*/ - void new_drawImplementation(RenderInfo& renderInfo) const; + void drawPrimitivesImplementation(RenderInfo& renderInfo) const; /** Return true, osg::Geometry does support accept(Drawable::AttributeFunctor&). */ @@ -223,10 +219,6 @@ class OSG_EXPORT Geometry : public Drawable void addVertexBufferObjectIfRequired(osg::Array* array); void addElementBufferObjectIfRequired(osg::PrimitiveSet* primitiveSet); - typedef buffered_object< osg::ref_ptr > VertexArrayStateList; - mutable VertexArrayStateList _vertexArrayStateList; - - PrimitiveSetList _primitives; osg::ref_ptr _vertexArray; osg::ref_ptr _normalArray; diff --git a/include/osg/State b/include/osg/State index 0de2206c5..ae8bc0cf0 100644 --- a/include/osg/State +++ b/include/osg/State @@ -517,8 +517,17 @@ class OSG_EXPORT State : public Referenced + +#if 1 + void setCurrentVertexBufferObject(osg::GLBufferObject* vbo); + const GLBufferObject* getCurrentVertexBufferObject(); + + void bindVertexBufferObject(osg::GLBufferObject* vbo); + void unbindVertexBufferObject(); +#else void setCurrentVertexBufferObject(osg::GLBufferObject* vbo) { _currentVBO = vbo; } const GLBufferObject* getCurrentVertexBufferObject() { return _currentVBO; } + inline void bindVertexBufferObject(osg::GLBufferObject* vbo) { if (vbo) @@ -537,7 +546,15 @@ class OSG_EXPORT State : public Referenced _glBindBuffer(GL_ARRAY_BUFFER_ARB,0); _currentVBO = 0; } +#endif +#if 1 + void setCurrentElementBufferObject(osg::GLBufferObject* ebo); + const GLBufferObject* getCurrentElementBufferObject(); + + void bindElementBufferObject(osg::GLBufferObject* ebo); + void unbindElementBufferObject(); +#else void setCurrentElementBufferObject(osg::GLBufferObject* ebo) { _currentEBO = ebo; } const GLBufferObject* getCurrentElementBufferObject() { return _currentEBO; } @@ -559,6 +576,7 @@ class OSG_EXPORT State : public Referenced _glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0); _currentEBO = 0; } +#endif void setCurrentPixelBufferObject(osg::GLBufferObject* pbo) { _currentPBO = pbo; } const GLBufferObject* getCurrentPixelBufferObject() { return _currentPBO; } @@ -681,6 +699,9 @@ class OSG_EXPORT State : public Referenced void setInterleavedArrays( GLenum format, GLsizei stride, const GLvoid* pointer); /** Set the vertex pointer using an osg::Array, and manage any VBO that are required.*/ +#if 1 + void setVertexPointer(const Array* array); +#else inline void setVertexPointer(const Array* array) { if (array) @@ -698,7 +719,7 @@ class OSG_EXPORT State : public Referenced } } } - +#endif /** wrapper around glEnableClientState(GL_VERTEX_ARRAY);glVertexPointer(..); * note, only updates values that change.*/ inline void setVertexPointer( GLint size, GLenum type, @@ -730,6 +751,9 @@ class OSG_EXPORT State : public Referenced #endif } +#if 1 + void disableVertexPointer(); +#else /** wrapper around glDisableClientState(GL_VERTEX_ARRAY). * note, only updates values that change.*/ inline void disableVertexPointer() @@ -753,7 +777,11 @@ class OSG_EXPORT State : public Referenced disableVertexAttribPointer(_vertexAlias._location); #endif } +#endif +#if 1 + void dirtyVertexPointer(); +#else inline void dirtyVertexPointer() { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE @@ -770,8 +798,12 @@ class OSG_EXPORT State : public Referenced dirtyVertexAttribPointer(_vertexAlias._location); #endif } +#endif +#if 1 + void setNormalPointer(const Array* array); +#else /** Set the normal pointer using an osg::Array, and manage any VBO that are required.*/ inline void setNormalPointer(const Array* array) { @@ -790,7 +822,7 @@ class OSG_EXPORT State : public Referenced } } } - +#endif /** wrapper around glEnableClientState(GL_NORMAL_ARRAY);glNormalPointer(..); * note, only updates values that change.*/ inline void setNormalPointer( GLenum type, GLsizei stride, @@ -822,6 +854,9 @@ class OSG_EXPORT State : public Referenced #endif } +#if 1 + void disableNormalPointer(); +#else /** wrapper around glDisableClientState(GL_NORMAL_ARRAY); * note, only updates values that change.*/ inline void disableNormalPointer() @@ -845,7 +880,11 @@ class OSG_EXPORT State : public Referenced disableVertexAttribPointer(_normalAlias._location); #endif } +#endif +#if 1 + void dirtyNormalPointer(); +#else inline void dirtyNormalPointer() { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE @@ -862,7 +901,11 @@ class OSG_EXPORT State : public Referenced dirtyVertexAttribPointer(_normalAlias._location); #endif } +#endif +#if 1 + void setColorPointer(const Array* array); +#else /** Set the color pointer using an osg::Array, and manage any VBO that are required.*/ inline void setColorPointer(const Array* array) { @@ -881,7 +924,7 @@ class OSG_EXPORT State : public Referenced } } } - +#endif /** wrapper around glEnableClientState(GL_COLOR_ARRAY);glColorPointer(..); * note, only updates values that change.*/ @@ -914,6 +957,9 @@ class OSG_EXPORT State : public Referenced #endif } +#if 1 + void disableColorPointer(); +#else /** wrapper around glDisableClientState(GL_COLOR_ARRAY); * note, only updates values that change.*/ inline void disableColorPointer() @@ -937,7 +983,11 @@ class OSG_EXPORT State : public Referenced disableVertexAttribPointer(_colorAlias._location); #endif } +#endif +#if 1 + void dirtyColorPointer(); +#else inline void dirtyColorPointer() { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE @@ -954,11 +1004,14 @@ class OSG_EXPORT State : public Referenced dirtyVertexAttribPointer(_colorAlias._location); #endif } - +#endif inline bool isSecondaryColorSupported() const { return _isSecondaryColorSupportResolved?_isSecondaryColorSupported:computeSecondaryColorSupported(); } +#if 1 + void setSecondaryColorPointer(const Array* array); +#else /** Set the secondary color pointer using an osg::Array, and manage any VBO that are required.*/ inline void setSecondaryColorPointer(const Array* array) { @@ -977,11 +1030,15 @@ class OSG_EXPORT State : public Referenced } } } +#endif /** wrapper around glEnableClientState(GL_SECONDARY_COLOR_ARRAY);glSecondayColorPointer(..); * note, only updates values that change.*/ void setSecondaryColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_TRUE ); +#if 1 + void disableSecondaryColorPointer(); +#else /** wrapper around glDisableClientState(GL_SECONDARY_COLOR_ARRAY); * note, only updates values that change.*/ inline void disableSecondaryColorPointer() @@ -1005,7 +1062,11 @@ class OSG_EXPORT State : public Referenced disableVertexAttribPointer(_secondaryColorAlias._location); #endif } +#endif +#if 1 + inline void dirtySecondaryColorPointer(); +#else inline void dirtySecondaryColorPointer() { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE @@ -1022,10 +1083,14 @@ class OSG_EXPORT State : public Referenced dirtyVertexAttribPointer(_secondaryColorAlias._location); #endif } +#endif inline bool isFogCoordSupported() const { return _isFogCoordSupportResolved?_isFogCoordSupported:computeFogCoordSupported(); } +#if 1 + void setFogCoordPointer(const Array* array); +#else /** Set the fog coord pointer using an osg::Array, and manage any VBO that are required.*/ inline void setFogCoordPointer(const Array* array) { @@ -1044,12 +1109,15 @@ class OSG_EXPORT State : public Referenced } } } - +#endif /** wrapper around glEnableClientState(GL_FOG_COORDINATE_ARRAY);glFogCoordPointer(..); * note, only updates values that change.*/ void setFogCoordPointer( GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized=GL_FALSE ); +#if 1 + void disableFogCoordPointer(); +#else /** wrapper around glDisableClientState(GL_FOG_COORDINATE_ARRAY); * note, only updates values that change.*/ inline void disableFogCoordPointer() @@ -1073,7 +1141,11 @@ class OSG_EXPORT State : public Referenced disableVertexAttribPointer(_fogCoordAlias._location); #endif } +#endif +#if 1 + void dirtyFogCoordPointer(); +#else inline void dirtyFogCoordPointer() { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE @@ -1090,9 +1162,12 @@ class OSG_EXPORT State : public Referenced dirtyVertexAttribPointer(_fogCoordAlias._location); #endif } +#endif - +#if 1 + void setTexCoordPointer(unsigned int unit, const Array* array); +#else /** Set the tex coord pointer using an osg::Array, and manage any VBO that are required.*/ inline void setTexCoordPointer(unsigned int unit, const Array* array) { @@ -1111,7 +1186,7 @@ class OSG_EXPORT State : public Referenced } } } - +#endif /** wrapper around glEnableClientState(GL_TEXTURE_COORD_ARRAY);glTexCoordPointer(..); * note, only updates values that change.*/ inline void setTexCoordPointer( unsigned int unit, @@ -1150,6 +1225,9 @@ class OSG_EXPORT State : public Referenced #endif } +#if 1 + void disableTexCoordPointer( unsigned int unit ); +#else /** wrapper around glDisableClientState(GL_TEXTURE_COORD_ARRAY); * note, only updates values that change.*/ inline void disableTexCoordPointer( unsigned int unit ) @@ -1179,7 +1257,11 @@ class OSG_EXPORT State : public Referenced disableVertexAttribPointer(_texCoordAliasList[unit]._location); #endif } +#endif +#if 1 + void dirtyTexCoordPointer( unsigned int unit ); +#else inline void dirtyTexCoordPointer( unsigned int unit ) { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE @@ -1198,8 +1280,11 @@ class OSG_EXPORT State : public Referenced dirtyVertexAttribPointer(_texCoordAliasList[unit]._location); #endif } +#endif - +#if 1 + void disableTexCoordPointersAboveAndIncluding( unsigned int unit ); +#else inline void disableTexCoordPointersAboveAndIncluding( unsigned int unit ) { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE @@ -1229,7 +1314,11 @@ class OSG_EXPORT State : public Referenced disableVertexAttribPointersAboveAndIncluding(_texCoordAliasList[unit]._location); #endif } +#endif +#if 1 + void dirtyTexCoordPointersAboveAndIncluding( unsigned int unit ); +#else inline void dirtyTexCoordPointersAboveAndIncluding( unsigned int unit ) { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE @@ -1251,7 +1340,7 @@ class OSG_EXPORT State : public Referenced dirtyVertexAttribPointersAboveAndIncluding(_texCoordAliasList[unit]._location); #endif } - +#endif /// For GL>=2.0 uses GL_MAX_TEXTURE_COORDS, for GL<2 uses GL_MAX_TEXTURE_UNITS inline GLint getMaxTextureCoords() const { return _glMaxTextureCoords; } @@ -1274,8 +1363,11 @@ class OSG_EXPORT State : public Referenced bool setClientActiveTextureUnit( unsigned int unit ); /** Get the current tex coord array texture unit.*/ - unsigned int getClientActiveTextureUnit() const { return _currentClientActiveTextureUnit; } + unsigned int getClientActiveTextureUnit() const; +#if 1 + void setVertexAttribPointer(unsigned int unit, const Array* array); +#else /** Set the vertex attrib pointer using an osg::Array, and manage any VBO that are required.*/ inline void setVertexAttribPointer(unsigned int unit, const Array* array) { @@ -1294,7 +1386,11 @@ class OSG_EXPORT State : public Referenced } } } +#endif +#if 1 + void setVertexAttribLPointer(unsigned int unit, const Array* array); +#else /** Set the vertex attrib pointer using an osg::Array, and manage any VBO that are required.*/ inline void setVertexAttribLPointer(unsigned int unit, const Array* array) { @@ -1313,7 +1409,11 @@ class OSG_EXPORT State : public Referenced } } } +#endif +#if 1 + void setVertexAttribIPointer(unsigned int unit, const Array* array); +#else /** Set the vertex attrib pointer using an osg::Array, and manage any VBO that are required.*/ inline void setVertexAttribIPointer(unsigned int unit, const Array* array) { @@ -1332,6 +1432,7 @@ class OSG_EXPORT State : public Referenced } } } +#endif /** wrapper around glEnableVertexAttribArrayARB(index);glVertexAttribPointerARB(..); * note, only updates values that change.*/ @@ -1357,6 +1458,9 @@ class OSG_EXPORT State : public Referenced void disableVertexAttribPointersAboveAndIncluding( unsigned int index ); +#if 1 + void dirtyVertexAttribPointer( unsigned int index ); +#else inline void dirtyVertexAttribPointer( unsigned int index ) { if (index<_vertexAttribArrayList.size()) @@ -1366,7 +1470,11 @@ class OSG_EXPORT State : public Referenced eap._dirty = true; } } +#endif +#if 1 + void dirtyVertexAttribPointersAboveAndIncluding( unsigned int index ); +#else inline void dirtyVertexAttribPointersAboveAndIncluding( unsigned int index ) { while (index<_vertexAttribArrayList.size()) @@ -1377,6 +1485,7 @@ class OSG_EXPORT State : public Referenced ++index; } } +#endif bool isVertexBufferObjectSupported() const { return _isVertexBufferObjectSupportResolved?_isVertexBufferObjectSupported:computeVertexBufferObjectSupported(); } diff --git a/include/osg/VertexArrayState b/include/osg/VertexArrayState index eefca0120..97e35bcd8 100644 --- a/include/osg/VertexArrayState +++ b/include/osg/VertexArrayState @@ -21,8 +21,6 @@ namespace osg { - - class VertexArrayState : public osg::Referenced { public: @@ -31,113 +29,109 @@ public: struct ArrayDispatch : public osg::Referenced { - ArrayDispatch(Array* in_array): - array(in_array), - modifiedCount(0xffffffff) {} + ArrayDispatch(): + array(0), + modifiedCount(0xffffffff), + active(false) {} - inline void dispatchIfDirty(osg::State& state, unsigned int index=0) - { - if (modifiedCount!=array->getModifiedCount()) dispatch(state, index); - } + virtual void enable_and_dispatch(osg::State& /*state*/, const osg::Array* /*new_array*/) {} // = 0; - virtual void dispatch(osg::State& state, unsigned int index=0) = 0; + virtual void enable_and_dispatch(osg::State& /*state*/, const osg::Array* /*new_array*/, const osg::GLBufferObject* /*vbo*/) {} // = 0; - virtual void dispatchDeprecated(osg::State& state, unsigned int index=0); + virtual void dispatch(osg::State& /*state*/, const osg::Array* /*new_array*/) {} // = 0; - osg::Array* array; - unsigned int modifiedCount; + virtual void dispatch(osg::State& /*state*/, const osg::Array* /*new_array*/, const osg::GLBufferObject* /*vbo*/) {} // = 0; + + virtual void disable(osg::State& /*state*/) {} // = 0; + + const osg::Array* array; + unsigned int modifiedCount; + bool active; }; typedef std::vector< ref_ptr > ArrayDispatchList; - ArrayDispatchList& getArrayDispatchList(Array::Binding binding) + void setCurrentVertexBufferObject(osg::GLBufferObject* vbo) { _currentVBO = vbo; } + GLBufferObject* getCurrentVertexBufferObject() { return _currentVBO; } + + inline void bindVertexBufferObject(osg::GLBufferObject* vbo) { - switch(binding) - { - case(osg::Array::BIND_PER_VERTEX): return _dispatchArrays; - case(osg::Array::BIND_PER_PRIMITIVE_SET): return _dispatchPerPrimitiveSet; - default: return _dispatchOverall; - } + if (vbo == _currentVBO) return; + if (vbo->isDirty()) vbo->compileBuffer(); + else vbo->bindBuffer(); + _currentVBO = vbo; + } + + inline void unbindVertexBufferObject() + { + if (!_currentVBO) return; + _ext->glBindBuffer(GL_ARRAY_BUFFER_ARB,0); + _currentVBO = 0; } - enum VertexArrayIdentifier + void setCurrentElementBufferObject(osg::GLBufferObject* ebo) { _currentEBO = ebo; } + GLBufferObject* getCurrentElementBufferObject() { return _currentEBO; } + + inline void bindElementBufferObject(osg::GLBufferObject* ebo) { - VERTEX_ARRAY, - NORMAL_ARRAY, - COLOR_ARRAY, - SECONDARY_COLOR_ARRAY, - FOG_COORD_ARRAY, - TEX_COORD_ARRAY, - VERTEX_ATTRIB_ARRAY=TEX_COORD_ARRAY+32 - }; - - - void assignVertexArray(osg::Array* array); - void assignColorArray(osg::Array* array); - void assignNormalArray(osg::Array* array); - - void assignSecondaryColorArray(osg::Array* array); - void assignFogCoordArray(osg::Array* array); - - void assignTexCoordArray(unsigned int unit, osg::Array* array); - void assignVertexAttribArray(unsigned int unit, osg::Array* array); - - inline void dispatchOverall(osg::State& state) - { - for(ArrayDispatchList::iterator itr = _dispatchOverall.begin(); - itr != _dispatchOverall.end(); - ++itr) - { - (*(*itr)).dispatch(state); - } + if (ebo == _currentEBO) return; + if (ebo->isDirty()) ebo->compileBuffer(); + else ebo->bindBuffer(); + _currentEBO = ebo; } - void dispatchPerPrimitveSet(osg::State& state, unsigned int index) + inline void unbindElementBufferObject() { - for(ArrayDispatchList::iterator itr = _dispatchPerPrimitiveSet.begin(); - itr != _dispatchPerPrimitiveSet.end(); - ++itr) - { - (*(*itr)).dispatch(state, index); - } + if (!_currentEBO) return; + _ext->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0); + _currentEBO = 0; } - inline void dispatchArrays(osg::State& state) - { - // need to check previous enabled/disabled mode + void assignAllDispatchers(); - if (_vertexArrayObject) - { - for(ArrayDispatchList::iterator itr = _dispatchArrays.begin(); - itr != _dispatchArrays.end(); - ++itr) - { - (*(*itr)).dispatch(state); - } - } - else - { - for(ArrayDispatchList::iterator itr = _dispatchArrays.begin(); - itr != _dispatchArrays.end(); - ++itr) - { - (*(*itr)).dispatchDeprecated(state); - } - } - } + virtual void assignVertexArrayDispatcher(); + virtual void assignNormalArrayDispatcher(); + virtual void assignColorArrayDispatcher(); + virtual void assignSecondaryColorArrayDispatcher(); + virtual void assignFogCoordArrayDispatcher(); + virtual void assignTexCoordArrayDispatcher(unsigned int numUnits); + virtual void assignVertexAttribArrayDispatcher(unsigned int numUnits); - inline void dispatchArraysIfDirty(osg::State& state) - { - // need to check previous enabled/disabled mode + inline bool isVertexBufferObjectSupported() const { return true; } + + void setArray(ArrayDispatch* vad, osg::State& state, const osg::Array* new_array); + void disable(ArrayDispatch* vad, osg::State& state) { vad->disable(state); vad->array=0; vad->modifiedCount=0xffffffff; vad->active=false; } + + inline void setVertexArray(osg::State& state, const osg::Array* array) { setArray(_vertexArray.get(), state, array); } + inline void disableVertexArray(osg::State& state) { disable(_vertexArray.get(), state); } + + inline void setNormalArray(osg::State& state, const osg::Array* array) { setArray(_normalArray.get(), state, array); } + inline void disableNormalArray(osg::State& state) { disable(_normalArray.get(), state); } + + inline void setColorArray(osg::State& state, const osg::Array* array) { setArray(_colorArray.get(), state, array); } + inline void disableColorArray(osg::State& state) { disable(_colorArray.get(), state); } + + inline void setSecondaryColorArray(osg::State& state, const osg::Array* array) { setArray(_secondaryColorArray.get(), state, array); } + inline void disableSecondaryColorArray(osg::State& state) { disable(_secondaryColorArray.get(), state); } + + inline void setFogCoordArray(osg::State& state, const osg::Array* array) { setArray(_fogCoordArray.get(), state, array); } + inline void disableFogCoordArray(osg::State& state) { disable(_fogCoordArray.get(), state); } + + inline void setTexCoordArray(osg::State& state, unsigned int unit, const osg::Array* array) { setArray(_texCoordArrays[unit].get(), state, array); } + inline void disableTexCoordArray(osg::State& state, unsigned int unit) { disable(_texCoordArrays[unit].get(),state); } + void disableTexCoordArrayAboveAndIncluding(osg::State& state, unsigned int index); + + inline void setVertexAttribArray(osg::State& state, unsigned int unit, const osg::Array* array) { setArray(_vertexAttribArrays[unit].get(), state, array); } + inline void disableVertexAttribArray(osg::State& state, unsigned int unit) { disable(_vertexAttribArrays[unit].get(), state); } + void disableVertexAttribArrayAboveAndIncluding(osg::State& state, unsigned int index); + + /** Mark all the vertex attributes as being disabled but leave the disabling till a later call to applyDisablingOfVertexAttributes.*/ + void lazyDisablingOfVertexAttributes(); + + /** Disable all the vertex attributes that have been marked as to be disabled.*/ + void applyDisablingOfVertexAttributes(osg::State& state); - for(ArrayDispatchList::iterator itr = _dispatchArrays.begin(); - itr != _dispatchArrays.end(); - ++itr) - { - (*(*itr)).dispatchIfDirty(state); - } - } @@ -154,49 +148,6 @@ public: - void setCurrentVertexBufferObject(osg::GLBufferObject* vbo) { _currentVBO = vbo; } - GLBufferObject* getCurrentVertexBufferObject() { return _currentVBO; } - inline void bindVertexBufferObject(osg::GLBufferObject* vbo) - { - if (vbo) - { - if (vbo == _currentVBO) return; - if (vbo->isDirty()) vbo->compileBuffer(); - else vbo->bindBuffer(); - _currentVBO = vbo; - } - else unbindVertexBufferObject(); - } - - inline void unbindVertexBufferObject() - { - if (!_currentVBO) return; - _ext->glBindBuffer(GL_ARRAY_BUFFER_ARB,0); - _currentVBO = 0; - } - - - void setCurrentElementBufferObject(osg::GLBufferObject* ebo) { _currentEBO = ebo; } - GLBufferObject* getCurrentElementBufferObject() { return _currentEBO; } - - inline void bindElementBufferObject(osg::GLBufferObject* ebo) - { - if (ebo) - { - //if (ebo == _currentEBO) return; - if (ebo->isDirty()) ebo->compileBuffer(); - else ebo->bindBuffer(); - _currentEBO = ebo; - } - else unbindElementBufferObject(); - } - - inline void unbindElementBufferObject() - { - //if (!_currentEBO) return; - _ext->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0); - _currentEBO = 0; - } public: @@ -208,12 +159,21 @@ public: GLuint _vertexArrayObject; + + osg::ref_ptr _vertexArray; + osg::ref_ptr _normalArray; + osg::ref_ptr _colorArray; + osg::ref_ptr _secondaryColorArray; + osg::ref_ptr _fogCoordArray; + ArrayDispatchList _texCoordArrays; + ArrayDispatchList _vertexAttribArrays; + + typedef std::vector ActiveDispatchers; + ActiveDispatchers _activeDispatchers; + ActiveDispatchers _previous_activeDispatchers; + GLBufferObject* _currentVBO; GLBufferObject* _currentEBO; - - ArrayDispatchList _dispatchOverall; - ArrayDispatchList _dispatchPerPrimitiveSet; - ArrayDispatchList _dispatchArrays; }; diff --git a/src/osg/DisplaySettings.cpp b/src/osg/DisplaySettings.cpp index d02bc88af..128ed9ca8 100644 --- a/src/osg/DisplaySettings.cpp +++ b/src/osg/DisplaySettings.cpp @@ -243,7 +243,8 @@ void DisplaySettings::setDefaults() _swapMethod = SWAP_DEFAULT; _syncSwapBuffers = 0; - _geometryImplementation = VERTEX_ARRAY_OBJECT; + // _geometryImplementation = VERTEX_ARRAY_OBJECT; + _geometryImplementation = OLD_GEOMETRY_IMPLEMENTATION; _keystoneHint = false; diff --git a/src/osg/Drawable.cpp b/src/osg/Drawable.cpp index 7a859e474..41abb15d4 100644 --- a/src/osg/Drawable.cpp +++ b/src/osg/Drawable.cpp @@ -234,6 +234,8 @@ Drawable::Drawable() _supportsVertexBufferObjects = true; _useVertexBufferObjects = false; #endif + + _useVertexArrayObject = false; } Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop): @@ -246,6 +248,7 @@ Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop): _useDisplayList(drawable._useDisplayList), _supportsVertexBufferObjects(drawable._supportsVertexBufferObjects), _useVertexBufferObjects(drawable._useVertexBufferObjects), + _useVertexArrayObject(drawable._useVertexArrayObject), _drawCallback(drawable._drawCallback) { setStateSet(copyop(drawable._stateset.get())); @@ -285,38 +288,6 @@ void Drawable::computeDataVariance() setDataVariance(dynamic ? DYNAMIC : STATIC); } -void Drawable::compileGLObjects(RenderInfo& renderInfo) const -{ - if (!_useDisplayList) return; - -#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE - // get the contextID (user defined ID of 0 upwards) for the - // current OpenGL context. - unsigned int contextID = renderInfo.getContextID(); - - // get the globj for the current contextID. - GLuint& globj = _globjList[contextID]; - - // call the globj if already set otherwise compile and execute. - if( globj != 0 ) - { - glDeleteLists( globj, 1 ); - } - - globj = generateDisplayList(contextID, getGLObjectSizeHint()); - glNewList( globj, GL_COMPILE ); - - if (_drawCallback.valid()) - _drawCallback->drawImplementation(renderInfo,this); - else - drawImplementation(renderInfo); - - glEndList(); -#else - OSG_NOTICE<<"Warning: Drawable::compileGLObjects(RenderInfo&) - not supported."<resizeGLObjectBuffers(maxSize); _globjList.resize(maxSize); + + _vertexArrayStateList.resize(maxSize); } void Drawable::releaseGLObjects(State* state) const @@ -361,6 +334,9 @@ void Drawable::releaseGLObjects(State* state) const { const_cast(this)->dirtyDisplayList(); } + + + // TODO release VAO's.. } void Drawable::setSupportsDisplayList(bool flag) @@ -425,6 +401,13 @@ void Drawable::setUseDisplayList(bool flag) } +void Drawable::setUseVertexArrayObject(bool flag) +{ + _useVertexArrayObject = flag; +} + + + void Drawable::setUseVertexBufferObjects(bool flag) { // _useVertexBufferObjects = true; @@ -444,6 +427,11 @@ void Drawable::setUseVertexBufferObjects(bool flag) } void Drawable::dirtyDisplayList() +{ + dirtyGLObjects(); +} + +void Drawable::dirtyGLObjects() { #ifdef OSG_GL_DISPLAYLISTS_AVAILABLE unsigned int i; @@ -589,3 +577,115 @@ void Drawable::setBound(const BoundingBox& bb) const _boundingSphere = computeBound(); _boundingSphereComputed = true; } + + +void Drawable::compileGLObjects(RenderInfo& renderInfo) const +{ + +#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE + if (_useDisplayList) + { + // get the contextID (user defined ID of 0 upwards) for the + // current OpenGL context. + unsigned int contextID = renderInfo.getContextID(); + + // get the globj for the current contextID. + GLuint& globj = _globjList[contextID]; + + // call the globj if already set otherwise compile and execute. + if( globj != 0 ) + { + glDeleteLists( globj, 1 ); + } + + globj = generateDisplayList(contextID, getGLObjectSizeHint()); + glNewList( globj, GL_COMPILE ); + + drawInner(renderInfo); + + glEndList(); + } +#endif +} + +void Drawable::draw(RenderInfo& renderInfo) const +{ +// OSG_NOTICE<getGeometryImplementation()==DisplaySettings::VERTEX_ARRAY_OBJECT); + + if (useVertexArrayObject /*&& state.VAOSupported*/) + { + unsigned int contextID = renderInfo.getContextID(); + + VertexArrayState* vas = _vertexArrayStateList[contextID].get(); + if (!vas) + { + _vertexArrayStateList[contextID] = vas = setUpVertexArrayState(renderInfo, true); + } + + //state.pushVAO(localVAO); + osg::ref_ptr previous_vas = state.getCurrentVertexArrayState(); + + state.setCurrentVertexArrayState(vas); + + vas->bindVertexArrayObject(); + + drawInner(renderInfo); + + // state.popVAO(); + state.setCurrentVertexArrayState(previous_vas); + + return; + } +#endif + + // TODO, add check against whether VOA is active and supported + if (state.getCurrentVertexArrayState()) state.getCurrentVertexArrayState()->bindVertexArrayObject(); + + +#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE + if (_useDisplayList) + { + // get the contextID (user defined ID of 0 upwards) for the + // current OpenGL context. + unsigned int contextID = renderInfo.getContextID(); + + // get the globj for the current contextID. + GLuint& globj = _globjList[contextID]; + + if( globj == 0 ) + { + // compile the display list + globj = generateDisplayList(contextID, getGLObjectSizeHint()); + glNewList( globj, GL_COMPILE ); + + drawInner(renderInfo); + + glEndList(); + } + + // call the display list + glCallList( globj); + } + else +#endif + { + // if state.previousVertexArrayState() is different than currentVertexArrayState bind current + + // OSG_NOTICE<<"Fallback drawInner()........................"<get()); +} diff --git a/src/osg/GLBeginEndAdapter.cpp b/src/osg/GLBeginEndAdapter.cpp index 0972d17e3..5e9f6037a 100644 --- a/src/osg/GLBeginEndAdapter.cpp +++ b/src/osg/GLBeginEndAdapter.cpp @@ -183,13 +183,13 @@ void GLBeginEndAdapter::Begin(GLenum mode) // reset geometry _primitiveMode = mode; - if (_vertices.valid()) _vertices->clear(); + if (_vertices.valid()) { _vertices->clear(); _vertices->dirty(); } _normalAssigned = false; - if (_normals.valid()) _normals->clear(); + if (_normals.valid()) { _normals->clear(); _normals->dirty(); } _colorAssigned = false; - if (_colors.valid()) _colors->clear(); + if (_colors.valid()) { _colors->clear(); _colors->dirty(); } _texCoordAssignedList.clear(); _texCoordList.clear(); @@ -197,7 +197,7 @@ void GLBeginEndAdapter::Begin(GLenum mode) itr != _texCoordsList.end(); ++itr) { - if (itr->valid()) (*itr)->clear(); + if (itr->valid()) { (*itr)->clear(); (*itr)->dirty(); } } _vertexAttribAssignedList.clear(); diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index a41385780..1b708484f 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -29,7 +29,7 @@ Geometry::Geometry(): // setSupportsDisplayList(false); #else _supportsVertexBufferObjects = true; - _useVertexBufferObjects = true; + _useVertexBufferObjects = false; #endif } @@ -600,17 +600,15 @@ void Geometry::setUseVertexBufferObjects(bool flag) } } -void Geometry::dirtyDisplayList() +void Geometry::dirtyGLObjects() { - Drawable::dirtyDisplayList(); + Drawable::dirtyGLObjects(); } void Geometry::resizeGLObjectBuffers(unsigned int maxSize) { Drawable::resizeGLObjectBuffers(maxSize); - _vertexArrayStateList.resize(maxSize); - ArrayList arrays; if (getArrayList(arrays)) { @@ -675,21 +673,14 @@ VertexArrayState* Geometry::setUpVertexArrayState(RenderInfo& renderInfo, bool u _vertexArrayStateList[state.getContextID()] = vas = new osg::VertexArrayState(state.get()); - if (_vertexArray.valid()) vas->assignVertexArray(_vertexArray.get()); - if (_colorArray.valid()) vas->assignColorArray(_colorArray.get()); - if (_normalArray.valid()) vas->assignNormalArray(_normalArray.get()); - if (_secondaryColorArray.valid()) vas->assignSecondaryColorArray(_secondaryColorArray.get()); - if (_fogCoordArray.valid()) vas->assignFogCoordArray(_fogCoordArray.get()); + if (_vertexArray.valid()) vas->assignVertexArrayDispatcher(); + if (_colorArray.valid()) vas->assignColorArrayDispatcher(); + if (_normalArray.valid()) vas->assignNormalArrayDispatcher(); + if (_secondaryColorArray.valid()) vas->assignSecondaryColorArrayDispatcher(); + if (_fogCoordArray.valid()) vas->assignFogCoordArrayDispatcher(); - for(unsigned int i=0; i<_texCoordList.size(); ++i) - { - if (_texCoordList[i].valid()) vas->assignTexCoordArray(i, _texCoordList[i].get()); - } - - for(unsigned int i=0; i<_vertexAttribList.size(); ++i) - { - if (_vertexAttribList[i].valid()) vas->assignVertexAttribArray(i, _vertexAttribList[i].get()); - } + if (!_texCoordList.empty()) vas->assignTexCoordArrayDispatcher(_texCoordList.size()); + if (!_vertexAttribList.empty()) vas->assignVertexAttribArrayDispatcher(_vertexAttribList.size()); if (usingVBOs && ds->getGeometryImplementation()==DisplaySettings::VERTEX_ARRAY_OBJECT) { @@ -771,24 +762,21 @@ void Geometry::compileGLObjects(RenderInfo& renderInfo) const extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0); extensions->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0); - if (ds->getGeometryImplementation()!=DisplaySettings::OLD_GEOMETRY_IMPLEMENTATION) + if (ds->getGeometryImplementation()==DisplaySettings::VERTEX_ARRAY_OBJECT && !bufferObjects.empty()) { - setUpVertexArrayState(renderInfo, !bufferObjects.empty()); + setUpVertexArrayState(renderInfo, true); } } else { - if (ds->getGeometryImplementation()!=DisplaySettings::OLD_GEOMETRY_IMPLEMENTATION) - { - setUpVertexArrayState(renderInfo, false); - } - Drawable::compileGLObjects(renderInfo); } } void Geometry::drawImplementation(RenderInfo& renderInfo) const { + // OSG_NOTICE<<" Geometry::drawImplementation()"<fixDeprecatedData();"<getGeometryImplementation()!=DisplaySettings::OLD_GEOMETRY_IMPLEMENTATION); - if (useNewImplementation) - { - new_drawImplementation(renderInfo); - } - else - { - // OSG_NOTICE<<"Old implementation"<getGeometryImplementation()==DisplaySettings::VERTEX_ARRAY_OBJECT); - bool dispatchIfDirty = useVAO; - - - VertexArrayState* vas = _vertexArrayStateList[contextID].get(); - - OSG_NOTICE<<"Geometry::new_drawImplementation() "<bindVertexArrayObject(); - } - - osg::ref_ptr previous_vas = state.getCurrentVertexArrayState(); - - state.setCurrentVertexArrayState(vas); - - vas->dispatchOverall(state); - - - if (dispatchIfDirty) - { - vas->dispatchArraysIfDirty(state); - } - else - { - vas->dispatchArrays(state); - } - - if (!useVAO) - { - state.applyDisablingOfVertexAttributes(); - } - - for(unsigned int primitiveSetNum=0; primitiveSetNum<_primitives.size(); ++primitiveSetNum) - { - // dispatch any attributes that are bound per primitive - vas->dispatchPerPrimitveSet(state, primitiveSetNum); - - // disaptch the primitives - _primitives[primitiveSetNum]->draw(state, usingVertexBufferObjects); - } - - state.setCurrentVertexArrayState(previous_vas); - - if (!useVAO && usingVertexBufferObjects) - { - // unbind the VBO's if any are used. - state.unbindVertexBufferObject(); - state.unbindElementBufferObject(); - } - - if (useVAO) - { - vas->unbindVertexArrayObject(); - - state.setCurrentVertexBufferObject(vas->getCurrentVertexBufferObject()); - state.setCurrentElementBufferObject(vas->getCurrentElementBufferObject()); - - // unbind the VBO's if any are used. - state.unbindVertexBufferObject(); - state.unbindElementBufferObject(); - } - - if (checkForGLErrors) state.checkGLErrors("Geometry::new_drawImplementation() after primitive dispatch."); -} - - void Geometry::accept(AttributeFunctor& af) { AttributeFunctorArrayVisitor afav(af); diff --git a/src/osg/PrimitiveSet.cpp b/src/osg/PrimitiveSet.cpp index 96e4a5998..4958fdfab 100644 --- a/src/osg/PrimitiveSet.cpp +++ b/src/osg/PrimitiveSet.cpp @@ -17,6 +17,9 @@ using namespace osg; +#define VOA_NOTICE OSG_INFO +//#define VOA_NOTICE OSG_NOTICE + //////////////////////////////////////////////////////////////////////////////////////////////////////// // // PrimitiveSet @@ -260,12 +263,12 @@ void DrawElementsUShort::draw(State& state, bool useVertexBufferObjects) const if (state.getCurrentVertexArrayState()) { - OSG_NOTICE<<" DrawElementsUShort::draw() size="<(); if (ext->glMultiDrawArrays) diff --git a/src/osg/ShapeDrawable.cpp b/src/osg/ShapeDrawable.cpp index 9ebf4bd83..2e2ce8fea 100644 --- a/src/osg/ShapeDrawable.cpp +++ b/src/osg/ShapeDrawable.cpp @@ -1945,7 +1945,7 @@ void ShapeDrawable::setColor(const Vec4& color) { if (_color!=color) { - _color = color; dirtyDisplayList(); + _color = color; dirtyGLObjects(); } } @@ -1954,7 +1954,7 @@ void ShapeDrawable::setTessellationHints(TessellationHints* hints) if (_tessellationHints!=hints) { _tessellationHints = hints; - dirtyDisplayList(); + dirtyGLObjects(); } } diff --git a/src/osg/State.cpp b/src/osg/State.cpp index f77620873..b625cee99 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -34,6 +34,8 @@ #define GL_MAX_TEXTURE_UNITS 0x84E2 #endif +#define USE_VERTEXARRAYSTATE 1 + using namespace std; using namespace osg; @@ -208,6 +210,8 @@ void State::releaseGLObjects() void State::reset() { + OSG_NOTICE<assignAllDispatchers(); +#endif setGLExtensionFuncPtr(_glClientActiveTexture,"glClientActiveTexture","glClientActiveTextureARB"); setGLExtensionFuncPtr(_glActiveTexture, "glActiveTexture","glActiveTextureARB"); @@ -1055,54 +1062,395 @@ void State::initializeExtensionProcs() } } -bool State::setClientActiveTextureUnit( unsigned int unit ) +#if USE_VERTEXARRAYSTATE +///////////////////////////////////////////////////////////////////////// +// +// New VertexArrayState version +// +void State::setVertexPointer(const Array* array) { - if (unit!=_currentClientActiveTextureUnit) - { - if (_glClientActiveTexture && unit < (unsigned int)_glMaxTextureCoords) - { - _glClientActiveTexture(GL_TEXTURE0+unit); - _currentClientActiveTextureUnit = unit; - } - else - { - return unit==0; - } - } - return true; + _currentVertexArrayState->setVertexArray(*this, array); +} + +void State::disableVertexPointer() +{ + _currentVertexArrayState->disableVertexArray(*this); +} + +void State::dirtyVertexPointer() +{ + OSG_NOTICE<<"NOT IMPLEMENTED YET, dirtyVertexPointer() "<<__LINE__<setNormalArray(*this, array); +} + +void State::disableNormalPointer() +{ + _currentVertexArrayState->disableNormalArray(*this); +} + +void State::dirtyNormalPointer() +{ + OSG_NOTICE<<"NOT IMPLEMENTED YET, dirtyNormalPointer() "<<__LINE__<setColorArray(*this, array); +} + +void State::disableColorPointer() +{ + _currentVertexArrayState->disableColorArray(*this); +} + +void State::dirtyColorPointer() +{ + OSG_NOTICE<<"NOT IMPLEMENTED YET, dirtyColorPointer() "<<__LINE__<setSecondaryColorArray(*this, array); +} + +void State::disableSecondaryColorPointer() +{ + _currentVertexArrayState->disableSecondaryColorArray(*this); +} + +void State::dirtySecondaryColorPointer() +{ + OSG_NOTICE<<"NOT IMPLEMENTED YET, dirtySecondaryColorPointer() "<<__LINE__<setFogCoordArray(*this, array); } void State::setFogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized) { -#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE - if (_useVertexAttributeAliasing) + OSG_NOTICE<<"NOT IMPLEMENTED YET, setFogCoordPointer "<<__LINE__<disableFogCoordArray(*this); +} + +void State::dirtyFogCoordPointer() +{ + OSG_NOTICE<<"NOT IMPLEMENTED YET, dirtyFogCoordPointer() "<<__LINE__<setTexCoordArray(*this, unit, array); +} + +void State::disableTexCoordPointer( unsigned int unit ) +{ + _currentVertexArrayState->disableTexCoordArray(*this, unit); +} + +void State::disableTexCoordPointersAboveAndIncluding( unsigned int unit ) +{ + _currentVertexArrayState->disableTexCoordArrayAboveAndIncluding(*this, unit); +} + +void State::dirtyTexCoordPointersAboveAndIncluding( unsigned int unit ) +{ + OSG_NOTICE<<"NOT IMPLEMENTED YET "<<__LINE__<setVertexAttribArray(*this, unit, array); +} + + +void State::setVertexAttribPointer( unsigned int index, + GLint size, GLenum type, GLboolean normalized, + GLsizei stride, const GLvoid *ptr ) +{ + OSG_NOTICE<<"NOT IMPLEMENTED YET "<<__LINE__<setVertexAttribArray(*this, unit, array); +} + +void State::setVertexAttribIPointer( unsigned int index, + GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ) +{ + OSG_NOTICE<<"NOT IMPLEMENTED YET "<<__LINE__<setVertexAttribArray(*this, unit, array); +} + +void State::setVertexAttribLPointer( unsigned int index, + GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ) +{ + OSG_NOTICE<<"NOT IMPLEMENTED YET "<<__LINE__<disableVertexAttribArray(*this, index); +} + +void State::disableVertexAttribPointersAboveAndIncluding( unsigned int index ) +{ + _currentVertexArrayState->disableVertexAttribArrayAboveAndIncluding(*this, index); +} + +void State::dirtyVertexAttribPointer( unsigned int index ) +{ + OSG_NOTICE<<"NOT IMPLEMENTED YET, dirtyVertexAttribPointer() "<<__LINE__<lazyDisablingOfVertexAttributes();; +} + +void State::applyDisablingOfVertexAttributes() +{ + _currentVertexArrayState->applyDisablingOfVertexAttributes(*this); +} + +void State::setCurrentVertexBufferObject(osg::GLBufferObject* vbo) +{ + _currentVertexArrayState->setCurrentVertexBufferObject(vbo); +} + +const GLBufferObject* State::getCurrentVertexBufferObject() +{ + return _currentVertexArrayState->getCurrentVertexBufferObject(); +} + +void State::bindVertexBufferObject(osg::GLBufferObject* vbo) +{ + _currentVertexArrayState->bindVertexBufferObject(vbo); +} + +void State::unbindVertexBufferObject() +{ + _currentVertexArrayState->unbindVertexBufferObject(); +} + +void State::setCurrentElementBufferObject(osg::GLBufferObject* ebo) +{ + _currentVertexArrayState->setCurrentElementBufferObject(ebo); +} + +const GLBufferObject* State::getCurrentElementBufferObject() +{ + return _currentVertexArrayState->getCurrentElementBufferObject(); +} + +void State::bindElementBufferObject(osg::GLBufferObject* ebo) +{ + _currentVertexArrayState->bindElementBufferObject(ebo); +} + +void State::unbindElementBufferObject() +{ + _currentVertexArrayState->unbindElementBufferObject(); +} + +#else +///////////////////////////////////////////////////////////////////////// +// +// Moved from State header +// +void State::setVertexPointer(const Array* array) +{ + if (array) + { + GLBufferObject* vbo = isVertexBufferObjectSupported() ? array->getOrCreateGLBufferObject(_contextID) : 0; + if (vbo) + { + OSG_NOTICE<<" State::setVertexPointer("<bindBuffer(); + OSG_NOTICE<<" done bind of "<getNumElements()<<")"<getDataSize(), new_array->getDataType(), 0, new_array->getDataPointer()); + } + + virtual void enable_and_dispatch(osg::State&, const osg::Array* new_array, const osg::GLBufferObject* vbo) + { + VAS_NOTICE<<" VertexArrayDispatch::enable_and_dispatch("<getNumElements()<<", vbo="<getDataSize(), new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex()))); + } + + virtual void dispatch(osg::State& state, const osg::Array* new_array) + { + VAS_NOTICE<<" VertexArrayDispatch::dispatch("<getNumElements()<<")"<getDataSize(), new_array->getDataType(), 0, new_array->getDataPointer()); + } + + virtual void dispatch(osg::State& state, const osg::Array* new_array, const osg::GLBufferObject* vbo) + { + VAS_NOTICE<<" VertexArrayDispatch::dispatch("<getNumElements()<<", vbo"<getDataSize(), new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex()))); + } + + virtual void disable(osg::State& state) + { + VAS_NOTICE<<" VertexArrayDispatch::disable()"<getNumElements()<<")"<getDataSize(), new_array->getDataType(), 0, new_array->getDataPointer()); + } + + virtual void enable_and_dispatch(osg::State&, const osg::Array* new_array, const osg::GLBufferObject* vbo) + { + VAS_NOTICE<<" ColorArrayDispatch::enable_and_dispatch("<getNumElements()<<", vbo="<getDataSize(), new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex()))); + } + + virtual void dispatch(osg::State& state, const osg::Array* new_array) + { + VAS_NOTICE<<" ColorArrayDispatch::dispatch("<getNumElements()<<")"<getDataSize(), new_array->getDataType(), 0, new_array->getDataPointer()); + } + + virtual void dispatch(osg::State& state, const osg::Array* new_array, const osg::GLBufferObject* vbo) + { + VAS_NOTICE<<" ColorArrayDispatch::dispatch("<getNumElements()<<", vbo="<getDataSize(), new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex()))); + } + + virtual void disable(osg::State& state) + { + VAS_NOTICE<<" ColorArrayDispatch::disable()"<getNumElements()<<")"<getDataType(), 0, new_array->getDataPointer()); + } + + virtual void enable_and_dispatch(osg::State&, const osg::Array* new_array, const osg::GLBufferObject* vbo) + { + VAS_NOTICE<<" NormalArrayDispatch::enable_and_dispatch("<getNumElements()<<", vbo="<getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex()))); + } + + virtual void dispatch(osg::State& state, const osg::Array* new_array) + { + VAS_NOTICE<<" NormalArrayDispatch::dispatch("<getNumElements()<<")"<getDataType(), 0, new_array->getDataPointer()); + } + + virtual void dispatch(osg::State& state, const osg::Array* new_array, const osg::GLBufferObject* vbo) + { + VAS_NOTICE<<" NormalArrayDispatch::dispatch("<getNumElements()<<", vbo="<getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex()))); + } + + virtual void disable(osg::State& state) + { + VAS_NOTICE<<" NormalArrayDispatch::disable()"<()->glSecondaryColorPointer(new_array->getDataSize(), new_array->getDataType(), 0, new_array->getDataPointer()); + } + + virtual void enable_and_dispatch(osg::State& state, const osg::Array* new_array, const osg::GLBufferObject* vbo) + { + glEnableClientState(GL_SECONDARY_COLOR_ARRAY); + state.get()->glSecondaryColorPointer(new_array->getDataSize(), new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex()))); + } + + virtual void dispatch(osg::State& state, const osg::Array* new_array) + { + state.get()->glSecondaryColorPointer(new_array->getDataSize(), new_array->getDataType(), 0, new_array->getDataPointer()); + } + + virtual void dispatch(osg::State& state, const osg::Array* new_array, const osg::GLBufferObject* vbo) + { + state.get()->glSecondaryColorPointer(new_array->getDataSize(), new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex()))); + } + + virtual void disable(osg::State& state) + { + glDisableClientState(GL_SECONDARY_COLOR_ARRAY); + } +}; + + +/////////////////////////////////////////////////////////////////////////////////// +// +// FogCoordArrayDispatch +// +struct FogCoordArrayDispatch : public VertexArrayState::ArrayDispatch +{ + FogCoordArrayDispatch() {} + + virtual void enable_and_dispatch(osg::State& state, const osg::Array* new_array) + { + glEnableClientState(GL_FOG_COORD_ARRAY); + state.get()->glFogCoordPointer(new_array->getDataType(), 0, new_array->getDataPointer()); + } + + virtual void enable_and_dispatch(osg::State& state, const osg::Array* new_array, const osg::GLBufferObject* vbo) + { + glEnableClientState(GL_FOG_COORD_ARRAY); + state.get()->glFogCoordPointer(new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex()))); + } + + virtual void dispatch(osg::State& state, const osg::Array* new_array) + { + state.get()->glFogCoordPointer(new_array->getDataType(), 0, new_array->getDataPointer()); + } + + virtual void dispatch(osg::State& state, const osg::Array* new_array, const osg::GLBufferObject* vbo) + { + state.get()->glFogCoordPointer(new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex()))); + } + + virtual void disable(osg::State& state) + { + glDisableClientState(GL_FOG_COORD_ARRAY); + } +}; + +/////////////////////////////////////////////////////////////////////////////////// +// +// TexCoordArrayDispatch +// +struct TexCoordArrayDispatch : public VertexArrayState::ArrayDispatch +{ + TexCoordArrayDispatch(unsigned int in_unit) : unit(in_unit) {} + + virtual void enable_and_dispatch(osg::State& state, const osg::Array* new_array) + { + VAS_NOTICE<<" TexCoordArrayDispatch::enable_and_dispatch("<getNumElements()<<") unit="<(GL_TEXTURE0+unit)); + //state.setClientActiveTextureUnit(unit); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(new_array->getDataSize(), new_array->getDataType(), 0, new_array->getDataPointer()); + } + + virtual void enable_and_dispatch(osg::State& state, const osg::Array* new_array, const osg::GLBufferObject* vbo) + { + VAS_NOTICE<<" TexCoordArrayDispatch::enable_and_dispatch("<getNumElements()<<", vbo="<getNumElements()<<") unit="<(GL_TEXTURE0+unit)); + state.setClientActiveTextureUnit(unit); + glTexCoordPointer(new_array->getDataSize(), new_array->getDataType(), 0, new_array->getDataPointer()); + } + + virtual void dispatch(osg::State& state, const osg::Array* new_array, const osg::GLBufferObject* vbo) + { + VAS_NOTICE<<" TexCoordArrayDispatch::dispatch("<getNumElements()<<", vbo="<getNumElements()<<", "<getDataPointer()<getDataSize(), array->getDataType(), 0, array->getDataPointer()); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - OSG_INFO<<"VertexArrayDispatch::dispatchDeprecated() "<getNumElements()<<", "<getDataPointer()<getModifiedCount(); - } -}; - -struct VertexArrayWithVBODispatch : public VertexArrayState::ArrayDispatch -{ - VertexArrayWithVBODispatch(Array* in_array, GLBufferObject* in_vbo) : ArrayDispatch(in_array), vbo(in_vbo) {} - - virtual void dispatch(osg::State& state, unsigned int) - { - OSG_NOTICE<<"VertexArrayWithVBODispatch::dispatch() "<getNumElements()<<", "<getDataPointer()<bindVertexBufferObject(vbo); -#else - - if (vbo->isDirty()) vbo->compileBuffer(); - else vbo->bindBuffer(); -#endif - - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(array->getDataSize(), array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - OSG_NOTICE<<"VertexArrayWithVBODispatch::dispatchDeprecated() "<getNumElements()<<", "<getDataPointer()<getModifiedCount(); - } - - GLBufferObject* vbo; -}; - -struct VertexVec2fDispatch : public VertexArrayState::ArrayDispatch -{ - VertexVec2fDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State&, unsigned int index) - { - // OSG_INFO<<"VertexVec2fDispatch::dispatch()"<(array->getDataPointer(index))); - } -}; - -struct VertexVec3fDispatch : public VertexArrayState::ArrayDispatch -{ - VertexVec3fDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State&, unsigned int index) - { - // OSG_INFO<<"VertexVec3fDispatch::dispatch()"<(array->getDataPointer(index))); - } -}; - -struct VertexVec4fDispatch : public VertexArrayState::ArrayDispatch -{ - VertexVec4fDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State&, unsigned int index) - { - // OSG_INFO<<"VertexVec4fDispatch::dispatch()"<(array->getDataPointer(index))); - } -}; -#endif - -void VertexArrayState::assignVertexArray(osg::Array* array) -{ -#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE - if (!_ext->getUseVertexAttributeAliasing()) - { - if (array->getBinding()==osg::Array::BIND_PER_VERTEX) - { - GLBufferObject* vbo = getGLBufferObject(array); - osg::ref_ptr dispatcher; - if (vbo) dispatcher = new VertexArrayWithVBODispatch(array, vbo); - else dispatcher = new VertexArrayDispatch(array); - _dispatchArrays.push_back(dispatcher.get()); - } - else - { - osg::ref_ptr dispatcher; - switch(array->getType()) - { - case(Array::Vec2ArrayType): dispatcher = new VertexVec2fDispatch(array); break; - case(Array::Vec3ArrayType): dispatcher = new VertexVec3fDispatch(array); break; - case(Array::Vec4ArrayType): dispatcher = new VertexVec4fDispatch(array); break; - default: break; // unsupported type - } - - if (dispatcher) - { - getArrayDispatchList(array->getBinding()).push_back(dispatcher); - } - } - } - else -#endif - { - assignVertexAttribArray(_ext->getVertexAlias()._location, array); - } -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// ColorArrayDispatch -// -#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE -struct ColorArrayDispatch : public VertexArrayState::ArrayDispatch -{ - ColorArrayDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State&, unsigned int) - { - OSG_INFO<<"ColorArrayDispatch::dispatch() "<getNumElements()<<", "<getDataPointer()<getDataSize(), array->getDataType(), 0, array->getDataPointer()); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - OSG_INFO<<"ColorArrayDispatch::dispatchDeprecated() "<getNumElements()<<", "<getDataPointer()<getModifiedCount(); - } -}; - -struct ColorArrayWithVBODispatch : public VertexArrayState::ArrayDispatch -{ - ColorArrayWithVBODispatch(Array* in_array, GLBufferObject* in_vbo) : ArrayDispatch(in_array), vbo(in_vbo) {} - - virtual void dispatch(osg::State& state, unsigned int) - { - // OSG_INFO<<"ColorArrayWithVBODispatch::dispatch()"<bindVertexBufferObject(vbo); -#else - if (vbo->isDirty()) vbo->compileBuffer(); - else vbo->bindBuffer(); -#endif - glEnableClientState(GL_COLOR_ARRAY); - glColorPointer(array->getDataSize(), array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - OSG_INFO<<"ColorArrayDispatchWitVBO::dispatchDeprecated() "<getNumElements()<<", "<getDataPointer()<getModifiedCount(); - } - - GLBufferObject* vbo; -}; - -struct ColorVec3fDispatch : public VertexArrayState::ArrayDispatch -{ - ColorVec3fDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State&, unsigned int index) - { - OSG_INFO<<"ColorVec3fDispatch::dispatch()"<(array->getDataPointer(index))); - } -}; - -struct ColorVec4fDispatch : public VertexArrayState::ArrayDispatch -{ - ColorVec4fDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State&, unsigned int index) - { - OSG_INFO<<"ColorVec4fDispatch::dispatch()"<(array->getDataPointer(index))); - } -}; - -struct ColorVec4ubDispatch : public VertexArrayState::ArrayDispatch -{ - ColorVec4ubDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State&, unsigned int index) - { - // OSG_INFO<<"ColorVec4ubDispatch::dispatch()"<(array->getDataPointer(index))); - } -}; -#endif - -void VertexArrayState::assignColorArray(osg::Array* array) -{ -#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE - if (!_ext->getUseVertexAttributeAliasing()) - { - if (array->getBinding()==osg::Array::BIND_PER_VERTEX) - { - GLBufferObject* vbo = getGLBufferObject(array); - osg::ref_ptr dispatcher; - if (vbo) dispatcher = new ColorArrayWithVBODispatch(array, vbo); - else dispatcher = new ColorArrayDispatch(array); - _dispatchArrays.push_back(dispatcher.get()); - } - else - { - osg::ref_ptr dispatcher; - switch(array->getType()) - { - case(Array::Vec3ArrayType): dispatcher = new ColorVec3fDispatch(array); break; - case(Array::Vec4ArrayType): dispatcher = new ColorVec4fDispatch(array); break; - case(Array::Vec4ubArrayType): dispatcher = new ColorVec4ubDispatch(array); break; - default: break; // unsupported type - } - - if (dispatcher) - { - getArrayDispatchList(array->getBinding()).push_back(dispatcher); - } - } - } - else -#endif - { - assignVertexAttribArray(_ext->getColorAlias()._location, array); - } -} - -/////////////////////////////////////////////////////////////////////////////////// -// -// NormalArrayDispatch -// -#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE -struct NormalArrayDispatch : public VertexArrayState::ArrayDispatch -{ - NormalArrayDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State&, unsigned int) - { - OSG_INFO<<"NormalArrayDispatch::dispatch() "<getNumElements()<<", "<getDataPointer()<getDataType(), 0, array->getDataPointer()); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - OSG_INFO<<"NormalArrayDispatch::dispatchDeprecated() "<getNumElements()<<", "<getDataPointer()<getModifiedCount(); - } -}; - -struct NormalArrayWithVBODispatch : public VertexArrayState::ArrayDispatch -{ - NormalArrayWithVBODispatch(Array* in_array, GLBufferObject* in_vbo) : ArrayDispatch(in_array), vbo(in_vbo) {} - - virtual void dispatch(osg::State& state, unsigned int) - { - OSG_INFO<<"NormalArrayWithVBODispatch::dispatch()"<bindVertexBufferObject(vbo); -#else - if (vbo->isDirty()) vbo->compileBuffer(); - else vbo->bindBuffer(); -#endif - - glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - OSG_INFO<<"NormalArrayDispatchWithVBO::dispatchDeprecated() "<getNumElements()<<", "<getDataPointer()<getModifiedCount(); - } - - GLBufferObject* vbo; -}; - -struct NormalVec3fDispatch : public VertexArrayState::ArrayDispatch -{ - NormalVec3fDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State&, unsigned int index) - { - glNormal3fv(static_cast(array->getDataPointer(index))); - } -}; -#endif - -void VertexArrayState::assignNormalArray(osg::Array* array) -{ -#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE - if (!_ext->getUseVertexAttributeAliasing()) - { - if (array->getBinding()==osg::Array::BIND_PER_VERTEX) - { - GLBufferObject* vbo = getGLBufferObject(array); - osg::ref_ptr dispatcher; - if (vbo) dispatcher = new NormalArrayWithVBODispatch(array, vbo); - else dispatcher = new NormalArrayDispatch(array); - _dispatchArrays.push_back(dispatcher.get()); - } - else - { - osg::ref_ptr dispatcher; - switch(array->getType()) - { - case(Array::Vec3ArrayType): dispatcher = new NormalVec3fDispatch(array); break; - default: break; // unsupported type - } - - if (dispatcher) - { - getArrayDispatchList(array->getBinding()).push_back(dispatcher); - } - } - } - else -#endif - { - assignVertexAttribArray(_ext->getNormalAlias()._location, array); - } -} - -/////////////////////////////////////////////////////////////////////////////////// -// -// SecondaryColorArrayDispatch -// -#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE -struct SecondaryColorArrayDispatch : public VertexArrayState::ArrayDispatch -{ - SecondaryColorArrayDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State& state, unsigned int) - { - OSG_INFO<<"SecondaryColorArrayDispatch::dispatch() "<getNumElements()<<", "<getDataPointer()<()->glSecondaryColorPointer(array->getDataSize(), array->getDataType(), 0, (const GLvoid *)(array->getDataPointer())); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - OSG_INFO<<"SecondaryColorArrayDispatch::dispatchDeprecated() "<getNumElements()<<", "<getDataPointer()<getModifiedCount(); - } -}; - -struct SecondaryColorArrayWithVBODispatch : public VertexArrayState::ArrayDispatch -{ - SecondaryColorArrayWithVBODispatch(Array* in_array, GLBufferObject* in_vbo) : ArrayDispatch(in_array), vbo(in_vbo) {} - - virtual void dispatch(osg::State& state, unsigned int) - { - OSG_INFO<<"SecondaryColorArrayWithVBODispatch::dispatch()"<bindVertexBufferObject(vbo); -#else - if (vbo->isDirty()) vbo->compileBuffer(); - else vbo->bindBuffer(); -#endif - - glEnableClientState(GL_FOG_COORDINATE_ARRAY); - state.get()->glSecondaryColorPointer(array->getDataSize(), array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - OSG_INFO<<"SecondaryColorArrayDispatchWithVBO::dispatchDeprecated() "<getNumElements()<<", "<getDataPointer()<getModifiedCount(); - } - - GLBufferObject* vbo; -}; - -struct SecondaryColor3fDispatch : public VertexArrayState::ArrayDispatch -{ - SecondaryColor3fDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State& state, unsigned int index) - { - state.get()->glSecondaryColor3fv(static_cast(array->getDataPointer(index))); - } -}; -#endif - -void VertexArrayState::assignSecondaryColorArray(osg::Array* array) -{ - if (!_ext->isSecondaryColorSupported) - { - OSG_WARN<<"VertexArrayState::assignSecondaryColorArray() glSeconaryColor* not support by OpenGL driver."<getUseVertexAttributeAliasing()) - { - if (array->getBinding()==osg::Array::BIND_PER_VERTEX) - { - GLBufferObject* vbo = getGLBufferObject(array); - osg::ref_ptr dispatcher; - if (vbo) dispatcher = new SecondaryColorArrayWithVBODispatch(array, vbo); - else dispatcher = new SecondaryColorArrayDispatch(array); - _dispatchArrays.push_back(dispatcher.get()); - } - else - { - osg::ref_ptr dispatcher; - switch(array->getType()) - { - case(Array::Vec3ArrayType): dispatcher = new SecondaryColor3fDispatch(array); break; - default: break; // unsupported type - } - - if (dispatcher) - { - getArrayDispatchList(array->getBinding()).push_back(dispatcher); - } - } - } - else -#endif - { - assignVertexAttribArray(_ext->getSecondaryColorAlias()._location, array); - } -} - -/////////////////////////////////////////////////////////////////////////////////// -// -// FogCoordArrayDispatch -// -#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE -struct FogCoordArrayDispatch : public VertexArrayState::ArrayDispatch -{ - FogCoordArrayDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State& state, unsigned int) - { - OSG_INFO<<"FogCoordArrayDispatch::dispatch() "<getNumElements()<<", "<getDataPointer()<()->glFogCoordPointer(array->getDataType(), 0, (const GLvoid *)(array->getDataPointer())); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - OSG_INFO<<"FogCoordArrayDispatch::dispatchDeprecated() "<getNumElements()<<", "<getDataPointer()<getModifiedCount(); - } -}; - -struct FogCoordArrayWithVBODispatch : public VertexArrayState::ArrayDispatch -{ - FogCoordArrayWithVBODispatch(Array* in_array, GLBufferObject* in_vbo) : ArrayDispatch(in_array), vbo(in_vbo) {} - - virtual void dispatch(osg::State& state, unsigned int) - { - OSG_INFO<<"FogCoordArrayWithVBODispatch::dispatch()"<bindVertexBufferObject(vbo); -#else - if (vbo->isDirty()) vbo->compileBuffer(); - else vbo->bindBuffer(); -#endif - - glEnableClientState(GL_FOG_COORDINATE_ARRAY); - state.get()->glFogCoordPointer(array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - OSG_INFO<<"FogCoordArrayDispatchWithVBO::dispatchDeprecated() "<getNumElements()<<", "<getDataPointer()<getModifiedCount(); - } - - GLBufferObject* vbo; -}; - -struct FogCoordfDispatch : public VertexArrayState::ArrayDispatch -{ - FogCoordfDispatch(Array* in_array) : ArrayDispatch(in_array) {} - - virtual void dispatch(osg::State& state, unsigned int index) - { - state.get()->glFogCoordfv(static_cast(array->getDataPointer(index))); - } -}; -#endif - -void VertexArrayState::assignFogCoordArray(osg::Array* array) -{ - if (!_ext->isFogCoordSupported) - { - OSG_WARN<<"VertexArrayState::assignFogCoordArray() glFogCoord* not support by OpenGL driver."<getUseVertexAttributeAliasing()) - { - if (array->getBinding()==osg::Array::BIND_PER_VERTEX) - { - GLBufferObject* vbo = getGLBufferObject(array); - osg::ref_ptr dispatcher; - if (vbo) dispatcher = new FogCoordArrayWithVBODispatch(array, vbo); - else dispatcher = new FogCoordArrayDispatch(array); - _dispatchArrays.push_back(dispatcher.get()); - } - else - { - osg::ref_ptr dispatcher; - switch(array->getType()) - { - case(Array::FloatArrayType): dispatcher = new FogCoordfDispatch(array); break; - default: break; // unsupported type - } - - if (dispatcher) - { - getArrayDispatchList(array->getBinding()).push_back(dispatcher); - } - } - } - else -#endif - { - assignVertexAttribArray(_ext->getFogCoordAlias()._location, array); - } -} - -/////////////////////////////////////////////////////////////////////////////////// -// -// TexCoordArrayDispatch -// -#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE -struct TexCoordArrayDispatch : public VertexArrayState::ArrayDispatch -{ - TexCoordArrayDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State&, unsigned int) - { - OSG_INFO<<"TexCoordArrayDispatch::dispatch() "<getNumElements()<<", "<getDataPointer()<(GL_TEXTURE0+unit)); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(array->getDataSize(), array->getDataType(), 0, array->getDataPointer()); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - OSG_INFO<<"TexCoordArrayDispatch::dispatchDeprecated() "<getNumElements()<<", "<getDataPointer()<getModifiedCount(); - } - - unsigned int unit; -}; - -struct TexCoordArrayWithVBODispatch : public VertexArrayState::ArrayDispatch -{ - TexCoordArrayWithVBODispatch(unsigned int in_unit, Array* in_array, GLBufferObject* in_vbo) : ArrayDispatch(in_array), unit(in_unit), vbo(in_vbo) {} - - virtual void dispatch(osg::State& state, unsigned int) - { - OSG_INFO<<"TexCoordArrayWithVBODispatch::dispatch()"<bindVertexBufferObject(vbo); -#else - if (vbo->isDirty()) vbo->compileBuffer(); - else vbo->bindBuffer(); -#endif - - glClientActiveTexture(static_cast(GL_TEXTURE0+unit)); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(array->getDataSize(), array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - OSG_INFO<<"TexCoordArrayDispatchWithVBO::dispatchDeprecated() "<getNumElements()<<", "<getDataPointer()<getModifiedCount(); - } - - unsigned int unit; - GLBufferObject* vbo; -}; - -struct TexCoordVec2fDispatch : public VertexArrayState::ArrayDispatch -{ - TexCoordVec2fDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State&, unsigned int index) - { - glMultiTexCoord2fv(static_cast(GL_TEXTURE0+unit), static_cast(array->getDataPointer(index))); - } - - unsigned int unit; -}; - -struct TexCoordVec3fDispatch : public VertexArrayState::ArrayDispatch -{ - TexCoordVec3fDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State&, unsigned int index) - { - glMultiTexCoord3fv(static_cast(GL_TEXTURE0+unit), static_cast(array->getDataPointer(index))); - } - - unsigned int unit; -}; - -struct TexCoordVec4fDispatch : public VertexArrayState::ArrayDispatch -{ - TexCoordVec4fDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State&, unsigned int index) - { - glMultiTexCoord4fv(static_cast(GL_TEXTURE0+unit), static_cast(array->getDataPointer(index))); - } - - unsigned int unit; -}; -#endif - -void VertexArrayState::assignTexCoordArray(unsigned int unit, osg::Array* array) -{ -#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE - if (!_ext->getUseVertexAttributeAliasing()) - { - if (array->getBinding()==osg::Array::BIND_PER_VERTEX) - { - GLBufferObject* vbo = getGLBufferObject(array); - osg::ref_ptr dispatcher; - if (vbo) dispatcher = new TexCoordArrayWithVBODispatch(unit, array, vbo); - else dispatcher = new TexCoordArrayDispatch(unit, array); - _dispatchArrays.push_back(dispatcher.get()); - } - else - { - osg::ref_ptr dispatcher; - switch(array->getType()) - { - case(Array::Vec2ArrayType): dispatcher = new TexCoordVec2fDispatch(unit, array); break; - case(Array::Vec3ArrayType): dispatcher = new TexCoordVec3fDispatch(unit, array); break; - case(Array::Vec4ArrayType): dispatcher = new TexCoordVec4fDispatch(unit, array); break; - default: break; // unsupported type - } - - if (dispatcher) - { - getArrayDispatchList(array->getBinding()).push_back(dispatcher); - } - } - } - else -#endif - { - if (unit<_ext->getTexCoordAliasList().size()) - { - assignVertexAttribArray(_ext->getTexCoordAliasList()[unit]._location, array); - } - // else no slot assigned... - } -} - -/////////////////////////////////////////////////////////////////////////////////// -// -// VertexAttribArrayDispatch -// - -struct VertexAttribArrayDispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribArrayDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State& state, unsigned int) - { - GLExtensions* ext = state.get(); - - ext->glEnableVertexAttribArray( unit ); - ext->glVertexAttribPointer(static_cast(unit), array->getDataSize(), array->getDataType(), array->getNormalize(), 0, array->getDataPointer()); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - state.setVertexAttribPointer(unit, array); - - modifiedCount = array->getModifiedCount(); - } - - unsigned int unit; -}; - -struct VertexAttribArrayWithVBODispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribArrayWithVBODispatch(unsigned int in_unit, Array* in_array, GLBufferObject* in_vbo) : ArrayDispatch(in_array), unit(in_unit), vbo(in_vbo) {} - - virtual void dispatch(osg::State& state, unsigned int) - { -#if 1 - state.getCurrentVertexArrayState()->bindVertexBufferObject(vbo); -#else - if (vbo->isDirty()) vbo->compileBuffer(); - else vbo->bindBuffer(); -#endif - - GLExtensions* ext = state.get(); - ext->glEnableVertexAttribArray( unit ); - ext->glVertexAttribPointer(static_cast(unit), array->getDataSize(), array->getDataType(), array->getNormalize(), 0, (const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - state.setVertexAttribPointer(unit, array); - - modifiedCount = array->getModifiedCount(); - } - - unsigned int unit; - GLBufferObject* vbo; -}; - -struct VertexAttribLArrayDispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribLArrayDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State& state, unsigned int) - { - GLExtensions* ext = state.get(); - - ext->glEnableVertexAttribArray( unit ); - ext->glVertexAttribLPointer(static_cast(unit), array->getDataSize(), array->getDataType(), 0, array->getDataPointer()); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - state.setVertexAttribLPointer(unit, array); - - modifiedCount = array->getModifiedCount(); - } - - unsigned int unit; -}; - -struct VertexAttribLArrayWithVBODispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribLArrayWithVBODispatch(unsigned int in_unit, Array* in_array, GLBufferObject* in_vbo) : ArrayDispatch(in_array), unit(in_unit), vbo(in_vbo) {} - - virtual void dispatch(osg::State& state, unsigned int) - { -#if 1 - state.getCurrentVertexArrayState()->bindVertexBufferObject(vbo); -#else - if (vbo->isDirty()) vbo->compileBuffer(); - else vbo->bindBuffer(); -#endif - - GLExtensions* ext = state.get(); - ext->glEnableVertexAttribArray( unit ); - ext->glVertexAttribLPointer(static_cast(unit), array->getDataSize(), array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - state.setVertexAttribLPointer(unit, array); - - modifiedCount = array->getModifiedCount(); - } - - unsigned int unit; - GLBufferObject* vbo; -}; - -struct VertexAttribIArrayDispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribIArrayDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State& state, unsigned int) - { - GLExtensions* ext = state.get(); - - ext->glEnableVertexAttribArray( unit ); - ext->glVertexAttribIPointer(static_cast(unit), array->getDataSize(), array->getDataType(), 0, array->getDataPointer()); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - state.setVertexAttribIPointer(unit, array); - - modifiedCount = array->getModifiedCount(); - } - - unsigned int unit; -}; - -struct VertexAttribIArrayWithVBODispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribIArrayWithVBODispatch(unsigned int in_unit, Array* in_array, GLBufferObject* in_vbo) : ArrayDispatch(in_array), unit(in_unit), vbo(in_vbo) {} - - virtual void dispatch(osg::State& state, unsigned int) - { -#if 1 - state.getCurrentVertexArrayState()->bindVertexBufferObject(vbo); -#else - if (vbo->isDirty()) vbo->compileBuffer(); - else vbo->bindBuffer(); -#endif - - GLExtensions* ext = state.get(); - ext->glEnableVertexAttribArray( unit ); - ext->glVertexAttribIPointer(static_cast(unit), array->getDataSize(), array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); - - modifiedCount = array->getModifiedCount(); - } - - virtual void dispatchDeprecated(osg::State& state, unsigned int) - { - state.setVertexAttribIPointer(unit, array); - - modifiedCount = array->getModifiedCount(); - } - - unsigned int unit; - GLBufferObject* vbo; -}; - -struct VertexAttribFloatDispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribFloatDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State& state, unsigned int index) - { - state.get()->glVertexAttrib1fv(static_cast(unit), static_cast(array->getDataPointer(index))); - } - - unsigned int unit; -}; - -struct VertexAttribVec2fDispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribVec2fDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State& state, unsigned int index) - { - state.get()->glVertexAttrib2fv(static_cast(unit), static_cast(array->getDataPointer(index))); - } - - unsigned int unit; -}; - -struct VertexAttribVec3fDispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribVec3fDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State& state, unsigned int index) - { - state.get()->glVertexAttrib3fv(static_cast(unit), static_cast(array->getDataPointer(index))); - } - - unsigned int unit; -}; - -struct VertexAttribVec4fDispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribVec4fDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State& state, unsigned int index) - { - state.get()->glVertexAttrib4fv(static_cast(unit), static_cast(array->getDataPointer(index))); - } - - unsigned int unit; -}; - - -struct VertexAttribDoubleDispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribDoubleDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State& state, unsigned int index) - { - state.get()->glVertexAttrib1dv(static_cast(unit), static_cast(array->getDataPointer(index))); - } - - unsigned int unit; -}; - -struct VertexAttribVec2dDispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribVec2dDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State& state, unsigned int index) - { - state.get()->glVertexAttrib2dv(static_cast(unit), static_cast(array->getDataPointer(index))); - } - - unsigned int unit; -}; - -struct VertexAttribVec3dDispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribVec3dDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State& state, unsigned int index) - { - state.get()->glVertexAttrib3dv(static_cast(unit), static_cast(array->getDataPointer(index))); - } - - unsigned int unit; -}; - -struct VertexAttribVec4dDispatch : public VertexArrayState::ArrayDispatch -{ - VertexAttribVec4dDispatch(unsigned int in_unit, Array* in_array) : ArrayDispatch(in_array), unit(in_unit) {} - - virtual void dispatch(osg::State& state, unsigned int index) - { - state.get()->glVertexAttrib4dv(static_cast(unit), static_cast(array->getDataPointer(index))); - } - - unsigned int unit; -}; - - -void VertexArrayState::assignVertexAttribArray(unsigned int unit, osg::Array* array) -{ - if (array->getBinding()==osg::Array::BIND_PER_VERTEX) - { - GLBufferObject* vbo = getGLBufferObject(array); - osg::ref_ptr dispatcher; - if (array->getDataType()==GL_FLOAT) - { - if (vbo) dispatcher = new VertexAttribArrayWithVBODispatch(unit, array, vbo); - else dispatcher = new VertexAttribArrayDispatch(unit, array); - } - else if (array->getDataType()==GL_DOUBLE) - { - if (vbo) dispatcher = new VertexAttribLArrayWithVBODispatch(unit, array, vbo); - else dispatcher = new VertexAttribLArrayDispatch(unit, array); - } - else - { - if (vbo) dispatcher = new VertexAttribIArrayWithVBODispatch(unit, array, vbo); - else dispatcher = new VertexAttribIArrayDispatch(unit, array); - } - - _dispatchArrays.push_back(dispatcher.get()); - } - else - { - osg::ref_ptr dispatcher; - switch(array->getType()) - { - case(Array::FloatArrayType): dispatcher = new VertexAttribFloatDispatch(unit, array); break; - case(Array::Vec2ArrayType): dispatcher = new VertexAttribVec2fDispatch(unit, array); break; - case(Array::Vec3ArrayType): dispatcher = new VertexAttribVec3fDispatch(unit, array); break; - case(Array::Vec4ArrayType): dispatcher = new VertexAttribVec4fDispatch(unit, array); break; - case(Array::DoubleArrayType): dispatcher = new VertexAttribFloatDispatch(unit, array); break; - case(Array::Vec2dArrayType): dispatcher = new VertexAttribVec2dDispatch(unit, array); break; - case(Array::Vec3dArrayType): dispatcher = new VertexAttribVec3dDispatch(unit, array); break; - case(Array::Vec4dArrayType): dispatcher = new VertexAttribVec4dDispatch(unit, array); break; - default: break; // unsupported type - } - - if (dispatcher) - { - getArrayDispatchList(array->getBinding()).push_back(dispatcher); - } - } -} - void VertexArrayState::generateVretexArrayObject() { _ext->glGenVertexArrays(1, &_vertexArrayObject); @@ -1115,6 +364,8 @@ void VertexArrayState::generateVretexArrayObject() void VertexArrayState::bindVertexArrayObject() const { + VAS_NOTICE<<"glBindVertexArray() _vertexArrayObject="<<_vertexArrayObject<glBindVertexArray (_vertexArrayObject); } @@ -1130,3 +381,241 @@ void VertexArrayState::releaseGLObjects() _ext->glDeleteVertexArrays(1, &_vertexArrayObject); } } + + +void VertexArrayState::assignVertexArrayDispatcher() +{ +#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE + if (!_ext->getUseVertexAttributeAliasing()) + { + _vertexArray = new VertexArrayDispatch(); + } + else +#endif + { + _vertexArray = new VertexAttribArrayDispatch(_ext->getVertexAlias()._location); + } +} + +void VertexArrayState::assignNormalArrayDispatcher() +{ +#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE + if (!_ext->getUseVertexAttributeAliasing()) + { + _normalArray = new NormalArrayDispatch(); + } + else +#endif + { + _normalArray = new VertexAttribArrayDispatch(_ext->getNormalAlias()._location); + } +} + +void VertexArrayState::assignColorArrayDispatcher() +{ +#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE + if (!_ext->getUseVertexAttributeAliasing()) + { + _colorArray = new ColorArrayDispatch(); + } + else +#endif + { + _colorArray = new VertexAttribArrayDispatch(_ext->getColorAlias()._location); + } +} + +void VertexArrayState::assignSecondaryColorArrayDispatcher() +{ +#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE + if (!_ext->getUseVertexAttributeAliasing()) + { + _secondaryColorArray = new SecondaryColorArrayDispatch(); + } + else +#endif + { + _secondaryColorArray = new VertexAttribArrayDispatch(_ext->getSecondaryColorAlias()._location); + } +} + +void VertexArrayState::assignFogCoordArrayDispatcher() +{ +#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE + if (!_ext->getUseVertexAttributeAliasing()) + { + _fogCoordArray = new FogCoordArrayDispatch(); + } + else +#endif + { + _fogCoordArray = new VertexAttribArrayDispatch(_ext->getFogCoordAlias()._location); + } +} + +void VertexArrayState::assignTexCoordArrayDispatcher(unsigned int numUnits) +{ +#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE + if (!_ext->getUseVertexAttributeAliasing()) + { + _texCoordArrays.clear(); + for(unsigned int i=0; igetTexCoordAliasList()[i]._location) ); + } + } +} + +void VertexArrayState::assignVertexAttribArrayDispatcher(unsigned int numUnits) +{ + _vertexAttribArrays.clear(); + for(unsigned int i=0; i::lazyDisablingOfVertexAttributes() _activeDispatchers.size()="<<_activeDispatchers.size()<<", _previous_activeDispatchers.size()="<<_previous_activeDispatchers.size()<array = 0; + ad->active = false; + } +} + +void VertexArrayState::applyDisablingOfVertexAttributes(osg::State& state) +{ + VAS_NOTICE<<" VertexArrayState<"<::applyDisablingOfVertexAttributes() _activeDispatchers.size()="<<_activeDispatchers.size()<<", _previous_activeDispatchers.size()="<<_previous_activeDispatchers.size()<active) + { + ad->disable(state); + ad->array = 0; + ad->modifiedCount = 0xffffffff; + } + } + _previous_activeDispatchers.clear(); +} + +void VertexArrayState::setArray(ArrayDispatch* vad, osg::State& state, const osg::Array* new_array) +{ + if (new_array) + { + VAS_NOTICE<<" VertexArrayState<"<::setArray() "<array = new_array; + vad->modifiedCount = new_array->getModifiedCount(); + + } + else if (vad->array) + { + VAS_NOTICE<<" VertexArrayState::setArray() need to disable "<dirtyDisplayList(); + if (drawable) drawable->dirtyGLObjects(); } } @@ -907,7 +907,7 @@ struct ActivateTransparencyOnType ss->setAttributeAndModes(new osg::CullFace(osg::CullFace::BACK),osg::StateAttribute::ON); ss->setMode(GL_BLEND,osg::StateAttribute::ON); - drawable->dirtyDisplayList(); + drawable->dirtyGLObjects(); } } @@ -931,7 +931,7 @@ struct DeactivateTransparencyOnType osg::StateSet* ss = drawable->getOrCreateStateSet(); if(ss) ss->setRenderingHint(osg::StateSet::OPAQUE_BIN); - drawable->dirtyDisplayList(); + drawable->dirtyGLObjects(); } }