Commit 1441746f authored by Adrien Maglo's avatar Adrien Maglo

[OpenGL] Make the GLSL shaders compatible with OpenGL ES 2.0

parent 198167d3
...@@ -191,7 +191,7 @@ static void BuildVertexShader(vout_display_opengl_t *vgl, ...@@ -191,7 +191,7 @@ static void BuildVertexShader(vout_display_opengl_t *vgl,
{ {
/* Basic vertex shader */ /* Basic vertex shader */
const char *vertexShader = const char *vertexShader =
"#version 120\n" "#version 100\n"
"varying vec4 TexCoord0,TexCoord1, TexCoord2;" "varying vec4 TexCoord0,TexCoord1, TexCoord2;"
"attribute vec4 MultiTexCoord0,MultiTexCoord1,MultiTexCoord2;" "attribute vec4 MultiTexCoord0,MultiTexCoord1,MultiTexCoord2;"
"attribute vec4 VertexPosition;" "attribute vec4 VertexPosition;"
...@@ -234,16 +234,18 @@ static void BuildYUVFragmentShader(vout_display_opengl_t *vgl, ...@@ -234,16 +234,18 @@ static void BuildYUVFragmentShader(vout_display_opengl_t *vgl,
/* Basic linear YUV -> RGB conversion using bilinear interpolation */ /* Basic linear YUV -> RGB conversion using bilinear interpolation */
const char *template_glsl_yuv = const char *template_glsl_yuv =
"#version 120\n" "#version 100\n"
"uniform sampler2D Texture[3];" "uniform sampler2D Texture0;"
"uniform sampler2D Texture1;"
"uniform sampler2D Texture2;"
"uniform vec4 Coefficient[4];" "uniform vec4 Coefficient[4];"
"varying vec4 TexCoord0,TexCoord1,TexCoord2;" "varying vec4 TexCoord0,TexCoord1,TexCoord2;"
"void main(void) {" "void main(void) {"
" vec4 x,y,z,result;" " vec4 x,y,z,result;"
" x = texture2D(Texture[0], TexCoord0.st);" " x = texture2D(Texture0, TexCoord0.st);"
" %c = texture2D(Texture[1], TexCoord1.st);" " %c = texture2D(Texture1, TexCoord1.st);"
" %c = texture2D(Texture[2], TexCoord2.st);" " %c = texture2D(Texture2, TexCoord2.st);"
" result = x * Coefficient[0] + Coefficient[3];" " result = x * Coefficient[0] + Coefficient[3];"
" result = (y * Coefficient[1]) + result;" " result = (y * Coefficient[1]) + result;"
...@@ -282,7 +284,7 @@ static void BuildRGBFragmentShader(vout_display_opengl_t *vgl, ...@@ -282,7 +284,7 @@ static void BuildRGBFragmentShader(vout_display_opengl_t *vgl,
{ {
// Simple shader for RGB // Simple shader for RGB
const char *code = const char *code =
"#version 120\n" "#version 100\n"
"uniform sampler2D Texture[3];" "uniform sampler2D Texture[3];"
"varying vec4 TexCoord0,TexCoord1,TexCoord2;" "varying vec4 TexCoord0,TexCoord1,TexCoord2;"
"void main()" "void main()"
...@@ -299,7 +301,7 @@ static void BuildRGBAFragmentShader(vout_display_opengl_t *vgl, ...@@ -299,7 +301,7 @@ static void BuildRGBAFragmentShader(vout_display_opengl_t *vgl,
{ {
// Simple shader for RGBA // Simple shader for RGBA
const char *code = const char *code =
"#version 120\n" "#version 100\n"
"uniform sampler2D Texture;" "uniform sampler2D Texture;"
"uniform vec4 FillColor;" "uniform vec4 FillColor;"
"varying vec4 TexCoord0;" "varying vec4 TexCoord0;"
...@@ -781,9 +783,9 @@ static void DrawWithShaders(vout_display_opengl_t *vgl, ...@@ -781,9 +783,9 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
{ {
vgl->UseProgram(vgl->program[0]); vgl->UseProgram(vgl->program[0]);
vgl->Uniform4fv(vgl->GetUniformLocation(vgl->program[0], "Coefficient"), 4, vgl->local_value); vgl->Uniform4fv(vgl->GetUniformLocation(vgl->program[0], "Coefficient"), 4, vgl->local_value);
vgl->Uniform1i(vgl->GetUniformLocation(vgl->program[0], "Texture[0]"), 0); vgl->Uniform1i(vgl->GetUniformLocation(vgl->program[0], "Texture0"), 0);
vgl->Uniform1i(vgl->GetUniformLocation(vgl->program[0], "Texture[1]"), 1); vgl->Uniform1i(vgl->GetUniformLocation(vgl->program[0], "Texture1"), 1);
vgl->Uniform1i(vgl->GetUniformLocation(vgl->program[0], "Texture[2]"), 2); vgl->Uniform1i(vgl->GetUniformLocation(vgl->program[0], "Texture2"), 2);
static const GLfloat vertexCoord[] = { static const GLfloat vertexCoord[] = {
-1.0, 1.0, -1.0, 1.0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment