diff --git a/include/osg/GLExtensions b/include/osg/GLExtensions index 258836026..faaf790da 100644 --- a/include/osg/GLExtensions +++ b/include/osg/GLExtensions @@ -698,58 +698,6 @@ class OSG_EXPORT GLExtensions : public osg::Referenced GLint glMaxTextureCoords; GLint glMaxTextureUnits; -public: - - - void setUseVertexAttributeAliasing(bool flag) { _useVertexAttributeAliasing = flag; } - bool getUseVertexAttributeAliasing() const { return _useVertexAttributeAliasing ; } - - typedef std::vector VertexAttribAliasList; - typedef std::map AttribBindingList; - - void setUpVertexAttribAlias(VertexAttribAlias& alias, GLuint location, const std::string glName, const std::string osgName, const std::string& declaration); - - /** Reset the vertex attribute aliasing to osg's default. This method needs to be called before render anything unless you really know what you're doing !*/ - void resetVertexAttributeAlias(bool compactAliasing=true, unsigned int numTextureUnits=8); - - /** Set the vertex attribute aliasing for "vertex". This method needs to be called before render anything unless you really know what you're doing !*/ - void setVertexAlias(const VertexAttribAlias& alias) { _vertexAlias = alias; } - const VertexAttribAlias& getVertexAlias() { return _vertexAlias; } - - /** Set the vertex attribute aliasing for "normal". This method needs to be called before render anything unless you really know what you're doing !*/ - void setNormalAlias(const VertexAttribAlias& alias) { _normalAlias = alias; } - const VertexAttribAlias& getNormalAlias() { return _normalAlias; } - - /** Set the vertex attribute aliasing for "color". This method needs to be called before render anything unless you really know what you're doing !*/ - void setColorAlias(const VertexAttribAlias& alias) { _colorAlias = alias; } - const VertexAttribAlias& getColorAlias() { return _colorAlias; } - - /** Set the vertex attribute aliasing for "secondary color". This method needs to be called before render anything unless you really know what you're doing !*/ - void setSecondaryColorAlias(const VertexAttribAlias& alias) { _secondaryColorAlias = alias; } - const VertexAttribAlias& getSecondaryColorAlias() { return _secondaryColorAlias; } - - /** Set the vertex attribute aliasing for "fog coord". This method needs to be called before render anything unless you really know what you're doing !*/ - void setFogCoordAlias(const VertexAttribAlias& alias) { _fogCoordAlias = alias; } - const VertexAttribAlias& getFogCoordAlias() { return _fogCoordAlias; } - - /** Set the vertex attribute aliasing list for texture coordinates. This method needs to be called before render anything unless you really know what you're doing !*/ - void setTexCoordAliasList(const VertexAttribAliasList& aliasList) { _texCoordAliasList = aliasList; } - const VertexAttribAliasList& getTexCoordAliasList() { return _texCoordAliasList; } - - /** Set the vertex attribute binding list. This method needs to be called before render anything unless you really know what you're doing !*/ - void setAttributeBindingList(const AttribBindingList& attribBindingList) { _attributeBindingList = attribBindingList; } - const AttribBindingList& getAttributeBindingList() { return _attributeBindingList; } - - - bool _useVertexAttributeAliasing; - VertexAttribAlias _vertexAlias; - VertexAttribAlias _normalAlias; - VertexAttribAlias _colorAlias; - VertexAttribAlias _secondaryColorAlias; - VertexAttribAlias _fogCoordAlias; - VertexAttribAliasList _texCoordAliasList; - - AttribBindingList _attributeBindingList; }; diff --git a/include/osg/VertexArrayState b/include/osg/VertexArrayState index e77574ad3..73caaffff 100644 --- a/include/osg/VertexArrayState +++ b/include/osg/VertexArrayState @@ -25,7 +25,7 @@ class VertexArrayState : public osg::Referenced { public: - VertexArrayState(osg::GLExtensions* ext); + VertexArrayState(osg::State* state); struct ArrayDispatch : public osg::Referenced { @@ -157,6 +157,7 @@ public: // osg::GLBufferObject* getGLBufferObject(osg::Array* array); + osg::State* _state; osg::ref_ptr _ext; GLuint _vertexArrayObject; diff --git a/src/osg/Drawable.cpp b/src/osg/Drawable.cpp index b2ab85250..9b2565b7c 100644 --- a/src/osg/Drawable.cpp +++ b/src/osg/Drawable.cpp @@ -626,6 +626,5 @@ void Drawable::compileGLObjects(RenderInfo& renderInfo) const VertexArrayState* Drawable::createVertexArrayState(RenderInfo& renderInfo, bool usingVBOs) const { - osg::State* state = renderInfo.getState(); - return new osg::VertexArrayState(state->get()); + return new osg::VertexArrayState(renderInfo.getState()); } diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index 51b67fac4..d1652f606 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -1180,14 +1180,6 @@ GLExtensions::GLExtensions(unsigned int in_contextID): glMaxTextureUnits = 0; glMaxTextureCoords = 0; } - - #if !defined(OSG_GL_FIXED_FUNCTION_AVAILABLE) - _useVertexAttributeAliasing = true; - #else - _useVertexAttributeAliasing = false; - #endif - - } @@ -1295,63 +1287,3 @@ bool GLExtensions::getFragDataLocation( const char* fragDataName, GLuint& locati location = loc; return true; } - -////////////////////////////////////////////////////////////////////////////////////////////////// -// -// Vertex Attrib Aliasing -// -void GLExtensions::setUpVertexAttribAlias(VertexAttribAlias& alias, GLuint location, const std::string glName, const std::string osgName, const std::string& declaration) -{ - alias = VertexAttribAlias(location, glName, osgName, declaration); - _attributeBindingList[osgName] = location; - // OSG_NOTICE<<"State::setUpVertexAttribAlias("<()); + _vertexArrayStateList[state.getContextID()] = vas = new osg::VertexArrayState(&state); if (_vertexArray.valid()) vas->assignVertexArrayDispatcher(); if (_colorArray.valid()) vas->assignColorArrayDispatcher(); diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 970d52ac6..18afa2c3a 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -178,7 +178,6 @@ void State::initializeExtensionProcs() _glExtensions = new GLExtensions(_contextID); GLExtensions::Set(_contextID, _glExtensions.get()); - computeSecondaryColorSupported(); computeFogCoordSupported(); computeVertexBufferObjectSupported(); @@ -190,7 +189,7 @@ void State::initializeExtensionProcs() #ifdef USE_VERTEXARRAYSTATE - _globalVertexArrayState = new VertexArrayState(_glExtensions.get()); + _globalVertexArrayState = new VertexArrayState(this); _globalVertexArrayState->assignAllDispatchers(); setCurrentToGloabalVertexArrayState(); #endif diff --git a/src/osg/VertexArrayState.cpp b/src/osg/VertexArrayState.cpp index 8b7f73d1d..4298d339e 100644 --- a/src/osg/VertexArrayState.cpp +++ b/src/osg/VertexArrayState.cpp @@ -17,9 +17,11 @@ using namespace osg; +#if 1 #define VAS_NOTICE OSG_INFO -//#define VAS_NOTICE OSG_NOTICE - +#else +#define VAS_NOTICE OSG_NOTICE +#endif class VertexArrayStateManager : public GraphicsObjectManager { @@ -425,13 +427,14 @@ struct VertexAttribArrayDispatch : public VertexArrayState::ArrayDispatch // // VertexArrayState // -VertexArrayState::VertexArrayState(osg::GLExtensions* ext): - _ext(ext), +VertexArrayState::VertexArrayState(osg::State* state): + _state(state), _vertexArrayObject(0), _currentVBO(0), _currentEBO(0), _requiresSetArrays(true) { + _ext = _state->get(); } void VertexArrayState::generateVretexArrayObject() @@ -452,78 +455,83 @@ void VertexArrayState::deleteVertexArrayObject() void VertexArrayState::assignVertexArrayDispatcher() { + OSG_NOTICE<<"VertexArrayState::assignVertexArrayDispatcher() _state->getUseVertexAttributeAliasing()="<<_state->getUseVertexAttributeAliasing()<getUseVertexAttributeAliasing()) + if (!_state->getUseVertexAttributeAliasing()) { _vertexArray = new VertexArrayDispatch(); } else #endif { - _vertexArray = new VertexAttribArrayDispatch(_ext->getVertexAlias()._location); + VAS_NOTICE<<"VertexArrayState::assignNormalArrayDispatcher() _state->getVertexAlias()._location="<<_state->getVertexAlias()._location<getVertexAlias()._location); } } void VertexArrayState::assignNormalArrayDispatcher() { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE - if (!_ext->getUseVertexAttributeAliasing()) + if (!_state->getUseVertexAttributeAliasing()) { _normalArray = new NormalArrayDispatch(); } else #endif { - _normalArray = new VertexAttribArrayDispatch(_ext->getNormalAlias()._location); + VAS_NOTICE<<"VertexArrayState::assignNormalArrayDispatcher() _state->getNormalAlias()._location="<<_state->getNormalAlias()._location<getNormalAlias()._location); } } void VertexArrayState::assignColorArrayDispatcher() { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE - if (!_ext->getUseVertexAttributeAliasing()) + if (!_state->getUseVertexAttributeAliasing()) { _colorArray = new ColorArrayDispatch(); } else #endif { - _colorArray = new VertexAttribArrayDispatch(_ext->getColorAlias()._location); + VAS_NOTICE<<"VertexArrayState::assignColorArrayDispatcher() _state->getColorAlias()._location="<<_state->getColorAlias()._location<getColorAlias()._location); } } void VertexArrayState::assignSecondaryColorArrayDispatcher() { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE - if (!_ext->getUseVertexAttributeAliasing()) + if (!_state->getUseVertexAttributeAliasing()) { _secondaryColorArray = new SecondaryColorArrayDispatch(); } else #endif { - _secondaryColorArray = new VertexAttribArrayDispatch(_ext->getSecondaryColorAlias()._location); + _secondaryColorArray = new VertexAttribArrayDispatch(_state->getSecondaryColorAlias()._location); } } void VertexArrayState::assignFogCoordArrayDispatcher() { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE - if (!_ext->getUseVertexAttributeAliasing()) + if (!_state->getUseVertexAttributeAliasing()) { _fogCoordArray = new FogCoordArrayDispatch(); } else #endif { - _fogCoordArray = new VertexAttribArrayDispatch(_ext->getFogCoordAlias()._location); + _fogCoordArray = new VertexAttribArrayDispatch(_state->getFogCoordAlias()._location); } } void VertexArrayState::assignTexCoordArrayDispatcher(unsigned int numUnits) { #ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE - if (!_ext->getUseVertexAttributeAliasing()) + if (!_state->getUseVertexAttributeAliasing()) { _texCoordArrays.clear(); for(unsigned int i=0; igetTexCoordAliasList()[i]._location) ); + VAS_NOTICE<<"VertexArrayState::VertexArrayState::assignTexCoordArrayDispatcher() _state->getTexCoordAliasList()[i]._location="<<_state->getTexCoordAliasList()[i]._location<getTexCoordAliasList()[i]._location) ); } } }