1 #include <msp/gl/resources.h>
2 #include <msp/io/seekable.h>
13 Module *get_builtins_module()
15 static RefPtr<Module> builtins_module;
16 static bool initialized = false;
21 RefPtr<IO::Seekable> io = Resources::get_builtins().open("_builtin.glsl");
26 Module *module = new Module(parser.parse(*io, "<builtin>", BUILTIN_SOURCE));
28 NodeList<Statement> &shared_body = module->shared.content.body;
30 RefPtr<BasicTypeDeclaration> type = new BasicTypeDeclaration;
31 type->source = BUILTIN_SOURCE;
33 type->kind = BasicTypeDeclaration::VOID;
34 shared_body.insert(shared_body.begin(), type);
36 type = new BasicTypeDeclaration;
37 type->source = BUILTIN_SOURCE;
39 type->kind = BasicTypeDeclaration::BOOL;
40 shared_body.insert(shared_body.begin(), type);
42 type = new BasicTypeDeclaration;
43 type->source = BUILTIN_SOURCE;
46 type->kind = BasicTypeDeclaration::INT;
47 shared_body.insert(shared_body.begin(), type);
49 type = new BasicTypeDeclaration;
50 type->source = BUILTIN_SOURCE;
53 type->kind = BasicTypeDeclaration::FLOAT;
54 shared_body.insert(shared_body.begin(), type);
56 TypeResolver().apply(module->shared);
57 for(list<Stage>::iterator i=module->stages.begin(); i!=module->stages.end(); ++i)
58 TypeResolver().apply(*i);
60 builtins_module = module;
62 return builtins_module.get();
65 const Stage *get_builtins(Stage::Type type)
67 Module *module = get_builtins_module();
71 if(type==Stage::SHARED)
72 return &module->shared;
73 for(list<Stage>::iterator i=module->stages.begin(); i!=module->stages.end(); ++i)