]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/output.cpp
Tweaks to visitor classes in the GLSL compiler
[libs/gl.git] / source / glsl / output.cpp
index aaba1dc4a0a638f15145dc48726344256056727a..973ff8324ac927bdb0d282ff23edf6f7259565c5 100644 (file)
@@ -9,14 +9,17 @@ namespace GL {
 namespace SL {
 
 Formatter::Formatter():
+       stage(0),
        source_index(0),
        source_line(1),
        indent(0),
        parameter_list(false)
 { }
 
-void Formatter::apply(Stage &s)
+const string &Formatter::apply(Stage &s)
 {
+       stage = &s;
+
        GLApi api = get_gl_api();
        const Version &ver = s.required_version;
 
@@ -33,7 +36,9 @@ void Formatter::apply(Stage &s)
        if(!s.required_extensions.empty())
                formatted += '\n';
 
-       StageVisitor::apply(s);
+       visit(s.content);
+
+       return formatted;
 }
 
 void Formatter::append(const string &text)
@@ -211,9 +216,9 @@ void Formatter::visit(VariableDeclaration &var)
                string interface = var.interface;
                if(stage->required_version<Version(1, 30))
                {
-                       if(stage->type==VERTEX && var.interface=="in")
+                       if(stage->type==Stage::VERTEX && var.interface=="in")
                                interface = "attribute";
-                       else if((stage->type==VERTEX && var.interface=="out") || (stage->type==FRAGMENT && var.interface=="in"))
+                       else if((stage->type==Stage::VERTEX && var.interface=="out") || (stage->type==Stage::FRAGMENT && var.interface=="in"))
                                interface = "varying";
                }
                append(format("%s ", interface));