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
This commit is contained in:
Robert Osfield 2016-11-03 17:11:58 +00:00
parent 8ee319bbd5
commit 6d531fd643
2 changed files with 27 additions and 5 deletions

View File

@ -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<VertexAttribAlias> VertexAttribAliasList;

View File

@ -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()<<std::endl;
while (!_stateStateStack.empty()) popStateSet();
if (_rootStateSet.valid())
{
while (_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(..) "<<shaderDefineStr<<std::endl;
}