Added basic ShaderComponent class and beginnings osgshadercomposition example

This commit is contained in:
Robert Osfield
2010-07-02 12:04:20 +00:00
parent aef5e36cf1
commit a55c4b7d70
12 changed files with 163 additions and 32 deletions

View File

@@ -42,7 +42,10 @@ State::State():
_graphicsContext = 0;
_contextID = 0;
_shaderCompositionEnabled = true;
_shaderCompositionDirty = true;
_shaderComposer = new ShaderComposer;
_currentShaderCompositionProgram = 0L;
_identity = new osg::RefMatrix(); // default RefMatrix constructs to identity.
_initialViewMatrix = _identity;
@@ -512,6 +515,21 @@ void State::apply(const StateSet* dstate)
else if (unit<_textureAttributeMapList.size()) applyAttributeMapOnTexUnit(unit,_textureAttributeMapList[unit]);
}
if (_shaderCompositionEnabled)
{
if (_shaderCompositionDirty)
{
// built lits of current ShaderComponents
_currentShaderCompositionProgram = _shaderComposer->getOrCreateProgram();
}
if (_currentShaderCompositionProgram)
{
Program::PerContextProgram* pcp = _currentShaderCompositionProgram->getPCP(_contextID);
if (_lastAppliedProgramObject != pcp) applyAttribute(_currentShaderCompositionProgram);
}
}
applyUniformList(_uniformMap,dstate->getUniformList());
}
else