]> git.sesse.net Git - movit/blobdiff - util.cpp
Add a hack to use #version 110 but keep using 130 features, for the benefit of OS X.
[movit] / util.cpp
index 59f1dcdd67529ef9b4fd54f959fdc49bdc41d633..675b25b4940c3d9a9048d3d4488220340b31817b 100644 (file)
--- a/util.cpp
+++ b/util.cpp
@@ -19,6 +19,7 @@
 #include <epoxy/wgl.h>
 #else
 #include <epoxy/glx.h>
+#include <epoxy/egl.h>
 #endif
 
 using namespace std;
@@ -126,10 +127,15 @@ string read_file(const string &filename)
 
 string read_version_dependent_file(const string &base, const string &extension)
 {
-       if (movit_shader_model == MOVIT_GLSL_110) {
-               return read_file(base + "." + extension);
+       if (movit_shader_model == MOVIT_GLSL_130_AS_110) {
+               string contents = read_file(base + ".130." + extension);
+               assert(contents.find("#version 130") == 0);
+               contents[10] = '1';  // Change from 130 to 110.
+               return contents;
        } else if (movit_shader_model == MOVIT_GLSL_130) {
                return read_file(base + ".130." + extension);
+       } else if (movit_shader_model == MOVIT_GLSL_150) {
+               return read_file(base + ".150." + extension);
        } else if (movit_shader_model == MOVIT_ESSL_300) {
                return read_file(base + ".300es." + extension);
        } else {
@@ -333,6 +339,10 @@ void *get_gl_context_identifier()
 #elif defined(WIN32)
        return (void *)wglGetCurrentContext();
 #else
+       void *ret = (void *)eglGetCurrentContext();
+       if (ret != NULL) {
+               return ret;
+       }
        return (void *)glXGetCurrentContext();
 #endif
 }