void ProgramCompiler::import(const string &name)
{
- if(!resources)
- throw runtime_error("no resources");
- RefPtr<IO::Seekable> io = resources->open_raw(name+".glsl");
+ string fn = name+".glsl";
+ RefPtr<IO::Seekable> io = (resources ? resources->open_raw(fn) : Resources::get_builtins().open(fn));
if(!io)
throw runtime_error(format("module %s not found", name));
ProgramParser import_parser;
if(!i->value.empty())
formatted += format("=%s", i->value);
}
- formatted += format(") %s;", layout.interface);
+ formatted += ')';
+}
+
+void ProgramCompiler::Formatter::visit(InterfaceLayout &layout)
+{
+ layout.layout.visit(*this);
+ formatted += format(" %s;", layout.interface);
}
void ProgramCompiler::Formatter::visit(StructDeclaration &strct)
void ProgramCompiler::Formatter::visit(VariableDeclaration &var)
{
+ if(var.layout)
+ {
+ var.layout->visit(*this);
+ formatted += ' ';
+ }
if(var.constant)
formatted += "const ";
if(!var.sampling.empty())
VariableDeclaration *&ptr = variables[var.name];
if(ptr)
{
+ ptr->type = var.type;
if(var.init_expression)
ptr->init_expression = var.init_expression;
remove_node = true;