Commit 95a82946 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - preprocessor #define statements now work properly.

parent 01a99953
......@@ -185,8 +185,7 @@ std::string WShader::processShader( const std::string filename, bool optional, i
// for the shader (not the included one, for which level != 0)
// apply defines
std::map< std::string, float >::const_iterator mi = m_defines.begin();
while ( mi != m_defines.end() )
for ( std::map< std::string, float >::const_iterator mi = m_defines.begin(); mi != m_defines.end(); ++mi )
{
output << "#define " << mi->first << " " << boost::lexical_cast< std::string, float >( mi->second ) << std::endl;
}
......@@ -263,11 +262,19 @@ void WShader::setDefine( std::string key, float value )
if ( key.length() > 0 )
{
m_defines[key] = value;
m_reload = true;
}
}
void WShader::eraseDefine( std::string key )
{
m_defines.erase( key );
m_reload = true;
}
void WShader::eraseAllDefines()
{
m_defines.clear();
m_reload = true;
}
......@@ -74,13 +74,13 @@ public:
virtual void reload();
/**
* Sets a define which is include into the shader source code.
* Not yet fully operational
* Sets a define which is include into the shader source code. This allows the preprocessor to turn on/off several parts of your code. In GLSL
* defines are a better choice when compared with a lot of branches (if-statements).
*
* \param key The name of the define
* \param value The value of the define.
* \param value The value of the define. If this is not specified, the define can be used as simple #ifdef switch.
*/
void setDefine( std::string key, float value );
void setDefine( std::string key, float value = 1.0 );
/**
* Deletes a define from the internal list
......@@ -89,6 +89,11 @@ public:
*/
void eraseDefine( std::string key );
/**
* Removes all existing defines.
*/
void eraseAllDefines();
protected:
/**
......
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