29 #include <boost/regex.hpp>
31 #include "../../common/WLogger.h"
33 #include "WGEShaderVersionPreprocessor.h"
57 static const boost::regex versionRegexp(
"^[ ]*#[ ]*version[ ]+([123456789][0123456789][0123456789]).*$" );
61 boost::smatch matches;
62 bool foundVersion =
false;
63 unsigned int version = 120;
64 std::stringstream completeCode( code );
65 std::ostringstream cleanedCode;
66 while( std::getline( completeCode, line ) )
68 if( boost::regex_match( line, matches, versionRegexp ) )
70 unsigned int versionNum = boost::lexical_cast<
unsigned int >( matches[1] );
71 version = std::max( versionNum, version );
76 cleanedCode << line << std::endl;
82 wlog::warn(
"WGEShader (" + file +
")" ) <<
"No version statements in unrolled shader file \"" << file <<
"\" found. Using default: "
88 vs <<
"#version " << version << std::endl << cleanedCode.str();