From: Mikko Rasa Date: Thu, 4 Mar 2021 21:30:13 +0000 (+0200) Subject: Load builtin GLSL declarations from a file X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=992516fcf616fe6ceb55f5a6767eb174aff3f830;p=libs%2Fgl.git Load builtin GLSL declarations from a file I'm going to add a lot more stuff into it so having it in the C++ source would be inconvenient. --- diff --git a/builtin_data/_builtin.glsl b/builtin_data/_builtin.glsl new file mode 100644 index 00000000..f6a3574f --- /dev/null +++ b/builtin_data/_builtin.glsl @@ -0,0 +1,18 @@ +#pragma MSP stage(vertex) +out gl_PerVertex +{ + vec4 gl_Position; + float gl_ClipDistance[]; +}; + +#pragma MSP stage(geometry) +in gl_PerVertex +{ + vec4 gl_Position; + float gl_ClipDistance[]; +} gl_in[]; +out gl_PerVertex +{ + vec4 gl_Position; + float gl_ClipDistance[]; +}; diff --git a/source/glsl/builtin.cpp b/source/glsl/builtin.cpp index 955266fe..9aa6a6c2 100644 --- a/source/glsl/builtin.cpp +++ b/source/glsl/builtin.cpp @@ -1,28 +1,10 @@ +#include +#include #include "builtin.h" #include "parser.h" using namespace std; -namespace { - -const char builtins_src[] = - "#pragma MSP stage(vertex)\n" - "out gl_PerVertex {\n" - " vec4 gl_Position;\n" - " float gl_ClipDistance[];\n" - "};\n" - "#pragma MSP stage(geometry)\n" - "in gl_PerVertex {\n" - " vec4 gl_Position;\n" - " float gl_ClipDistance[];\n" - "} gl_in[];\n" - "out gl_PerVertex {\n" - " vec4 gl_Position;\n" - " float gl_ClipDistance[];\n" - "};\n"; - -} - namespace Msp { namespace GL { namespace SL { @@ -35,8 +17,12 @@ Module *get_builtins_module() { initialized = true; + RefPtr io = Resources::get_builtins().open("_builtin.glsl"); + if(!io) + return 0; + Parser parser; - Module *module = new Module(parser.parse(builtins_src, "", BUILTIN_SOURCE)); + Module *module = new Module(parser.parse(*io, "", BUILTIN_SOURCE)); builtins_module = module; }