]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/output.cpp
Redesign the way shader programs are loaded
[libs/gl.git] / source / glsl / output.cpp
index f97b8cdb2e2958aeb7bee1d979bb9b0ecbbffeae..9d4383e4de979b91c6febdab5e0cd02ca599e4e8 100644 (file)
@@ -10,14 +10,16 @@ namespace SL {
 
 Formatter::Formatter():
        stage(0),
+       mode(Compiler::PROGRAM),
        source_index(0),
        source_line(1),
        indent(0),
        parameter_list(false)
 { }
 
-const string &Formatter::apply(Stage &s)
+const string &Formatter::apply(Stage &s, Compiler::Mode m)
 {
+       mode = m;
        stage = &s;
 
        GLApi api = get_gl_api();
@@ -65,7 +67,7 @@ void Formatter::set_source(unsigned index, unsigned line)
                else
                {
                        unsigned l = line;
-                       if(stage && stage->required_version<Version(3, 30))
+                       if(mode==Compiler::PROGRAM && stage && stage->required_version<Version(3, 30))
                                --l;
                        formatted += format("#line %d %d\n", l, index);
                }
@@ -214,7 +216,7 @@ void Formatter::visit(VariableDeclaration &var)
        if(!var.interface.empty() && var.interface!=block_interface)
        {
                string interface = var.interface;
-               if(stage && stage->required_version<Version(1, 30))
+               if(mode==Compiler::PROGRAM && stage && stage->required_version<Version(1, 30))
                {
                        if(stage->type==Stage::VERTEX && var.interface=="in")
                                interface = "attribute";