[327/906] fix init FBO's texture attachment on ES 2.0

This commit is contained in:
Julien 2009-04-10 20:42:59 +02:00 committed by Matthew Waters
parent bb0781a389
commit bf0b1fa1ab

View file

@ -236,11 +236,9 @@ gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
"uniform sampler2DRect Ytex, UVtex;\n" "uniform sampler2DRect Ytex, UVtex;\n"
#else #else
"precision mediump float;\n" "precision mediump float;\n"
"varying vec2 v_texCoord;\n" "varying vec2 v_texCoord;\n" "uniform sampler2D Ytex, UVtex;\n"
"uniform sampler2D Ytex, UVtex;\n"
#endif #endif
"void main(void) {\n" "void main(void) {\n" " float fx, fy, y, u, v, r, g, b;\n"
" float fx, fy, y, u, v, r, g, b;\n"
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
" fx = gl_TexCoord[0].x;\n" " fx = gl_TexCoord[0].x;\n"
" fy = gl_TexCoord[0].y;\n" " fy = gl_TexCoord[0].y;\n"
@ -259,9 +257,7 @@ gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
" v=v-0.5;\n" " v=v-0.5;\n"
" r = y+1.5958*v;\n" " r = y+1.5958*v;\n"
" g = y-0.39173*u-0.81290*v;\n" " g = y-0.39173*u-0.81290*v;\n"
" b = y+2.017*u;\n" " b = y+2.017*u;\n" " gl_FragColor = vec4(r, g, b, 1.0);\n" "}\n";
" gl_FragColor = vec4(r, g, b, 1.0);\n"
"}\n";
//ATI: "*0.5", "" //ATI: "*0.5", ""
//normal: "", "*0.5" //normal: "", "*0.5"
@ -271,11 +267,9 @@ gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
"uniform sampler2DRect Ytex,Utex,Vtex;\n" "uniform sampler2DRect Ytex,Utex,Vtex;\n"
#else #else
"precision mediump float;\n" "precision mediump float;\n"
"varying vec2 v_texCoord;\n" "varying vec2 v_texCoord;\n" "uniform sampler2D Ytex,Utex,Vtex;\n"
"uniform sampler2D Ytex,Utex,Vtex;\n"
#endif #endif
"void main(void) {\n" "void main(void) {\n" " float r,g,b,y,u,v;\n"
" float r,g,b,y,u,v;\n"
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
" vec2 nxy = gl_TexCoord[0].xy;\n" " vec2 nxy = gl_TexCoord[0].xy;\n"
" y=texture2DRect(Ytex,nxy%s).r;\n" " y=texture2DRect(Ytex,nxy%s).r;\n"
@ -284,17 +278,14 @@ gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
#else #else
" vec2 nxy = v_texCoord.xy;\n" " vec2 nxy = v_texCoord.xy;\n"
" y=texture2D(Ytex,nxy).r;\n" " y=texture2D(Ytex,nxy).r;\n"
" u=texture2D(Utex,nxy).r;\n" " u=texture2D(Utex,nxy).r;\n" " v=texture2D(Vtex,nxy).r;\n"
" v=texture2D(Vtex,nxy).r;\n"
#endif #endif
" y=1.1643*(y-0.0625);\n" " y=1.1643*(y-0.0625);\n"
" u=u-0.5;\n" " u=u-0.5;\n"
" v=v-0.5;\n" " v=v-0.5;\n"
" r=y+1.5958*v;\n" " r=y+1.5958*v;\n"
" g=y-0.39173*u-0.81290*v;\n" " g=y-0.39173*u-0.81290*v;\n"
" b=y+2.017*u;\n" " b=y+2.017*u;\n" " gl_FragColor=vec4(r,g,b,1.0);\n" "}\n";
" gl_FragColor=vec4(r,g,b,1.0);\n"
"}\n";
display->text_shader_upload_AYUV = display->text_shader_upload_AYUV =
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
@ -302,30 +293,24 @@ gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
"uniform sampler2DRect tex;\n" "uniform sampler2DRect tex;\n"
#else #else
"precision mediump float;\n" "precision mediump float;\n"
"varying vec2 v_texCoord;\n" "varying vec2 v_texCoord;\n" "uniform sampler2D tex;\n"
"uniform sampler2D tex;\n"
#endif #endif
"void main(void) {\n" "void main(void) {\n" " float r,g,b,y,u,v;\n"
" float r,g,b,y,u,v;\n"
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
" vec2 nxy=gl_TexCoord[0].xy;\n" " vec2 nxy=gl_TexCoord[0].xy;\n"
" y=texture2DRect(tex,nxy).r;\n" " y=texture2DRect(tex,nxy).r;\n"
" u=texture2DRect(tex,nxy).g;\n" " u=texture2DRect(tex,nxy).g;\n" " v=texture2DRect(tex,nxy).b;\n"
" v=texture2DRect(tex,nxy).b;\n"
#else #else
" vec2 nxy = v_texCoord.xy;\n" " vec2 nxy = v_texCoord.xy;\n"
" y=texture2D(tex,nxy).g;\n" " y=texture2D(tex,nxy).g;\n"
" u=texture2D(tex,nxy).b;\n" " u=texture2D(tex,nxy).b;\n" " v=texture2D(tex,nxy).a;\n"
" v=texture2D(tex,nxy).a;\n"
#endif #endif
" y=1.1643*(y-0.0625);\n" " y=1.1643*(y-0.0625);\n"
" u=u-0.5;\n" " u=u-0.5;\n"
" v=v-0.5;\n" " v=v-0.5;\n"
" r=y+1.5958*v;\n" " r=y+1.5958*v;\n"
" g=y-0.39173*u-0.81290*v;\n" " g=y-0.39173*u-0.81290*v;\n"
" b=y+2.017*u;\n" " b=y+2.017*u;\n" " gl_FragColor=vec4(r,g,b,1.0);\n" "}\n";
" gl_FragColor=vec4(r,g,b,1.0);\n"
"}\n";
//YUY2:y2,u,y1,v //YUY2:y2,u,y1,v
//UYVY:v,y1,u,y2 //UYVY:v,y1,u,y2
@ -335,11 +320,9 @@ gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
"uniform sampler2DRect tex;\n" "uniform sampler2DRect tex;\n"
#else #else
"precision mediump float;\n" "precision mediump float;\n"
"varying vec2 v_texCoord;\n" "varying vec2 v_texCoord;\n" "uniform sampler2D tex;\n"
"uniform sampler2D tex;\n"
#endif #endif
"void main(void) {\n" "void main(void) {\n" " float fx,fy,r,g,b,r2,g2,b2,y1,y2,u,v;\n"
" float fx,fy,r,g,b,r2,g2,b2,y1,y2,u,v;\n"
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
" fx = gl_TexCoord[0].x;\n" " fx = gl_TexCoord[0].x;\n"
" fy = gl_TexCoord[0].y;\n" " fy = gl_TexCoord[0].y;\n"
@ -365,11 +348,8 @@ gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
" v=0.439271*r - 0.367833*g - 0.071438*b ;\n" " v=0.439271*r - 0.367833*g - 0.071438*b ;\n"
" y1=0.858885*y1 + 0.0625;\n" " y1=0.858885*y1 + 0.0625;\n"
" y2=0.858885*y2 + 0.0625;\n" " y2=0.858885*y2 + 0.0625;\n"
" u=u + 0.5;\n" " u=u + 0.5;\n" " v=v + 0.5;\n" " gl_FragColor=vec4(%s);\n" "}\n";
" v=v + 0.5;\n"
" gl_FragColor=vec4(%s);\n"
"}\n";
//no OpenGL ES 2.0 support because for now it's not possible //no OpenGL ES 2.0 support because for now it's not possible
//to attach multiple textures to a frame buffer object //to attach multiple textures to a frame buffer object
display->text_shader_download_I420_YV12 = display->text_shader_download_I420_YV12 =
@ -394,8 +374,7 @@ gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
" v=v + 0.5;\n" " v=v + 0.5;\n"
" gl_FragData[0] = vec4(y, 0.0, 0.0, 1.0);\n" " gl_FragData[0] = vec4(y, 0.0, 0.0, 1.0);\n"
" gl_FragData[1] = vec4(u, 0.0, 0.0, 1.0);\n" " gl_FragData[1] = vec4(u, 0.0, 0.0, 1.0);\n"
" gl_FragData[2] = vec4(v, 0.0, 0.0, 1.0);\n" " gl_FragData[2] = vec4(v, 0.0, 0.0, 1.0);\n" "}\n";
"}\n";
display->text_shader_download_AYUV = display->text_shader_download_AYUV =
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
@ -403,28 +382,22 @@ gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
"uniform sampler2DRect tex;\n" "uniform sampler2DRect tex;\n"
#else #else
"precision mediump float;\n" "precision mediump float;\n"
"varying vec2 v_texCoord;\n" "varying vec2 v_texCoord;\n" "uniform sampler2D tex;\n"
"uniform sampler2D tex;\n"
#endif #endif
"void main(void) {\n" "void main(void) {\n" " float r,g,b,y,u,v;\n"
" float r,g,b,y,u,v;\n"
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
" vec2 nxy=gl_TexCoord[0].xy;\n" " vec2 nxy=gl_TexCoord[0].xy;\n"
" r=texture2DRect(tex,nxy).r;\n" " r=texture2DRect(tex,nxy).r;\n"
" g=texture2DRect(tex,nxy).g;\n" " g=texture2DRect(tex,nxy).g;\n" " b=texture2DRect(tex,nxy).b;\n"
" b=texture2DRect(tex,nxy).b;\n"
#else #else
" vec2 nxy=v_texCoord.xy;\n" " vec2 nxy=v_texCoord.xy;\n"
" r=texture2D(tex,nxy).r;\n" " r=texture2D(tex,nxy).r;\n"
" g=texture2D(tex,nxy).g;\n" " g=texture2D(tex,nxy).g;\n" " b=texture2D(tex,nxy).b;\n"
" b=texture2D(tex,nxy).b;\n"
#endif #endif
" y=0.299011*r + 0.586987*g + 0.114001*b;\n" " y=0.299011*r + 0.586987*g + 0.114001*b;\n"
" u=-0.148246*r -0.29102*g + 0.439266*b;\n" " u=-0.148246*r -0.29102*g + 0.439266*b;\n"
" v=0.439271*r - 0.367833*g - 0.071438*b ;\n" " v=0.439271*r - 0.367833*g - 0.071438*b ;\n"
" y=0.858885*y + 0.0625;\n" " y=0.858885*y + 0.0625;\n" " u=u + 0.5;\n" " v=v + 0.5;\n"
" u=u + 0.5;\n"
" v=v + 0.5;\n"
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
" gl_FragColor=vec4(y,u,v,1.0);\n" " gl_FragColor=vec4(y,u,v,1.0);\n"
#else #else
@ -433,53 +406,50 @@ gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
"}\n"; "}\n";
#ifdef OPENGL_ES2 #ifdef OPENGL_ES2
display->redisplay_vertex_shader_str = display->redisplay_vertex_shader_str =
"attribute vec4 a_position; \n" "attribute vec4 a_position; \n"
"attribute vec2 a_texCoord; \n" "attribute vec2 a_texCoord; \n"
"varying vec2 v_texCoord; \n" "varying vec2 v_texCoord; \n"
"void main() \n" "void main() \n"
"{ \n" "{ \n"
" gl_Position = a_position; \n" " gl_Position = a_position; \n"
" v_texCoord = a_texCoord; \n" " v_texCoord = a_texCoord; \n" "} \n";
"} \n";
display->redisplay_fragment_shader_str =
display->redisplay_fragment_shader_str = "precision mediump float; \n"
"precision mediump float; \n" "varying vec2 v_texCoord; \n"
"varying vec2 v_texCoord; \n" "uniform sampler2D s_texture; \n"
"uniform sampler2D s_texture; \n" "void main() \n"
"void main() \n" "{ \n"
"{ \n" " gl_FragColor = texture2D( s_texture, v_texCoord );\n"
" gl_FragColor = texture2D( s_texture, v_texCoord );\n" "} \n";
"} \n";
display->text_vertex_shader_upload = display->text_vertex_shader_upload =
"attribute vec4 a_position; \n" "attribute vec4 a_position; \n"
"attribute vec2 a_texCoord; \n" "attribute vec2 a_texCoord; \n"
"varying vec2 v_texCoord; \n" "varying vec2 v_texCoord; \n"
"void main() \n" "void main() \n"
"{ \n" "{ \n"
" gl_Position = a_position; \n" " gl_Position = a_position; \n"
" v_texCoord = a_texCoord; \n" " v_texCoord = a_texCoord; \n" "} \n";
"} \n";
display->text_vertex_shader_download = display->text_vertex_shader_download =
"attribute vec4 a_position; \n" "attribute vec4 a_position; \n"
"attribute vec2 a_texCoord; \n" "attribute vec2 a_texCoord; \n"
"varying vec2 v_texCoord; \n" "varying vec2 v_texCoord; \n"
"void main() \n" "void main() \n"
"{ \n" "{ \n"
" gl_Position = a_position; \n" " gl_Position = a_position; \n"
" v_texCoord = a_texCoord; \n" " v_texCoord = a_texCoord; \n" "} \n";
"} \n";
display->text_fragment_shader_download_RGB = display->text_fragment_shader_download_RGB =
"precision mediump float; \n" "precision mediump float; \n"
"varying vec2 v_texCoord; \n" "varying vec2 v_texCoord; \n"
"uniform sampler2D s_texture; \n" "uniform sampler2D s_texture; \n"
"void main() \n" "void main() \n"
"{ \n" "{ \n"
" gl_FragColor = texture2D( s_texture, v_texCoord );\n" " gl_FragColor = texture2D( s_texture, v_texCoord );\n"
"} \n"; "} \n";
#endif #endif
} }
@ -742,7 +712,6 @@ gst_gl_display_thread_destroy_context (GstGLDisplay * display)
glDeleteTextures (1, &display->upload_intex_v); glDeleteTextures (1, &display->upload_intex_v);
display->upload_intex_v = 0; display->upload_intex_v = 0;
} }
#ifdef OPENGL_ES2 #ifdef OPENGL_ES2
if (display->redisplay_shader) { if (display->redisplay_shader) {
g_object_unref (G_OBJECT (display->redisplay_shader)); g_object_unref (G_OBJECT (display->redisplay_shader));
@ -793,10 +762,10 @@ gst_gl_display_thread_init_redisplay (GstGLDisplay * display)
GError *error = NULL; GError *error = NULL;
display->redisplay_shader = gst_gl_shader_new (); display->redisplay_shader = gst_gl_shader_new ();
gst_gl_shader_set_vertex_source(display->redisplay_shader, gst_gl_shader_set_vertex_source (display->redisplay_shader,
display->redisplay_vertex_shader_str); display->redisplay_vertex_shader_str);
gst_gl_shader_set_fragment_source(display->redisplay_shader, gst_gl_shader_set_fragment_source (display->redisplay_shader,
display->redisplay_fragment_shader_str); display->redisplay_fragment_shader_str);
gst_gl_shader_compile (display->redisplay_shader, &error); gst_gl_shader_compile (display->redisplay_shader, &error);
if (error) { if (error) {
@ -806,12 +775,12 @@ gst_gl_display_thread_init_redisplay (GstGLDisplay * display)
gst_gl_shader_use (NULL); gst_gl_shader_use (NULL);
display->isAlive = FALSE; display->isAlive = FALSE;
} else { } else {
display->redisplay_attr_position_loc = display->redisplay_attr_position_loc =
gst_gl_shader_get_attribute_location (display->redisplay_shader, gst_gl_shader_get_attribute_location (display->redisplay_shader,
"a_position"); "a_position");
display->redisplay_attr_texture_loc = display->redisplay_attr_texture_loc =
gst_gl_shader_get_attribute_location (display->redisplay_shader, gst_gl_shader_get_attribute_location (display->redisplay_shader,
"a_texCoord"); "a_texCoord");
} }
} }
#endif #endif
@ -878,10 +847,10 @@ gst_gl_display_thread_init_upload (GstGLDisplay * display)
display->shader_upload_YUY2 = NULL; display->shader_upload_YUY2 = NULL;
} }
#else #else
gst_gl_shader_set_vertex_source(display->shader_upload_YUY2, gst_gl_shader_set_vertex_source (display->shader_upload_YUY2,
display->text_vertex_shader_upload); display->text_vertex_shader_upload);
gst_gl_shader_set_fragment_source(display->shader_upload_YUY2, gst_gl_shader_set_fragment_source (display->shader_upload_YUY2,
text_shader_upload_YUY2); text_shader_upload_YUY2);
gst_gl_shader_compile (display->shader_upload_YUY2, &error); gst_gl_shader_compile (display->shader_upload_YUY2, &error);
if (error) { if (error) {
@ -893,12 +862,12 @@ gst_gl_display_thread_init_upload (GstGLDisplay * display)
g_object_unref (G_OBJECT (display->shader_upload_YUY2)); g_object_unref (G_OBJECT (display->shader_upload_YUY2));
display->shader_upload_YUY2 = NULL; display->shader_upload_YUY2 = NULL;
} else { } else {
display->shader_upload_attr_position_loc = display->shader_upload_attr_position_loc =
gst_gl_shader_get_attribute_location (display->shader_upload_YUY2, gst_gl_shader_get_attribute_location
"a_position"); (display->shader_upload_YUY2, "a_position");
display->shader_upload_attr_texture_loc = display->shader_upload_attr_texture_loc =
gst_gl_shader_get_attribute_location (display->shader_upload_YUY2, gst_gl_shader_get_attribute_location
"a_texCoord"); (display->shader_upload_YUY2, "a_texCoord");
} }
#endif #endif
} }
@ -923,10 +892,10 @@ gst_gl_display_thread_init_upload (GstGLDisplay * display)
display->shader_upload_UYVY = NULL; display->shader_upload_UYVY = NULL;
} }
#else #else
gst_gl_shader_set_vertex_source(display->shader_upload_UYVY, gst_gl_shader_set_vertex_source (display->shader_upload_UYVY,
display->text_vertex_shader_upload); display->text_vertex_shader_upload);
gst_gl_shader_set_fragment_source(display->shader_upload_UYVY, gst_gl_shader_set_fragment_source (display->shader_upload_UYVY,
text_shader_upload_UYVY); text_shader_upload_UYVY);
gst_gl_shader_compile (display->shader_upload_UYVY, &error); gst_gl_shader_compile (display->shader_upload_UYVY, &error);
if (error) { if (error) {
@ -938,12 +907,12 @@ gst_gl_display_thread_init_upload (GstGLDisplay * display)
g_object_unref (G_OBJECT (display->shader_upload_UYVY)); g_object_unref (G_OBJECT (display->shader_upload_UYVY));
display->shader_upload_UYVY = NULL; display->shader_upload_UYVY = NULL;
} else { } else {
display->shader_upload_attr_position_loc = display->shader_upload_attr_position_loc =
gst_gl_shader_get_attribute_location (display->shader_upload_UYVY, gst_gl_shader_get_attribute_location
"a_position"); (display->shader_upload_UYVY, "a_position");
display->shader_upload_attr_texture_loc = display->shader_upload_attr_texture_loc =
gst_gl_shader_get_attribute_location (display->shader_upload_UYVY, gst_gl_shader_get_attribute_location
"a_texCoord"); (display->shader_upload_UYVY, "a_texCoord");
} }
#endif #endif
} }
@ -973,10 +942,10 @@ gst_gl_display_thread_init_upload (GstGLDisplay * display)
display->shader_upload_I420_YV12 = NULL; display->shader_upload_I420_YV12 = NULL;
} }
#else #else
gst_gl_shader_set_vertex_source(display->shader_upload_I420_YV12, gst_gl_shader_set_vertex_source (display->shader_upload_I420_YV12,
display->text_vertex_shader_upload); display->text_vertex_shader_upload);
gst_gl_shader_set_fragment_source(display->shader_upload_I420_YV12, gst_gl_shader_set_fragment_source (display->shader_upload_I420_YV12,
display->text_shader_upload_I420_YV12); display->text_shader_upload_I420_YV12);
gst_gl_shader_compile (display->shader_upload_I420_YV12, &error); gst_gl_shader_compile (display->shader_upload_I420_YV12, &error);
if (error) { if (error) {
@ -988,12 +957,12 @@ gst_gl_display_thread_init_upload (GstGLDisplay * display)
g_object_unref (G_OBJECT (display->shader_upload_I420_YV12)); g_object_unref (G_OBJECT (display->shader_upload_I420_YV12));
display->shader_upload_I420_YV12 = NULL; display->shader_upload_I420_YV12 = NULL;
} else { } else {
display->shader_upload_attr_position_loc = display->shader_upload_attr_position_loc =
gst_gl_shader_get_attribute_location (display->shader_upload_I420_YV12, gst_gl_shader_get_attribute_location
"a_position"); (display->shader_upload_I420_YV12, "a_position");
display->shader_upload_attr_texture_loc = display->shader_upload_attr_texture_loc =
gst_gl_shader_get_attribute_location (display->shader_upload_I420_YV12, gst_gl_shader_get_attribute_location
"a_texCoord"); (display->shader_upload_I420_YV12, "a_texCoord");
} }
#endif #endif
} }
@ -1011,10 +980,10 @@ gst_gl_display_thread_init_upload (GstGLDisplay * display)
display->shader_upload_AYUV = NULL; display->shader_upload_AYUV = NULL;
} }
#else #else
gst_gl_shader_set_vertex_source(display->shader_upload_AYUV, gst_gl_shader_set_vertex_source (display->shader_upload_AYUV,
display->text_vertex_shader_upload); display->text_vertex_shader_upload);
gst_gl_shader_set_fragment_source(display->shader_upload_AYUV, gst_gl_shader_set_fragment_source (display->shader_upload_AYUV,
display->text_shader_upload_AYUV); display->text_shader_upload_AYUV);
gst_gl_shader_compile (display->shader_upload_AYUV, &error); gst_gl_shader_compile (display->shader_upload_AYUV, &error);
if (error) { if (error) {
@ -1026,12 +995,12 @@ gst_gl_display_thread_init_upload (GstGLDisplay * display)
g_object_unref (G_OBJECT (display->shader_upload_AYUV)); g_object_unref (G_OBJECT (display->shader_upload_AYUV));
display->shader_upload_AYUV = NULL; display->shader_upload_AYUV = NULL;
} else { } else {
display->shader_upload_attr_position_loc = display->shader_upload_attr_position_loc =
gst_gl_shader_get_attribute_location (display->shader_upload_AYUV, gst_gl_shader_get_attribute_location
"a_position"); (display->shader_upload_AYUV, "a_position");
display->shader_upload_attr_texture_loc = display->shader_upload_attr_texture_loc =
gst_gl_shader_get_attribute_location (display->shader_upload_AYUV, gst_gl_shader_get_attribute_location
"a_texCoord"); (display->shader_upload_AYUV, "a_texCoord");
} }
#endif #endif
} }
@ -1320,10 +1289,10 @@ gst_gl_display_thread_init_download (GstGLDisplay * display)
GError *error = NULL; GError *error = NULL;
display->shader_download_RGB = gst_gl_shader_new (); display->shader_download_RGB = gst_gl_shader_new ();
gst_gl_shader_set_vertex_source(display->shader_download_RGB, gst_gl_shader_set_vertex_source (display->shader_download_RGB,
display->text_vertex_shader_download); display->text_vertex_shader_download);
gst_gl_shader_set_fragment_source(display->shader_download_RGB, gst_gl_shader_set_fragment_source (display->shader_download_RGB,
display->text_fragment_shader_download_RGB); display->text_fragment_shader_download_RGB);
gst_gl_shader_compile (display->shader_download_RGB, &error); gst_gl_shader_compile (display->shader_download_RGB, &error);
if (error) { if (error) {
@ -1335,12 +1304,12 @@ gst_gl_display_thread_init_download (GstGLDisplay * display)
g_object_unref (G_OBJECT (display->shader_download_RGB)); g_object_unref (G_OBJECT (display->shader_download_RGB));
display->shader_download_RGB = NULL; display->shader_download_RGB = NULL;
} else { } else {
display->shader_download_attr_position_loc = display->shader_download_attr_position_loc =
gst_gl_shader_get_attribute_location (display->shader_download_RGB, gst_gl_shader_get_attribute_location (display->shader_download_RGB,
"a_position"); "a_position");
display->shader_download_attr_texture_loc = display->shader_download_attr_texture_loc =
gst_gl_shader_get_attribute_location (display->shader_download_RGB, gst_gl_shader_get_attribute_location (display->shader_download_RGB,
"a_texCoord"); "a_texCoord");
} }
} }
#endif #endif
@ -1376,10 +1345,10 @@ gst_gl_display_thread_init_download (GstGLDisplay * display)
display->shader_download_YUY2 = NULL; display->shader_download_YUY2 = NULL;
} }
#else #else
gst_gl_shader_set_vertex_source(display->shader_download_YUY2, gst_gl_shader_set_vertex_source (display->shader_download_YUY2,
display->text_vertex_shader_download); display->text_vertex_shader_download);
gst_gl_shader_set_fragment_source(display->shader_download_YUY2, gst_gl_shader_set_fragment_source (display->shader_download_YUY2,
text_shader_download_YUY2); text_shader_download_YUY2);
gst_gl_shader_compile (display->shader_download_YUY2, &error); gst_gl_shader_compile (display->shader_download_YUY2, &error);
if (error) { if (error) {
@ -1391,12 +1360,12 @@ gst_gl_display_thread_init_download (GstGLDisplay * display)
g_object_unref (G_OBJECT (display->shader_download_YUY2)); g_object_unref (G_OBJECT (display->shader_download_YUY2));
display->shader_download_YUY2 = NULL; display->shader_download_YUY2 = NULL;
} else { } else {
display->shader_download_attr_position_loc = display->shader_download_attr_position_loc =
gst_gl_shader_get_attribute_location (display->shader_download_YUY2, gst_gl_shader_get_attribute_location
"a_position"); (display->shader_download_YUY2, "a_position");
display->shader_download_attr_texture_loc = display->shader_download_attr_texture_loc =
gst_gl_shader_get_attribute_location (display->shader_download_YUY2, gst_gl_shader_get_attribute_location
"a_texCoord"); (display->shader_download_YUY2, "a_texCoord");
} }
#endif #endif
} }
@ -1417,10 +1386,10 @@ gst_gl_display_thread_init_download (GstGLDisplay * display)
display->shader_download_UYVY = NULL; display->shader_download_UYVY = NULL;
} }
#else #else
gst_gl_shader_set_vertex_source(display->shader_download_UYVY, gst_gl_shader_set_vertex_source (display->shader_download_UYVY,
display->text_vertex_shader_download); display->text_vertex_shader_download);
gst_gl_shader_set_fragment_source(display->shader_download_UYVY, gst_gl_shader_set_fragment_source (display->shader_download_UYVY,
text_shader_download_UYVY); text_shader_download_UYVY);
gst_gl_shader_compile (display->shader_download_UYVY, &error); gst_gl_shader_compile (display->shader_download_UYVY, &error);
if (error) { if (error) {
@ -1432,12 +1401,12 @@ gst_gl_display_thread_init_download (GstGLDisplay * display)
g_object_unref (G_OBJECT (display->shader_download_UYVY)); g_object_unref (G_OBJECT (display->shader_download_UYVY));
display->shader_download_UYVY = NULL; display->shader_download_UYVY = NULL;
} else { } else {
display->shader_download_attr_position_loc = display->shader_download_attr_position_loc =
gst_gl_shader_get_attribute_location (display->shader_download_UYVY, gst_gl_shader_get_attribute_location
"a_position"); (display->shader_download_UYVY, "a_position");
display->shader_download_attr_texture_loc = display->shader_download_attr_texture_loc =
gst_gl_shader_get_attribute_location (display->shader_download_UYVY, gst_gl_shader_get_attribute_location
"a_texCoord"); (display->shader_download_UYVY, "a_texCoord");
} }
#endif #endif
@ -1467,10 +1436,10 @@ gst_gl_display_thread_init_download (GstGLDisplay * display)
display->shader_download_AYUV = NULL; display->shader_download_AYUV = NULL;
} }
#else #else
gst_gl_shader_set_vertex_source(display->shader_download_AYUV, gst_gl_shader_set_vertex_source (display->shader_download_AYUV,
display->text_vertex_shader_download); display->text_vertex_shader_download);
gst_gl_shader_set_fragment_source(display->shader_download_AYUV, gst_gl_shader_set_fragment_source (display->shader_download_AYUV,
display->text_shader_download_AYUV); display->text_shader_download_AYUV);
gst_gl_shader_compile (display->shader_download_AYUV, &error); gst_gl_shader_compile (display->shader_download_AYUV, &error);
if (error) { if (error) {
@ -1482,12 +1451,12 @@ gst_gl_display_thread_init_download (GstGLDisplay * display)
g_object_unref (G_OBJECT (display->shader_download_AYUV)); g_object_unref (G_OBJECT (display->shader_download_AYUV));
display->shader_download_AYUV = NULL; display->shader_download_AYUV = NULL;
} else { } else {
display->shader_download_attr_position_loc = display->shader_download_attr_position_loc =
gst_gl_shader_get_attribute_location (display->shader_download_AYUV, gst_gl_shader_get_attribute_location
"a_position"); (display->shader_download_AYUV, "a_position");
display->shader_download_attr_texture_loc = display->shader_download_attr_texture_loc =
gst_gl_shader_get_attribute_location (display->shader_download_AYUV, gst_gl_shader_get_attribute_location
"a_texCoord"); (display->shader_download_AYUV, "a_texCoord");
} }
#endif #endif
break; break;
@ -1570,6 +1539,12 @@ gst_gl_display_thread_gen_fbo (GstGLDisplay * display)
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
display->gen_fbo_width, display->gen_fbo_height, 0, GL_RGBA, display->gen_fbo_width, display->gen_fbo_height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, NULL); GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
//attach the texture to the FBO to renderer to //attach the texture to the FBO to renderer to
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
@ -1633,7 +1608,7 @@ gst_gl_display_thread_use_fbo (GstGLDisplay * display)
glPushMatrix (); glPushMatrix ();
glLoadIdentity (); glLoadIdentity ();
#else // OPENGL_ES2 #else // OPENGL_ES2
glGetIntegerv(GL_VIEWPORT, viewport_dim); glGetIntegerv (GL_VIEWPORT, viewport_dim);
#endif #endif
glViewport (0, 0, display->use_fbo_width, display->use_fbo_height); glViewport (0, 0, display->use_fbo_width, display->use_fbo_height);
@ -1658,7 +1633,8 @@ gst_gl_display_thread_use_fbo (GstGLDisplay * display)
glPopMatrix (); glPopMatrix ();
glPopAttrib (); glPopAttrib ();
#else #else
glViewport(viewport_dim[0], viewport_dim[1], viewport_dim[2], viewport_dim[3]); glViewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
viewport_dim[3]);
#endif #endif
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0); glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
@ -1831,15 +1807,15 @@ gst_gl_display_on_draw (GstGLDisplay * display)
#else //OPENGL_ES2 #else //OPENGL_ES2
const GLfloat vVertices [] = const GLfloat vVertices[] = { 1.0f, 1.0f, 0.0f,
{1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
1.0f, 0.0f, -1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f,
-1.0f, -1.0f, 0.0f, -1.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f, 1.0f,
1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f,
1.0f, 1.0f}; 1.0f, 1.0f
};
GLushort indices[] = { 0, 1, 2, 0, 2, 3 }; GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
@ -1848,12 +1824,12 @@ gst_gl_display_on_draw (GstGLDisplay * display)
gst_gl_shader_use (display->redisplay_shader); gst_gl_shader_use (display->redisplay_shader);
//Load the vertex position //Load the vertex position
glVertexAttribPointer (display->redisplay_attr_position_loc, 3, GL_FLOAT, glVertexAttribPointer (display->redisplay_attr_position_loc, 3, GL_FLOAT,
GL_FALSE, 5 * sizeof(GLfloat), vVertices); GL_FALSE, 5 * sizeof (GLfloat), vVertices);
//Load the texture coordinate //Load the texture coordinate
glVertexAttribPointer (display->redisplay_attr_texture_loc, 2, GL_FLOAT, glVertexAttribPointer (display->redisplay_attr_texture_loc, 2, GL_FLOAT,
GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3]); GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
glEnableVertexAttribArray (display->redisplay_attr_position_loc); glEnableVertexAttribArray (display->redisplay_attr_position_loc);
glEnableVertexAttribArray (display->redisplay_attr_texture_loc); glEnableVertexAttribArray (display->redisplay_attr_texture_loc);
@ -1865,7 +1841,7 @@ gst_gl_display_on_draw (GstGLDisplay * display)
glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices); glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
#endif #endif
}//end default opengl scene } //end default opengl scene
} }
@ -2046,7 +2022,19 @@ gst_gl_display_check_framebuffer_status (void)
break; break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT: case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
GST_ERROR ("GL_FRAMEBUFFER_UNSUPPORTED_EXT"); GST_ERROR ("GL_FRAMEBUFFER_UNSUPPORTED");
break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
break;
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
break; break;
default: default:
@ -2109,7 +2097,7 @@ gst_gl_display_redisplay (GstGLDisplay * display, GLuint texture, gint width,
#ifdef OPENGL_ES2 #ifdef OPENGL_ES2
if (!display->redisplay_shader) { if (!display->redisplay_shader) {
gst_gl_window_send_message (display->gl_window, gst_gl_window_send_message (display->gl_window,
GST_GL_WINDOW_CB (gst_gl_display_thread_init_redisplay), display); GST_GL_WINDOW_CB (gst_gl_display_thread_init_redisplay), display);
} }
#endif #endif
@ -2420,6 +2408,14 @@ gst_gl_display_thread_init_upload_fbo (GstGLDisplay * display)
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
display->upload_width, display->upload_height, 0, GL_RGBA, display->upload_width, display->upload_height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, NULL); GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
//attach the texture to the FBO to renderer to //attach the texture to the FBO to renderer to
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
@ -2699,15 +2695,15 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay * display)
#ifdef OPENGL_ES2 #ifdef OPENGL_ES2
GLint viewport_dim[4]; GLint viewport_dim[4];
const GLfloat vVertices [] = const GLfloat vVertices[] = { 1.0f, -1.0f, 0.0f,
{1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
1.0f, 0.0f, -1.0f, -1.0f, 0.0f,
-1.0f, -1.0f, 0.0f, 0.0f, .0f,
0.0f, .0f, -1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f, 1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f
1.0f, 1.0f}; };
GLushort indices[] = { 0, 1, 2, 0, 2, 3 }; GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
#endif #endif
@ -2737,13 +2733,13 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay * display)
glPushMatrix (); glPushMatrix ();
glLoadIdentity (); glLoadIdentity ();
#else // OPENGL_ES2 #else // OPENGL_ES2
glGetIntegerv(GL_VIEWPORT, viewport_dim); glGetIntegerv (GL_VIEWPORT, viewport_dim);
#endif #endif
glViewport (0, 0, display->upload_width, display->upload_height); glViewport (0, 0, display->upload_width, display->upload_height);
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT);
#endif #endif
glClearColor (0.0, 0.0, 0.0, 0.0); glClearColor (0.0, 0.0, 0.0, 0.0);
@ -2766,9 +2762,9 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay * display)
glLoadIdentity (); glLoadIdentity ();
#else #else
glVertexAttribPointer (display->shader_upload_attr_position_loc, 3, glVertexAttribPointer (display->shader_upload_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), vVertices); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
glVertexAttribPointer (display->shader_upload_attr_texture_loc, 2, glVertexAttribPointer (display->shader_upload_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3]); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
glEnableVertexAttribArray (display->shader_upload_attr_position_loc); glEnableVertexAttribArray (display->shader_upload_attr_position_loc);
glEnableVertexAttribArray (display->shader_upload_attr_texture_loc); glEnableVertexAttribArray (display->shader_upload_attr_texture_loc);
@ -2814,9 +2810,9 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay * display)
glLoadIdentity (); glLoadIdentity ();
#else #else
glVertexAttribPointer (display->shader_upload_attr_position_loc, 3, glVertexAttribPointer (display->shader_upload_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), vVertices); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
glVertexAttribPointer (display->shader_upload_attr_texture_loc, 2, glVertexAttribPointer (display->shader_upload_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3]); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
glEnableVertexAttribArray (display->shader_upload_attr_position_loc); glEnableVertexAttribArray (display->shader_upload_attr_position_loc);
glEnableVertexAttribArray (display->shader_upload_attr_texture_loc); glEnableVertexAttribArray (display->shader_upload_attr_texture_loc);
@ -2884,9 +2880,9 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay * display)
glLoadIdentity (); glLoadIdentity ();
#else #else
glVertexAttribPointer (display->shader_upload_attr_position_loc, 3, glVertexAttribPointer (display->shader_upload_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), vVertices); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
glVertexAttribPointer (display->shader_upload_attr_texture_loc, 2, glVertexAttribPointer (display->shader_upload_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3]); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
glEnableVertexAttribArray (display->shader_upload_attr_position_loc); glEnableVertexAttribArray (display->shader_upload_attr_position_loc);
glEnableVertexAttribArray (display->shader_upload_attr_texture_loc); glEnableVertexAttribArray (display->shader_upload_attr_texture_loc);
@ -2942,9 +2938,9 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay * display)
glLoadIdentity (); glLoadIdentity ();
#else #else
glVertexAttribPointer (display->shader_upload_attr_position_loc, 3, glVertexAttribPointer (display->shader_upload_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), vVertices); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
glVertexAttribPointer (display->shader_upload_attr_texture_loc, 2, glVertexAttribPointer (display->shader_upload_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3]); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
glEnableVertexAttribArray (display->shader_upload_attr_position_loc); glEnableVertexAttribArray (display->shader_upload_attr_position_loc);
glEnableVertexAttribArray (display->shader_upload_attr_texture_loc); glEnableVertexAttribArray (display->shader_upload_attr_texture_loc);
@ -2999,7 +2995,8 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay * display)
glPopMatrix (); glPopMatrix ();
glPopAttrib (); glPopAttrib ();
#else #else
glViewport(viewport_dim[0], viewport_dim[1], viewport_dim[2], viewport_dim[3]); glViewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
viewport_dim[3]);
#endif #endif
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0); glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
@ -3022,15 +3019,15 @@ gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay * display)
gint width = display->ouput_texture_width; gint width = display->ouput_texture_width;
gint height = display->ouput_texture_height; gint height = display->ouput_texture_height;
const GLfloat vVertices [] = const GLfloat vVertices[] = { 1.0f, -1.0f, 0.0f,
{1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
1.0f, 0.0f, -1.0f, -1.0f, 0.0f,
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, -1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f, 1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f
1.0f, 1.0f}; };
GLushort indices[] = { 0, 1, 2, 0, 2, 3 }; GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
@ -3042,9 +3039,9 @@ gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay * display)
gst_gl_shader_use (display->shader_download_RGB); gst_gl_shader_use (display->shader_download_RGB);
glVertexAttribPointer (display->shader_download_attr_position_loc, 3, glVertexAttribPointer (display->shader_download_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), vVertices); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
glVertexAttribPointer (display->shader_download_attr_texture_loc, 2, glVertexAttribPointer (display->shader_download_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3]); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
glEnableVertexAttribArray (display->shader_download_attr_position_loc); glEnableVertexAttribArray (display->shader_download_attr_position_loc);
glEnableVertexAttribArray (display->shader_download_attr_texture_loc); glEnableVertexAttribArray (display->shader_download_attr_texture_loc);
@ -3070,8 +3067,7 @@ gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay * display)
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
GL_UNSIGNED_BYTE, data); GL_UNSIGNED_BYTE, data);
#else #else
glReadPixels (0, 0, width, height, GL_RGBA, glReadPixels (0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
GL_UNSIGNED_BYTE, data);
#endif #endif
break; break;
case GST_VIDEO_FORMAT_BGRx: case GST_VIDEO_FORMAT_BGRx:
@ -3088,8 +3084,7 @@ gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay * display)
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
GL_UNSIGNED_BYTE, data); GL_UNSIGNED_BYTE, data);
#else #else
glReadPixels (0, 0, width, height, GL_RGB, glReadPixels (0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data);
GL_UNSIGNED_BYTE, data);
#endif #endif
break; break;
case GST_VIDEO_FORMAT_BGR: case GST_VIDEO_FORMAT_BGR:
@ -3116,15 +3111,15 @@ gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay * display)
#ifdef OPENGL_ES2 #ifdef OPENGL_ES2
GLint viewport_dim[4]; GLint viewport_dim[4];
const GLfloat vVertices [] = const GLfloat vVertices[] = { 1.0f, -1.0f, 0.0f,
{1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
1.0f, 0.0f, -1.0f, -1.0f, 0.0f,
-1.0f, -1.0f, 0.0f, 0.0f, .0f,
0.0f, .0f, -1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f, 1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f
1.0f, 1.0f}; };
GLushort indices[] = { 0, 1, 2, 0, 2, 3 }; GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
#endif #endif
@ -3143,7 +3138,7 @@ gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay * display)
glPushMatrix (); glPushMatrix ();
glLoadIdentity (); glLoadIdentity ();
#else // OPENGL_ES2 #else // OPENGL_ES2
glGetIntegerv(GL_VIEWPORT, viewport_dim); glGetIntegerv (GL_VIEWPORT, viewport_dim);
#endif #endif
glViewport (0, 0, width, height); glViewport (0, 0, width, height);
@ -3178,9 +3173,9 @@ gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay * display)
glLoadIdentity (); glLoadIdentity ();
#else #else
glVertexAttribPointer (display->shader_download_attr_position_loc, 3, glVertexAttribPointer (display->shader_download_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), vVertices); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
glVertexAttribPointer (display->shader_download_attr_texture_loc, 2, glVertexAttribPointer (display->shader_download_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3]); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
glEnableVertexAttribArray (display->shader_download_attr_position_loc); glEnableVertexAttribArray (display->shader_download_attr_position_loc);
glEnableVertexAttribArray (display->shader_download_attr_texture_loc); glEnableVertexAttribArray (display->shader_download_attr_texture_loc);
@ -3236,9 +3231,9 @@ gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay * display)
glLoadIdentity (); glLoadIdentity ();
#else #else
glVertexAttribPointer (display->shader_download_attr_position_loc, 3, glVertexAttribPointer (display->shader_download_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), vVertices); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
glVertexAttribPointer (display->shader_download_attr_texture_loc, 2, glVertexAttribPointer (display->shader_download_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3]); GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
glEnableVertexAttribArray (display->shader_download_attr_position_loc); glEnableVertexAttribArray (display->shader_download_attr_position_loc);
glEnableVertexAttribArray (display->shader_download_attr_texture_loc); glEnableVertexAttribArray (display->shader_download_attr_texture_loc);
@ -3286,7 +3281,8 @@ gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay * display)
glPopMatrix (); glPopMatrix ();
glPopAttrib (); glPopAttrib ();
#else #else
glViewport(viewport_dim[0], viewport_dim[1], viewport_dim[2], viewport_dim[3]); glViewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
viewport_dim[3]);
#endif #endif
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0); glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);