1 #include <msp/gl/resources.h>
2 #include <msp/io/seekable.h>
12 void add_builtin_type(Stage &stage, const std::string &name, BasicTypeDeclaration::Kind kind, unsigned size, unsigned sign)
14 RefPtr<BasicTypeDeclaration> type = new BasicTypeDeclaration;
15 type->source = BUILTIN_SOURCE;
20 stage.content.body.push_back(type);
21 stage.types[name] = type.get();
24 Module *get_builtins_module()
26 static RefPtr<Module> builtins_module;
27 static bool initialized = false;
32 RefPtr<IO::Seekable> io = Resources::get_builtins().open("_builtin.glsl");
36 builtins_module = new Module;
37 add_builtin_type(builtins_module->shared, "void", BasicTypeDeclaration::VOID, 0, true);
38 add_builtin_type(builtins_module->shared, "bool", BasicTypeDeclaration::BOOL, 1, true);
39 add_builtin_type(builtins_module->shared, "int", BasicTypeDeclaration::INT, 32, true);
40 add_builtin_type(builtins_module->shared, "uint", BasicTypeDeclaration::INT, 32, false);
41 add_builtin_type(builtins_module->shared, "float", BasicTypeDeclaration::FLOAT, 32, true);
46 parser.parse(*builtins_module, *io, "<builtin>", BUILTIN_SOURCE);
54 return builtins_module.get();
57 const Stage *get_builtins(Stage::Type type)
59 Module *module = get_builtins_module();
63 if(type==Stage::SHARED)
64 return &module->shared;
65 for(list<Stage>::iterator i=module->stages.begin(); i!=module->stages.end(); ++i)