]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/output.cpp
Inject builtins into the module
[libs/gl.git] / source / glsl / output.cpp
index 46314588858667c059a80c131bb6f527b3ba9bc6..81f335735e80eb433fd746ae85216dc59b309e83 100644 (file)
@@ -44,7 +44,7 @@ const string &Formatter::apply(Stage &s, Compiler::Mode m)
                append("#extension ext_texture_array: require\n");
        formatted += '\n';
 
-       visit(s.content);
+       s.content.visit(*this);
 
        return formatted;
 }
@@ -99,6 +99,11 @@ void Formatter::visit(VariableReference &var)
        append(var.name);
 }
 
+void Formatter::visit(InterfaceBlockReference &iface)
+{
+       append(iface.name);
+}
+
 void Formatter::visit(MemberAccess &memacc)
 {
        memacc.left->visit(*this);
@@ -156,10 +161,14 @@ void Formatter::visit(Block &block)
 
        SetForScope<unsigned> set(indent, indent+(indent>0 || use_braces));
        string spaces(indent*2, ' ');
+       bool first = true;
        for(NodeList<Statement>::iterator i=block.body.begin(); i!=block.body.end(); ++i)
        {
-               if(i!=block.body.begin())
+               if((*i)->source==BUILTIN_SOURCE)
+                       continue;
+               if(!first)
                        append('\n');
+               first = false;
                set_source((*i)->source, (*i)->line);
                append(spaces);
                (*i)->visit(*this);
@@ -255,6 +264,13 @@ void Formatter::visit(InterfaceBlock &iface)
        SetForScope<string> set(block_interface, iface.interface);
        append(format("%s %s\n", iface.interface, iface.name));
        iface.members.visit(*this);
+       if(!iface.instance_name.empty())
+       {
+               append(' ');
+               append(iface.instance_name);
+               if(iface.array)
+                       append("[]");
+       }
        append(';');
 }