[vlc-commits] opengl: use vec2 for TexCoords

Thomas Guillem git at videolan.org
Thu Feb 2 09:52:49 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jan 27 18:48:47 2017 +0100| [67f2472718afd430f9710e6c4c84f94382064ca1] | committer: Thomas Guillem

opengl: use vec2 for TexCoords

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=67f2472718afd430f9710e6c4c84f94382064ca1
---

 modules/video_output/opengl/converter_android.c |  4 ++--
 modules/video_output/opengl/converters.c        | 20 ++++++++++----------
 modules/video_output/opengl/vout_helper.c       | 12 ++++++------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/modules/video_output/opengl/converter_android.c b/modules/video_output/opengl/converter_android.c
index 3c304a9..d10f272 100644
--- a/modules/video_output/opengl/converter_android.c
+++ b/modules/video_output/opengl/converter_android.c
@@ -254,12 +254,12 @@ opengl_tex_converter_anop_init(const video_format_t *fmt,
         "#version " GLSL_VERSION "\n"
         "#extension GL_OES_EGL_image_external : require\n"
         PRECISION
-        "varying vec4 TexCoord0;"
+        "varying vec2 TexCoord0;"
         "uniform samplerExternalOES sTexture;"
         "uniform mat4 uSTMatrix;"
         "void main()"
         "{ "
-        "  gl_FragColor = texture2D(sTexture, (uSTMatrix * TexCoord0).xy);"
+        "  gl_FragColor = texture2D(sTexture, (uSTMatrix * vec4(TexCoord0, 1, 1)).xy);"
         "}";
     GLuint fragment_shader = tc->api->CreateShader(GL_FRAGMENT_SHADER);
     tc->api->ShaderSource(fragment_shader, 1, &code, NULL);
diff --git a/modules/video_output/opengl/converters.c b/modules/video_output/opengl/converters.c
index f77eecf..18529c3 100644
--- a/modules/video_output/opengl/converters.c
+++ b/modules/video_output/opengl/converters.c
@@ -542,10 +542,10 @@ opengl_tex_converter_rgba_init(const video_format_t *fmt,
         "#version " GLSL_VERSION "\n"
         PRECISION
         "uniform sampler2D Texture[3];"
-        "varying vec4 TexCoord0,TexCoord1,TexCoord2;"
+        "varying vec2 TexCoord0;"
         "void main()"
         "{ "
-        "  gl_FragColor = texture2D(Texture[0], TexCoord0.st);"
+        "  gl_FragColor = texture2D(Texture[0], TexCoord0);"
         "}";
 #endif
 
@@ -555,10 +555,10 @@ opengl_tex_converter_rgba_init(const video_format_t *fmt,
         PRECISION
         "uniform sampler2D Texture0;"
         "uniform vec4 FillColor;"
-        "varying vec4 TexCoord0;"
+        "varying vec2 TexCoord0;"
         "void main()"
         "{ "
-        "  gl_FragColor = texture2D(Texture0, TexCoord0.st) * FillColor;"
+        "  gl_FragColor = texture2D(Texture0, TexCoord0) * FillColor;"
         "}";
 
     GLuint fragment_shader = tc->api->CreateShader(GL_FRAGMENT_SHADER);
@@ -695,7 +695,7 @@ opengl_tex_converter_yuv_init(const video_format_t *fmt,
         "uniform sampler2D Texture1;"
         "uniform sampler2D Texture2;"
         "uniform vec4      Coefficient[4];"
-        "varying vec4      TexCoord0,TexCoord1,TexCoord2;"
+        "varying vec2      TexCoord0,TexCoord1,TexCoord2;"
 
         "void main(void) {"
         " vec4 x,y,z,result;"
@@ -704,9 +704,9 @@ opengl_tex_converter_yuv_init(const video_format_t *fmt,
          * vec4(L,L,L,1). The following transform a vec4(x, y, z, w) into a
          * vec4(x, x, x, 1) (we may want to use texture swizzling starting
          * OpenGL 3.3). */
-        " float val0 = texture2D(Texture0, TexCoord0.st).x;"
-        " float val1 = texture2D(Texture1, TexCoord1.st).x;"
-        " float val2 = texture2D(Texture2, TexCoord2.st).x;"
+        " float val0 = texture2D(Texture0, TexCoord0).x;"
+        " float val1 = texture2D(Texture1, TexCoord1).x;"
+        " float val2 = texture2D(Texture2, TexCoord2).x;"
         " x  = vec4(val0, val0, val0, 1);"
         " %c = vec4(val1, val1, val1, 1);"
         " %c = vec4(val2, val2, val2, 1);"
@@ -803,11 +803,11 @@ opengl_tex_converter_xyz12_init(const video_format_t *fmt,
         "    0.0,      0.0,         0.0,        1.0 "
         " );"
 
-        "varying vec4 TexCoord0;"
+        "varying vec2 TexCoord0;"
         "void main()"
         "{ "
         " vec4 v_in, v_out;"
-        " v_in  = texture2D(Texture0, TexCoord0.st);"
+        " v_in  = texture2D(Texture0, TexCoord0);"
         " v_in = pow(v_in, xyz_gamma);"
         " v_out = matrix_xyz_rgb * v_in ;"
         " v_out = pow(v_out, rgb_gamma) ;"
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index 5fd5ebc..65c8054 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -349,7 +349,7 @@ static GLuint BuildVertexShader(vout_display_opengl_t *vgl, unsigned plane_count
     static const char *template =
         "#version " GLSL_VERSION "\n"
         PRECISION
-        "varying vec4 TexCoord0;attribute vec4 MultiTexCoord0;"
+        "varying vec2 TexCoord0;attribute vec4 MultiTexCoord0;"
         "%s%s"
         "attribute vec3 VertexPosition;"
         "uniform mat4 OrientationMatrix;"
@@ -359,19 +359,19 @@ static GLuint BuildVertexShader(vout_display_opengl_t *vgl, unsigned plane_count
         "uniform mat4 ZRotMatrix;"
         "uniform mat4 ZoomMatrix;"
         "void main() {"
-        " TexCoord0 = OrientationMatrix * MultiTexCoord0;"
+        " TexCoord0 = vec4(OrientationMatrix * MultiTexCoord0).st;"
         "%s%s"
         " gl_Position = ProjectionMatrix * ZoomMatrix * ZRotMatrix * XRotMatrix * YRotMatrix * vec4(VertexPosition, 1.0);"
         "}";
 
     const char *coord1_header = plane_count > 1 ?
-        "varying vec4 TexCoord1;attribute vec4 MultiTexCoord1;" : "";
+        "varying vec2 TexCoord1;attribute vec4 MultiTexCoord1;" : "";
     const char *coord1_code = plane_count > 1 ?
-        " TexCoord1 = OrientationMatrix * MultiTexCoord1;" : "";
+        " TexCoord1 = vec4(OrientationMatrix * MultiTexCoord1).st;" : "";
     const char *coord2_header = plane_count > 2 ?
-        "varying vec4 TexCoord2;attribute vec4 MultiTexCoord2;" : "";
+        "varying vec2 TexCoord2;attribute vec4 MultiTexCoord2;" : "";
     const char *coord2_code = plane_count > 2 ?
-        " TexCoord2 = OrientationMatrix * MultiTexCoord2;" : "";
+        " TexCoord2 = vec4(OrientationMatrix * MultiTexCoord2).st;" : "";
 
     char *code;
     if (asprintf(&code, template, coord1_header, coord2_header,



More information about the vlc-commits mailing list