--- /dev/null
+#version 150
+
+in vec2 tc;
+
+vec4 tex2D(sampler2D s, vec2 coord)
+{
+ return texture(s, coord);
+}
get_glsl_version());
return false;
}
- movit_shader_model = MOVIT_GLSL_130;
+ if (get_glsl_version() < 1.50f) {
+ movit_shader_model = MOVIT_GLSL_130;
+ } else {
+ // Note: All of our 1.50 shaders are identical to our 1.30 shaders,
+ // but OS X does not support 1.30; only 1.10 (which we don't support
+ // anymore) and 1.50 (and then only with core contexts). So we keep
+ // a second set of shaders around whose only difference is the different
+ // #version declaration.
+ movit_shader_model = MOVIT_GLSL_150;
+ }
} else {
movit_shader_model = MOVIT_ESSL_300;
}
enum MovitShaderModel {
MOVIT_GLSL_110, // No longer in use, but kept until next ABI break in order not to change the enums.
MOVIT_GLSL_130,
- MOVIT_ESSL_300
+ MOVIT_ESSL_300,
+ MOVIT_GLSL_150,
};
extern MovitShaderModel movit_shader_model;
--- /dev/null
+#version 150
+
+uniform sampler2D tex;
+in vec2 tc;
+
+out vec4 FragColor;
+
+void main()
+{
+ FragColor = texture(tex, tc); // Second component is irrelevant.
+}
{
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 {
--- /dev/null
+#version 150
+
+in vec2 position;
+in vec2 texcoord;
+out vec2 tc;
+
+// Will be overridden by compile_glsl_program() if needed.
+// (It cannot just be prepended, as #version must be before everything.)
+#define FLIP_ORIGIN 0
+
+void main()
+{
+ // The result of glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0) is:
+ //
+ // 2.000 0.000 0.000 -1.000
+ // 0.000 2.000 0.000 -1.000
+ // 0.000 0.000 -2.000 -1.000
+ // 0.000 0.000 0.000 1.000
+ gl_Position = vec4(2.0 * position.x - 1.0, 2.0 * position.y - 1.0, -1.0, 1.0);
+ tc = texcoord;
+#if FLIP_ORIGIN
+ tc.y = 1.0f - tc.y;
+#endif
+}