]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programparser.cpp
Recognize #version directive in GLSL
[libs/gl.git] / source / programparser.cpp
index ca554f427464b8863b03ed8211c0f8598e2c7c03..7477f38bc9a6ad01d1f0182ed2429caaa6f49d39 100644 (file)
@@ -369,8 +369,10 @@ void ProgramParser::preprocess()
        string token = peek_token();
        if(token=="pragma")
                preprocess_pragma();
+       else if(token=="version")
+               preprocess_version();
        else if(token=="define" || token=="undef" || token=="if" || token=="ifdef" || token=="ifndef" || token=="else" ||
-               token=="elif" || token=="endif" || token=="error" || token=="extension" || token=="version" || token=="line")
+               token=="elif" || token=="endif" || token=="error" || token=="extension" || token=="line")
                throw runtime_error(format_error(format("Unsupported preprocessor directive '%s'", token)));
        else if(!token.empty())
                throw runtime_error(format_syntax_error("a preprocessor directive"));
@@ -378,6 +380,18 @@ void ProgramParser::preprocess()
        iter = line_end;
 }
 
+void ProgramParser::preprocess_version()
+{
+       expect("version");
+       string token = parse_token();
+       unsigned version = lexical_cast<unsigned>(token);
+       cur_stage->required_version = Version(version/100, version%100);
+
+       token = parse_token();
+       if(!token.empty())
+               throw runtime_error(format_syntax_error("end of line"));
+}
+
 void ProgramParser::preprocess_pragma()
 {
        expect("pragma");