]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programcompiler.cpp
Allow redeclarations to override the type of a variable
[libs/gl.git] / source / programcompiler.cpp
index d65869316423d64806a23bdf3e60254d0f014ce7..aef17fa2369fdadc46366c7b4868751ba2d1fc1e 100644 (file)
@@ -123,9 +123,8 @@ void ProgramCompiler::process()
 
 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;
@@ -479,6 +478,7 @@ void ProgramCompiler::DeclarationCombiner::visit(VariableDeclaration &var)
        VariableDeclaration *&ptr = variables[var.name];
        if(ptr)
        {
+               ptr->type = var.type;
                if(var.init_expression)
                        ptr->init_expression = var.init_expression;
                remove_node = true;