Commit 4d99caf9 authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[FIX #215] introduced maximum allowed number of textures to whitelisted

modules using textures
parent b1fb4643
......@@ -401,7 +401,7 @@ void WMMarchingCubes::renderMesh( boost::shared_ptr< WTriangleMesh2 > mesh )
m_cmapUniforms.push_back( osg::ref_ptr<osg::Uniform>( new osg::Uniform( "useCmap8", 0 ) ) );
m_cmapUniforms.push_back( osg::ref_ptr<osg::Uniform>( new osg::Uniform( "useCmap9", 0 ) ) );
for ( int i = 0; i < 10; ++i )
for ( int i = 0; i < m_maxNumberOfTextures; ++i )
{
state->addUniform( m_typeUniforms[i] );
state->addUniform( m_thresholdUniforms[i] );
......@@ -565,7 +565,7 @@ void WMMarchingCubes::updateGraphics()
osg::StateSet* rootState = m_surfaceGeode->getOrCreateStateSet();
// reset all uniforms
for ( int i = 0; i < 10; ++i )
for ( int i = 0; i < m_maxNumberOfTextures; ++i )
{
m_typeUniforms[i]->set( 0 );
}
......@@ -600,6 +600,10 @@ void WMMarchingCubes::updateGraphics()
m_cmapUniforms[c]->set( cmap );
++c;
if( c == m_maxNumberOfTextures )
{
break;
}
}
}
}
......
......@@ -197,6 +197,8 @@ private:
std::vector< osg::ref_ptr< osg::Uniform > > m_thresholdUniforms; //!< uniforms for thresholds of textures in shader
std::vector< osg::ref_ptr< osg::Uniform > > m_samplerUniforms; //!< uniforms for ids of textures in shader
std::vector< osg::ref_ptr<osg::Uniform> > m_cmapUniforms; //!< uniforms for color maps per texture in shader
static const int m_maxNumberOfTextures = 10; //!< We support only 10 textures because hardware has may have unknown limits.
};
/**
......
......@@ -793,7 +793,7 @@ void WMNavSlices::updateTextures()
if ( tex.size() > 0 )
{
// reset all uniforms
for ( int i = 0; i < 10; ++i )
for ( int i = 0; i < m_maxNumberOfTextures; ++i )
{
m_typeUniforms[i]->set( 0 );
}
......@@ -827,12 +827,11 @@ void WMNavSlices::updateTextures()
m_cmapUniforms[c]->set( cmap );
++c;
if( c == m_maxNumberOfTextures )
{
break;
}
}
// TODO(schurade): used? Not used? Replace by new Property please
// rootState->addUniform( osg::ref_ptr<osg::Uniform>(
// new osg::Uniform( "useTexture", m_properties->getValue< bool >( "Use Texture" ) ) )
// );
}
}
......@@ -905,7 +904,7 @@ void WMNavSlices::initUniforms( osg::StateSet* rootState )
m_cmapUniforms.push_back( osg::ref_ptr<osg::Uniform>( new osg::Uniform( "useCmap8", 0 ) ) );
m_cmapUniforms.push_back( osg::ref_ptr<osg::Uniform>( new osg::Uniform( "useCmap9", 0 ) ) );
for ( int i = 0; i < 10; ++i )
for ( int i = 0; i < m_maxNumberOfTextures; ++i )
{
rootState->addUniform( m_typeUniforms[i] );
rootState->addUniform( m_thresholdUniforms[i] );
......
......@@ -320,6 +320,8 @@ private:
*/
static bool m_navsliceRunning;
static const int m_maxNumberOfTextures = 10; //!< We support only 10 textures because hardware has may have unknown limits.
/**
* Node callback to handle updates properly
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment