From 6d531fd64366b7bd240bfe1eb5f31c56d9b5621c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 3 Nov 2016 17:11:58 +0000 Subject: [PATCH] Moved the implementation of the State::setUseModelViewAndProjectionUniforms(bool) and State::setUseVertexAttributeAliasing(bool) into State.cpp and added initialization of the VertexArrayState array bindings to ensure that bindings get updated correctly. Refined the State::popStateSet() method to make it more efficient --- include/osg/State | 4 ++-- src/osg/State.cpp | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/include/osg/State b/include/osg/State index 097a5a4d6..47e6be583 100644 --- a/include/osg/State +++ b/include/osg/State @@ -236,7 +236,7 @@ class OSG_EXPORT State : public Referenced const osg::Matrix& getModelViewMatrix() const { return *_modelView; } - void setUseModelViewAndProjectionUniforms(bool flag) { _useModelViewAndProjectionUniforms = flag; } + void setUseModelViewAndProjectionUniforms(bool flag); bool getUseModelViewAndProjectionUniforms() const { return _useModelViewAndProjectionUniforms; } void updateModelViewAndProjectionMatrixUniforms(); @@ -252,7 +252,7 @@ class OSG_EXPORT State : public Referenced Polytope getViewFrustum() const; - void setUseVertexAttributeAliasing(bool flag) { _useVertexAttributeAliasing = flag; } + void setUseVertexAttributeAliasing(bool flag); bool getUseVertexAttributeAliasing() const { return _useVertexAttributeAliasing ; } typedef std::vector VertexAttribAliasList; diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 95fb0b45f..9ec306123 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -170,6 +170,17 @@ State::~State() //_vertexAttribArrayList.clear(); } +void State::setUseModelViewAndProjectionUniforms(bool flag) +{ + _useModelViewAndProjectionUniforms = flag; +} + +void State::setUseVertexAttributeAliasing(bool flag) +{ + _useVertexAttributeAliasing = flag; + if (_globalVertexArrayState.valid()) _globalVertexArrayState->assignAllDispatchers(); +} + void State::initializeExtensionProcs() { if (_extensionProcsInitialized) return; @@ -572,14 +583,19 @@ void State::popAllStateSets() { // OSG_NOTICE<<"State::popAllStateSets()"<<_stateStateStack.size()<2) popStateSet(); + } + else + { + while (!_stateStateStack.empty()) popStateSet(); + } applyProjectionMatrix(0); applyModelViewMatrix(0); _lastAppliedProgramObject = 0; - - if (_rootStateSet.valid()) pushStateSet(_rootStateSet.get()); } void State::popStateSet() @@ -1840,6 +1856,12 @@ void State::getDefineString(std::string& shaderDefineStr, const osg::ShaderPragm } + + if (getUseVertexAttributeAliasing() || getUseModelViewAndProjectionUniforms()) + { + convertVertexShaderSourceToOsgBuiltIns(shaderDefineStr); + } + // OSG_NOTICE<<"State::getDefineString(..) "<