diff --git a/RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h b/RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h index 9d5c47f6160..a21b7c1b2ba 100644 --- a/RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h +++ b/RenderSystems/GL3Plus/include/GLSL/OgreGLSLPreprocessor.h @@ -521,6 +521,16 @@ namespace Ogre */ char *Parse( const char *iSource, size_t iLength, size_t &oLength ); + /** Parse the input string as a preamble (i.e. to define a lot of enums). + @param iSource + The source text containing preamble macros. + @param iLength + The length of iSource text in characters. + @return + False on errors. True on success. + */ + bool ParsePreamble( const char *iSource, size_t iLength ); + /** * An error handler function type. * The default implementation just drops a note to stderr and diff --git a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp index dbcb6845a73..5dbd8c55172 100644 --- a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp +++ b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLPreprocessor.cpp @@ -1437,4 +1437,10 @@ namespace Ogre return retval.Buffer; } + bool CPreprocessor::ParsePreamble( const char *iSource, size_t iLength ) + { + Token retval = Parse( Token( Token::TK_TEXT, iSource, iLength ) ); + return retval.Type != Token::TK_ERROR; + } + } // namespace Ogre diff --git a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp index 8cf99c165de..53cf2ade1b6 100644 --- a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp +++ b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp @@ -163,7 +163,6 @@ namespace Ogre replaceVersionMacros(); // Mask out vulkan_layout() macros - size_t unusedVal = 0; const String preamble = "#define vulkan_layout(x)\n" "#define vulkan( x )\n" @@ -180,7 +179,7 @@ namespace Ogre "#define vkSampler2DArray( a, b ) a\n" "#define vkSampler3D( a, b ) a\n" "#define vkSamplerCube( a, b ) a\n"; - cpp.Parse( preamble.c_str(), preamble.size(), unusedVal ); + cpp.ParsePreamble( preamble.c_str(), preamble.size() ); // Pass all user-defined macros to preprocessor if( !mPreprocessorDefines.empty() )