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;
29 NodeList<Statement>::iterator insert_point = shared_body.begin();
31 RefPtr<BasicTypeDeclaration> type = new BasicTypeDeclaration;
32 type->source = BUILTIN_SOURCE;
34 type->kind = BasicTypeDeclaration::VOID;
35 shared_body.insert(insert_point, type);
37 type = new BasicTypeDeclaration;
38 type->source = BUILTIN_SOURCE;
41 type->kind = BasicTypeDeclaration::BOOL;
42 shared_body.insert(insert_point, type);
44 type = new BasicTypeDeclaration;
45 type->source = BUILTIN_SOURCE;
48 type->kind = BasicTypeDeclaration::INT;
49 shared_body.insert(insert_point, type);
51 type = new BasicTypeDeclaration;
52 type->source = BUILTIN_SOURCE;
55 type->kind = BasicTypeDeclaration::FLOAT;
56 shared_body.insert(insert_point, type);
58 TypeResolver().apply(module->shared);
59 for(list<Stage>::iterator i=module->stages.begin(); i!=module->stages.end(); ++i)
60 TypeResolver().apply(*i);
62 builtins_module = module;
64 return builtins_module.get();
67 const Stage *get_builtins(Stage::Type type)
69 Module *module = get_builtins_module();
73 if(type==Stage::SHARED)
74 return &module->shared;
75 for(list<Stage>::iterator i=module->stages.begin(); i!=module->stages.end(); ++i)