]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/builtin.cpp
Copy the location when moving output declarations out of functions
[libs/gl.git] / source / glsl / builtin.cpp
1 #include "builtin.h"
2 #include "parser.h"
3
4 using namespace std;
5
6 namespace {
7
8 const char builtins_src[] =
9         "#pragma MSP stage(vertex)\n"
10         "out gl_PerVertex {\n"
11         "  vec4 gl_Position;\n"
12         "  float gl_ClipDistance[];\n"
13         "};\n"
14         "#pragma MSP stage(geometry)\n"
15         "in gl_PerVertex {\n"
16         "  vec4 gl_Position;\n"
17         "  float gl_ClipDistance[];\n"
18         "} gl_in[];\n"
19         "out gl_PerVertex {\n"
20         "  vec4 gl_Position;\n"
21         "  float gl_ClipDistance[];\n"
22         "};\n";
23
24 }
25
26 namespace Msp {
27 namespace GL {
28 namespace SL {
29
30 Module *get_builtins_module()
31 {
32         static RefPtr<Module> builtins_module;
33         static bool initialized = false;
34         if(!initialized)
35         {
36                 initialized = true;
37
38                 Parser parser;
39                 Module *module = new Module(parser.parse(builtins_src, "<builtin>", BUILTIN_SOURCE));
40
41                 builtins_module = module;
42         }
43         return builtins_module.get();
44 }
45
46 Stage *get_builtins(Stage::Type type)
47 {
48         Module *module = get_builtins_module();
49         if(!module)
50                 return 0;
51
52         for(list<Stage>::iterator i=module->stages.begin(); i!=module->stages.end(); ++i)
53                 if(i->type==type)
54                         return &*i;
55         return 0;
56 }
57
58 } // namespace SL
59 } // namespace GL
60 } // namespace Msp