GFX: make OS X work with OpenGL 2.1 shaders

This commit is contained in:
Pawel Kolodziejski 2015-02-21 13:46:16 +01:00 committed by Bastien Bouclet
parent a72d415793
commit 3e4a4646d9
3 changed files with 41 additions and 13 deletions

View File

@ -28,7 +28,6 @@ namespace Graphics {
namespace BuiltinShaders {
const char *boxVertex =
"#version 100\n"
"attribute vec2 position;\n"
"attribute vec2 texcoord;\n"
"uniform vec2 offsetXY;\n"
@ -47,11 +46,12 @@ const char *boxVertex =
"}\n";
const char *boxFragment =
"#version 100\n"
"#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
"precision highp float;\n"
"#else\n"
"precision mediump float;\n"
"#ifdef GL_ES\n"
"#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
"precision highp float;\n"
"#else\n"
"precision mediump float;\n"
"#endif\n"
"#endif\n"
"varying vec2 Texcoord;\n"
"uniform sampler2D tex;\n"

View File

@ -28,15 +28,37 @@ namespace Graphics {
namespace BuiltinShaders {
const char *compatVertex =
#if defined(USE_OPENGL_SHADERS)
"#if __VERSION__ < 130\n"
"float round(in float x) {\n"
"return sign(x) * floor(abs(x) + .5);\n"
"}\n"
"#define highp\n"
"#define in attribute\n"
"#define out varying\n"
"#endif\n"
#else
"#ifdef GL_ES\n"
"mediump float round(in mediump float x) {\n"
" return sign(x) * floor(abs(x) + .5);\n"
"}\n"
"#define in attribute\n"
"#define out varying\n"
"#endif\n";
"mediump float round(in mediump float x) {\n"
"return sign(x) * floor(abs(x) + .5);\n"
"}\n"
"#define in attribute\n"
"#define out varying\n"
"#endif\n"
#endif
;
const char *compatFragment =
#if defined(USE_OPENGL_SHADERS)
"#if __VERSION__ < 130\n"
"#define in varying\n"
"#define OUTPUT\n"
"#define outColor gl_FragColor\n"
"#define texture texture2D\n"
"#else\n"
"#define OUTPUT out vec4 outColor;\n"
"#endif\n"
#else
"#ifdef GL_ES\n"
"#define in varying\n"
"#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
@ -49,7 +71,9 @@ const char *compatFragment =
"#define texture texture2D\n"
"#else\n"
"#define OUTPUT out vec4 outColor;\n"
"#endif\n";
"#endif\n"
#endif
;
}
}

View File

@ -76,7 +76,11 @@ static GLuint createCompatShader(const char *shaderSource, GLenum shaderType, co
#ifdef USE_GLES2
"#version 100\n",
#else
#ifdef MACOSX
"#version 120\n",
#else
"#version 130\n",
#endif
#endif
compatSource,
shaderSource