]> git.tdb.fi Git - libs/gl.git/commitdiff
Load builtin GLSL declarations from a file
authorMikko Rasa <tdb@tdb.fi>
Thu, 4 Mar 2021 21:30:13 +0000 (23:30 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 4 Mar 2021 22:30:28 +0000 (00:30 +0200)
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 [new file with mode: 0644]
source/glsl/builtin.cpp

diff --git a/builtin_data/_builtin.glsl b/builtin_data/_builtin.glsl
new file mode 100644 (file)
index 0000000..f6a3574
--- /dev/null
@@ -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[];
+};
index 955266fe0a1ce4ad3a8abfcd9fb3afb0340266f8..9aa6a6c2b4dd6bcef9d71cc26ea9d6af6343646d 100644 (file)
@@ -1,28 +1,10 @@
+#include <msp/gl/resources.h>
+#include <msp/io/seekable.h>
 #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::Seekable> io = Resources::get_builtins().open("_builtin.glsl");
+               if(!io)
+                       return 0;
+
                Parser parser;
-               Module *module = new Module(parser.parse(builtins_src, "<builtin>", BUILTIN_SOURCE));
+               Module *module = new Module(parser.parse(*io, "<builtin>", BUILTIN_SOURCE));
 
                builtins_module = module;
        }