From 992516fcf616fe6ceb55f5a6767eb174aff3f830 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 4 Mar 2021 23:30:13 +0200 Subject: [PATCH] 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. --- builtin_data/_builtin.glsl | 18 ++++++++++++++++++ source/glsl/builtin.cpp | 28 +++++++--------------------- 2 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 builtin_data/_builtin.glsl 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; } -- 2.43.0