]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/output.cpp
Allow using SL::Formatter on single nodes
[libs/gl.git] / source / glsl / output.cpp
index 6e88fd1f870e6ba554a0fbfa0ddaba93d6347720..f97b8cdb2e2958aeb7bee1d979bb9b0ecbbffeae 100644 (file)
@@ -18,7 +18,7 @@ Formatter::Formatter():
 
 const string &Formatter::apply(Stage &s)
 {
-       SetForScope<Stage *> set_stage(stage, &s);
+       stage = &s;
 
        GLApi api = get_gl_api();
        const Version &ver = s.required_version;
@@ -65,7 +65,7 @@ void Formatter::set_source(unsigned index, unsigned line)
                else
                {
                        unsigned l = line;
-                       if(stage->required_version<Version(3, 30))
+                       if(stage && stage->required_version<Version(3, 30))
                                --l;
                        formatted += format("#line %d %d\n", l, index);
                }
@@ -214,7 +214,7 @@ void Formatter::visit(VariableDeclaration &var)
        if(!var.interface.empty() && var.interface!=block_interface)
        {
                string interface = var.interface;
-               if(stage->required_version<Version(1, 30))
+               if(stage && stage->required_version<Version(1, 30))
                {
                        if(stage->type==Stage::VERTEX && var.interface=="in")
                                interface = "attribute";