[838/906] gl: Use GL_TEXTURE_2D instead of GL_TEXTURE_RECTANGLE

We create our textures (in Desktop GL) with GL_TEXTURE_RECTANGLE,
vaapi attempts to bind our texture to GL_TEXTURE_2D which throws a
GL_INVALID_OPERATION error and as thus, no video.

Also, by moving exclusively to GL_TEXTURE_2D and the npot extension
we also remove a difference between the Desktop GL and GLES2 code.

https://bugzilla.gnome.org/show_bug.cgi?id=712287
This commit is contained in:
Matthew Waters 2013-11-15 18:28:49 +11:00 committed by Tim-Philipp Müller
parent 32265d7e4e
commit efa22442a9
8 changed files with 178 additions and 231 deletions

View file

@ -74,16 +74,16 @@ static void _do_download_draw_yuv_gles2 (GstGLContext * context,
/* YUY2:y2,u,y1,v
UYVY:v,y1,u,y2 */
static const gchar *text_shader_YUY2_UYVY_opengl =
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;\n"
"uniform sampler2D tex;\n"
"uniform float width;\n"
RGB_TO_YUV_COEFFICIENTS
"void main(void) {\n"
" vec3 rgb1, rgb2;\n"
" float fx,fy,y1,y2,u,v;\n"
" fx = gl_TexCoord[0].x;\n"
" fy = gl_TexCoord[0].y;\n"
" rgb1=texture2DRect(tex,vec2(fx*2.0,fy)).rgb;\n"
" rgb2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).rgb;\n"
" rgb1=texture2D(tex,vec2(fx*2.0,fy)).rgb;\n"
" rgb2=texture2D(tex,vec2(fx*2.0+1.0/width,fy)).rgb;\n"
" y1=dot(rgb1, ycoeff);\n"
" y2=dot(rgb2, ycoeff);\n"
" u=dot(rgb1, ucoeff);\n"
@ -96,8 +96,7 @@ static const gchar *text_shader_YUY2_UYVY_opengl =
"}\n";
static const gchar *text_shader_I420_YV12_opengl =
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;\n"
"uniform sampler2D tex;\n"
"uniform float w, h;\n"
RGB_TO_YUV_COEFFICIENTS
"void main(void) {\n"
@ -105,8 +104,8 @@ static const gchar *text_shader_I420_YV12_opengl =
" float y,u,v;\n"
" vec2 nxy=gl_TexCoord[0].xy;\n"
" vec2 nxy2=nxy*2.0;\n"
" rgb1=texture2DRect(tex,nxy).rgb;\n"
" rgb2=texture2DRect(tex,nxy2).rgb;\n"
" rgb1=texture2D(tex,nxy).rgb;\n"
" rgb2=texture2D(tex,nxy2).rgb;\n"
" y=dot(rgb1, ycoeff);\n"
" u=dot(rgb2, ucoeff);\n"
" v=dot(rgb2, vcoeff);\n"
@ -119,14 +118,13 @@ static const gchar *text_shader_I420_YV12_opengl =
"}\n";
static const gchar *text_shader_AYUV_opengl =
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;\n"
"uniform sampler2D tex;\n"
RGB_TO_YUV_COEFFICIENTS
"void main(void) {\n"
" vec3 rgb;\n"
" float y,u,v;\n"
" vec2 nxy=gl_TexCoord[0].xy;\n"
" rgb=texture2DRect(tex,nxy).rgb;\n"
" rgb=texture2D(tex,nxy).rgb;\n"
" y=dot(rgb, ycoeff);\n"
" u=dot(rgb, ucoeff);\n"
" v=dot(rgb, vcoeff);\n"
@ -591,61 +589,47 @@ _init_download (GstGLContext * context, GstGLDownload * download)
/* setup a first texture to render to */
gl->GenTextures (1, &download->out_texture[0]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->out_texture[0]);
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
gl->BindTexture (GL_TEXTURE_2D, download->out_texture[0]);
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
out_width, out_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
/* attach the first texture to the FBO to renderer to */
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_RECTANGLE_ARB, download->out_texture[0], 0);
GL_TEXTURE_2D, download->out_texture[0], 0);
if (v_format == GST_VIDEO_FORMAT_I420 ||
v_format == GST_VIDEO_FORMAT_YV12) {
/* setup a second texture to render to */
gl->GenTextures (1, &download->out_texture[1]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->out_texture[1]);
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
gl->BindTexture (GL_TEXTURE_2D, download->out_texture[1]);
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
out_width, out_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
/* attach the second texture to the FBO to renderer to */
gl->FramebufferTexture2D (GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT1, GL_TEXTURE_RECTANGLE_ARB,
download->out_texture[1], 0);
GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, download->out_texture[1], 0);
/* setup a third texture to render to */
gl->GenTextures (1, &download->out_texture[2]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->out_texture[2]);
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
gl->BindTexture (GL_TEXTURE_2D, download->out_texture[2]);
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
out_width, out_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
/* attach the third texture to the FBO to renderer to */
gl->FramebufferTexture2D (GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT2, GL_TEXTURE_RECTANGLE_ARB,
download->out_texture[2], 0);
GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, download->out_texture[2], 0);
}
/* attach the depth render buffer to the FBO */
@ -931,48 +915,48 @@ _do_download_draw_rgb_opengl (GstGLContext * context, GstGLDownload * download)
gst_gl_context_clear_shader (context);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, download->in_texture);
v_format = GST_VIDEO_INFO_FORMAT (&download->info);
switch (v_format) {
case GST_VIDEO_FORMAT_RGBA:
case GST_VIDEO_FORMAT_RGBx:
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
gl->GetTexImage (GL_TEXTURE_2D, 0, GL_RGBA,
GL_UNSIGNED_BYTE, download->data[0]);
break;
case GST_VIDEO_FORMAT_xRGB:
case GST_VIDEO_FORMAT_ARGB:
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,
gl->GetTexImage (GL_TEXTURE_2D, 0, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8, download->data[0]);
#else
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,
gl->GetTexImage (GL_TEXTURE_2D, 0, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV, download->data[0]);
#endif /* G_BYTE_ORDER */
break;
case GST_VIDEO_FORMAT_BGRx:
case GST_VIDEO_FORMAT_BGRA:
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,
gl->GetTexImage (GL_TEXTURE_2D, 0, GL_BGRA,
GL_UNSIGNED_BYTE, download->data[0]);
break;
case GST_VIDEO_FORMAT_xBGR:
case GST_VIDEO_FORMAT_ABGR:
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
gl->GetTexImage (GL_TEXTURE_2D, 0, GL_RGBA,
GL_UNSIGNED_INT_8_8_8_8, download->data[0]);
#else
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
glGetTexImage (GL_TEXTURE_2D, 0, GL_RGBA,
GL_UNSIGNED_INT_8_8_8_8_REV, download->data[0]);
#endif /* G_BYTE_ORDER */
break;
case GST_VIDEO_FORMAT_RGB:
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
gl->GetTexImage (GL_TEXTURE_2D, 0, GL_RGB,
GL_UNSIGNED_BYTE, download->data[0]);
break;
case GST_VIDEO_FORMAT_BGR:
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGR,
gl->GetTexImage (GL_TEXTURE_2D, 0, GL_BGR,
GL_UNSIGNED_BYTE, download->data[0]);
break;
default:
@ -982,7 +966,7 @@ _do_download_draw_rgb_opengl (GstGLContext * context, GstGLDownload * download)
break;
}
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gl->Disable (GL_TEXTURE_2D);
}
#endif
@ -1036,7 +1020,7 @@ _do_download_draw_rgb_gles2 (GstGLContext * context, GstGLDownload * download)
gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (download->shader, "tex", 0);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
gl->BindTexture (GL_TEXTURE_2D, download->in_texture);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
@ -1096,10 +1080,10 @@ _do_download_draw_yuv_opengl (GstGLContext * context, GstGLDownload * download)
-1.0f, 1.0f,
1.0f, 1.0f
};
gfloat texcoords[8] = { out_width, 0.0,
gfloat texcoords[8] = { 1.0, 0.0,
0.0, 0.0,
0.0, out_height,
out_width, out_height
0.0, 1.0,
1.0, 1.0
};
gl = context->gl_vtable;
@ -1141,7 +1125,8 @@ _do_download_draw_yuv_opengl (GstGLContext * context, GstGLDownload * download)
gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (download->shader, "tex", 0);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
gst_gl_shader_set_uniform_1f (download->shader, "width", out_width);
gl->BindTexture (GL_TEXTURE_2D, download->in_texture);
}
break;
@ -1162,7 +1147,7 @@ _do_download_draw_yuv_opengl (GstGLContext * context, GstGLDownload * download)
gst_gl_shader_set_uniform_1i (download->shader, "tex", 0);
gst_gl_shader_set_uniform_1f (download->shader, "w", (gfloat) out_width);
gst_gl_shader_set_uniform_1f (download->shader, "h", (gfloat) out_height);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
gl->BindTexture (GL_TEXTURE_2D, download->in_texture);
}
break;
@ -1193,7 +1178,7 @@ _do_download_draw_yuv_opengl (GstGLContext * context, GstGLDownload * download)
*/
gl->UseProgramObject (0);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gl->Disable (GL_TEXTURE_2D);
gl->MatrixMode (GL_PROJECTION);
gl->PopMatrix ();
gl->MatrixMode (GL_MODELVIEW);
@ -1333,7 +1318,7 @@ _do_download_draw_yuv_gles2 (GstGLContext * context, GstGLDownload * download)
gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (download->shader, "tex", 0);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
gl->BindTexture (GL_TEXTURE_2D, download->in_texture);
}
break;
@ -1349,7 +1334,7 @@ _do_download_draw_yuv_gles2 (GstGLContext * context, GstGLDownload * download)
gst_gl_shader_set_uniform_1i (download->shader, "tex", 0);
gst_gl_shader_set_uniform_1f (download->shader, "w", (gfloat) out_width);
gst_gl_shader_set_uniform_1f (download->shader, "h", (gfloat) out_height);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
gl->BindTexture (GL_TEXTURE_2D, download->in_texture);
}
break;

View file

@ -37,8 +37,6 @@ G_BEGIN_DECLS
#define GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_BYTE
//END FIXME
#define GL_TEXTURE_RECTANGLE_ARB GL_TEXTURE_2D
/* UNSUPPORTED */
#define GL_YCBCR_MESA 0

View file

@ -1127,11 +1127,13 @@ _draw_with_shader_cb (gint width, gint height, guint texture, gpointer stuff)
gst_gl_shader_use (filter->default_shader);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, texture);
gl->Disable (GL_TEXTURE_2D);
gst_gl_shader_set_uniform_1i (filter->default_shader, "tex", 1);
gst_gl_shader_set_uniform_1f (filter->default_shader, "width", width);
gst_gl_shader_set_uniform_1f (filter->default_shader, "height", height);
gst_gl_filter_draw_texture (filter, texture, width, height);
}
@ -1184,17 +1186,17 @@ gst_gl_filter_draw_texture (GstGLFilter * filter, GLuint texture,
1.0f, 1.0f,
-1.0f, 1.0f
};
GLfloat texcoords[] = { 0, 0,
width, 0,
width, height,
0, height
GLfloat texcoords[] = { 0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f
};
GST_DEBUG ("drawing texture:%u dimensions:%ux%u", texture, width, height);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, texture);
gl->ClientActiveTexture (GL_TEXTURE0);

View file

@ -125,21 +125,17 @@ gst_gl_framebuffer_generate (GstGLFramebuffer * frame, gint width, gint height,
/* setup a texture to render to */
gl->GenTextures (1, &fake_texture);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, fake_texture);
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
gl->BindTexture (GL_TEXTURE_2D, fake_texture);
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
/* attach the texture to the FBO to renderer to */
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_RECTANGLE_ARB, fake_texture, 0);
GL_TEXTURE_2D, fake_texture, 0);
/* attach the depth render buffer to the FBO */
gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
@ -194,11 +190,11 @@ gst_gl_framebuffer_use (GstGLFramebuffer * frame, gint texture_fbo_width,
gl->BindFramebuffer (GL_FRAMEBUFFER, fbo);
/*setup a texture to render to */
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture_fbo);
gl->BindTexture (GL_TEXTURE_2D, texture_fbo);
/* attach the texture to the FBO to renderer to */
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_RECTANGLE_ARB, texture_fbo, 0);
GL_TEXTURE_2D, texture_fbo, 0);
gst_gl_context_clear_shader (frame->context);
@ -290,11 +286,11 @@ gst_gl_framebuffer_use_v2 (GstGLFramebuffer * frame, gint texture_fbo_width,
gl->BindFramebuffer (GL_FRAMEBUFFER, fbo);
/* setup a texture to render to */
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture_fbo);
gl->BindTexture (GL_TEXTURE_2D, texture_fbo);
/* attach the texture to the FBO to renderer to */
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_RECTANGLE_ARB, texture_fbo, 0);
GL_TEXTURE_2D, texture_fbo, 0);
gl->GetIntegerv (GL_VIEWPORT, viewport_dim);

View file

@ -261,17 +261,16 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data)
}
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_RECTANGLE_ARB, src->tex_id, 0);
GL_TEXTURE_2D, src->tex_id, 0);
/* check FBO status */
if (!gst_gl_context_check_framebuffer_status (src->context))
goto fbo_error;
/* copy tex */
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, tex_id);
gl->CopyTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, gl_format, 0, 0,
width, height, 0);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
gl->BindTexture (GL_TEXTURE_2D, tex_id);
gl->CopyTexImage2D (GL_TEXTURE_2D, 0, gl_format, 0, 0, width, height, 0);
gl->BindTexture (GL_TEXTURE_2D, 0);
gl->BindFramebuffer (GL_FRAMEBUFFER, 0);

View file

@ -71,8 +71,7 @@ static gboolean _do_upload_draw_gles2 (GstGLContext * context,
#if GST_GL_HAVE_OPENGL
static const char *frag_AYUV_opengl = {
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;\n"
"uniform sampler2D tex;\n"
"uniform vec2 tex_scale0;\n"
"uniform vec2 tex_scale1;\n"
"uniform vec2 tex_scale2;\n"
@ -80,7 +79,7 @@ static const char *frag_AYUV_opengl = {
"void main(void) {\n"
" float r,g,b;\n"
" vec3 yuv;\n"
" yuv = texture2DRect(tex, gl_TexCoord[0].xy * tex_scale0).gba;\n"
" yuv = texture2D(tex, gl_TexCoord[0].xy * tex_scale0).gba;\n"
" yuv += offset;\n"
" r = dot(yuv, rcoeff);\n"
" g = dot(yuv, gcoeff);\n"
@ -91,8 +90,7 @@ static const char *frag_AYUV_opengl = {
/** YUV to RGB conversion */
static const char *frag_PLANAR_YUV_opengl = {
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect Ytex,Utex,Vtex;\n"
"uniform sampler2D Ytex,Utex,Vtex;\n"
"uniform vec2 tex_scale0;\n"
"uniform vec2 tex_scale1;\n"
"uniform vec2 tex_scale2;\n"
@ -100,9 +98,9 @@ static const char *frag_PLANAR_YUV_opengl = {
"void main(void) {\n"
" float r,g,b;\n"
" vec3 yuv;\n"
" yuv.x=texture2DRect(Ytex, gl_TexCoord[0].xy * tex_scale0).r;\n"
" yuv.y=texture2DRect(Utex, gl_TexCoord[0].xy * tex_scale1).r;\n"
" yuv.z=texture2DRect(Vtex, gl_TexCoord[0].xy * tex_scale2).r;\n"
" yuv.x=texture2D(Ytex, gl_TexCoord[0].xy * tex_scale0).r;\n"
" yuv.y=texture2D(Utex, gl_TexCoord[0].xy * tex_scale1).r;\n"
" yuv.z=texture2D(Vtex, gl_TexCoord[0].xy * tex_scale2).r;\n"
" yuv += offset;\n"
" r = dot(yuv, rcoeff);\n"
" g = dot(yuv, gcoeff);\n"
@ -113,8 +111,7 @@ static const char *frag_PLANAR_YUV_opengl = {
/** NV12/NV21 to RGB conversion */
static const char *frag_NV12_NV21_opengl = {
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect Ytex,UVtex;\n"
"uniform sampler2D Ytex,UVtex;\n"
"uniform vec2 tex_scale0;\n"
"uniform vec2 tex_scale1;\n"
"uniform vec2 tex_scale2;\n"
@ -122,8 +119,8 @@ static const char *frag_NV12_NV21_opengl = {
"void main(void) {\n\n"
" float r,g,b;\n"
" vec3 yuv;\n"
" yuv.x = texture2DRect(Ytex, gl_TexCoord[0].xy * tex_scale0).r;\n"
" yuv.yz = texture2DRect(UVtex, gl_TexCoord[0].xy * tex_scale1).%c%c;\n"
" yuv.x = texture2D(Ytex, gl_TexCoord[0].xy * tex_scale0).r;\n"
" yuv.yz = texture2D(UVtex, gl_TexCoord[0].xy * tex_scale1).%c%c;\n"
" yuv += offset;\n"
" r = dot(yuv, rcoeff);\n"
" g = dot(yuv, gcoeff);\n"
@ -134,28 +131,26 @@ static const char *frag_NV12_NV21_opengl = {
/* Channel reordering for XYZ <-> ZYX conversion */
static const char *frag_REORDER_opengl = {
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;\n"
"uniform sampler2D tex;\n"
"uniform vec2 tex_scale0;\n"
"uniform vec2 tex_scale1;\n"
"uniform vec2 tex_scale2;\n"
"void main(void)\n"
"{\n"
" vec4 t = texture2DRect(tex, gl_TexCoord[0].xy);\n"
" vec4 t = texture2D(tex, gl_TexCoord[0].xy);\n"
" gl_FragColor = vec4(t.%c, t.%c, t.%c, 1.0);\n"
"}"
};
/* Direct fragments copy with stride-scaling */
static const char *frag_COPY_opengl = {
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;\n"
"uniform sampler2D tex;\n"
"uniform vec2 tex_scale0;\n"
"uniform vec2 tex_scale1;\n"
"uniform vec2 tex_scale2;\n"
"void main(void)\n"
"{\n"
" vec4 t = texture2DRect(tex, gl_TexCoord[0].xy);\n"
" vec4 t = texture2D(tex, gl_TexCoord[0].xy);\n"
" gl_FragColor = vec4(t.rgb, 1.0);\n"
"}\n"
};
@ -163,8 +158,7 @@ static const char *frag_COPY_opengl = {
/* YUY2:r,g,a
UYVY:a,b,r */
static const gchar *frag_YUY2_UYVY_opengl =
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect Ytex, UVtex;\n"
"uniform sampler2D Ytex, UVtex;\n"
"uniform vec2 tex_scale0;\n"
"uniform vec2 tex_scale1;\n"
"uniform vec2 tex_scale2;\n"
@ -172,9 +166,9 @@ static const gchar *frag_YUY2_UYVY_opengl =
"void main(void) {\n"
" float fx, fy, y, u, v, r, g, b;\n"
" vec3 yuv;\n"
" yuv.x = texture2DRect(Ytex, gl_TexCoord[0].xy * tex_scale0).%c;\n"
" yuv.y = texture2DRect(UVtex, gl_TexCoord[0].xy * tex_scale1).%c;\n"
" yuv.z = texture2DRect(UVtex, gl_TexCoord[0].xy * tex_scale2).%c;\n"
" yuv.x = texture2D(Ytex, gl_TexCoord[0].xy * tex_scale0).%c;\n"
" yuv.y = texture2D(UVtex, gl_TexCoord[0].xy * tex_scale1).%c;\n"
" yuv.z = texture2D(UVtex, gl_TexCoord[0].xy * tex_scale2).%c;\n"
" yuv += offset;\n"
" r = dot(yuv, rcoeff);\n"
" g = dot(yuv, gcoeff);\n"
@ -794,21 +788,17 @@ _init_upload_fbo (GstGLContext * context, GstGLUpload * upload)
/* a fake texture is attached to the upload FBO (cannot init without it) */
gl->GenTextures (1, &fake_texture);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, fake_texture);
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, out_width, out_height,
gl->BindTexture (GL_TEXTURE_2D, fake_texture);
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, out_width, out_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
/* attach the texture to the FBO to renderer to */
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_RECTANGLE_ARB, fake_texture, 0);
GL_TEXTURE_2D, fake_texture, 0);
/* attach the depth render buffer to the FBO */
gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
@ -924,7 +914,7 @@ _do_upload_make (GstGLContext * context, GstGLUpload * upload)
tex[1].internal_format = GL_RGBA8;
tex[1].format = GL_BGRA;
tex[1].type = GL_UNSIGNED_INT_8_8_8_8;
tex[1].width = in_width;
tex[1].width = GST_ROUND_UP_2 (in_width) / 2;
tex[1].height = in_height;
break;
case GST_VIDEO_FORMAT_UYVY:
@ -936,7 +926,7 @@ _do_upload_make (GstGLContext * context, GstGLUpload * upload)
tex[1].internal_format = GL_RGBA8;
tex[1].format = GL_BGRA;
tex[1].type = GL_UNSIGNED_INT_8_8_8_8_REV;
tex[1].width = in_width;
tex[1].width = GST_ROUND_UP_2 (in_width) / 2;
tex[1].height = in_height;
break;
case GST_VIDEO_FORMAT_NV12:
@ -949,8 +939,8 @@ _do_upload_make (GstGLContext * context, GstGLUpload * upload)
tex[1].internal_format = GL_LUMINANCE_ALPHA;
tex[1].format = GL_LUMINANCE_ALPHA;
tex[1].type = GL_UNSIGNED_BYTE;
tex[1].width = in_width / 2;
tex[1].height = in_height / 2;
tex[1].width = GST_ROUND_UP_2 (in_width) / 2;
tex[1].height = GST_ROUND_UP_2 (in_height) / 2;
break;
case GST_VIDEO_FORMAT_Y444:
tex[0].internal_format = GL_LUMINANCE;
@ -1030,9 +1020,9 @@ _do_upload_make (GstGLContext * context, GstGLUpload * upload)
for (i = 0; i < upload->priv->n_textures; i++) {
gl->GenTextures (1, &upload->in_texture[i]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[i]);
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[i]);
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, tex[i].internal_format,
gl->TexImage2D (GL_TEXTURE_2D, 0, tex[i].internal_format,
tex[i].width, tex[i].height, 0, tex[i].format, tex[i].type, NULL);
}
@ -1054,12 +1044,12 @@ _do_upload_fill (GstGLContext * context, GstGLUpload * upload)
in_height = upload->in_height;
v_format = GST_VIDEO_INFO_FORMAT (&upload->info);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[0]);
switch (v_format) {
case GST_VIDEO_FORMAT_RGB:
case GST_VIDEO_FORMAT_BGR:
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, in_width, in_height,
GL_RGB, GL_UNSIGNED_BYTE, upload->data[0]);
break;
case GST_VIDEO_FORMAT_RGBx:
@ -1071,111 +1061,111 @@ _do_upload_fill (GstGLContext * context, GstGLUpload * upload)
case GST_VIDEO_FORMAT_AYUV:
case GST_VIDEO_FORMAT_xBGR:
case GST_VIDEO_FORMAT_ABGR:
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, in_width, in_height,
GL_RGBA, GL_UNSIGNED_BYTE, upload->data[0]);
break;
case GST_VIDEO_FORMAT_YUY2:
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width,
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, in_width,
in_height, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, upload->data[0]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, in_height,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, upload->data[0]);
break;
case GST_VIDEO_FORMAT_UYVY:
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width,
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, in_width,
in_height, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, upload->data[0]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, in_height,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, upload->data[0]);
break;
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, in_width, in_height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[0]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
in_width / 2, in_height / 2,
GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, upload->data[1]);
break;
case GST_VIDEO_FORMAT_I420:
{
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, in_width, in_height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[0]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, GST_ROUND_UP_2 (in_height) / 2,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[1]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[2]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, GST_ROUND_UP_2 (in_height) / 2,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[2]);
}
break;
case GST_VIDEO_FORMAT_YV12: /* same as I420 except plane 1+2 swapped */
{
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, in_width, in_height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[0]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[2]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, GST_ROUND_UP_2 (in_height) / 2,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[1]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, GST_ROUND_UP_2 (in_height) / 2,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[2]);
}
break;
case GST_VIDEO_FORMAT_Y444:
{
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, in_width, in_height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[0]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
in_width, in_height, GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[1]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[2]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
in_width, in_height, GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[2]);
}
break;
case GST_VIDEO_FORMAT_Y42B:
{
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, in_width, in_height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[0]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, in_height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[1]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[2]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, in_height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[2]);
}
break;
case GST_VIDEO_FORMAT_Y41B:
{
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, in_width, in_height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[0]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[1]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
GST_ROUND_UP_4 (in_width) / 4, in_height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[1]);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[2]);
gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,
GST_ROUND_UP_4 (in_width) / 4, in_height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[2]);
}
@ -1190,7 +1180,7 @@ _do_upload_fill (GstGLContext * context, GstGLUpload * upload)
/* make sure no texture is in use in our opengl context
* in case we want to use the upload texture in an other opengl context
*/
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
glBindTexture (GL_TEXTURE_2D, 0);
return TRUE;
}
@ -1203,8 +1193,6 @@ _do_upload_draw_opengl (GstGLContext * context, GstGLUpload * upload)
GstGLFuncs *gl;
GstVideoFormat v_format;
guint out_width, out_height;
guint in_width = upload->in_width;
guint in_height = upload->in_height;
char *texnames[GST_VIDEO_MAX_PLANES];
gint i;
gfloat tex_scaling[6] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
@ -1214,10 +1202,10 @@ _do_upload_draw_opengl (GstGLContext * context, GstGLUpload * upload)
-1.0f, 1.0f,
1.0f, 1.0f
};
GLfloat texcoords[8] = { in_width, 0,
0, 0,
0, in_height,
in_width, in_height
GLfloat texcoords[8] = { 1.0f, 0.0f,
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f
};
gl = context->gl_vtable;
@ -1229,12 +1217,12 @@ _do_upload_draw_opengl (GstGLContext * context, GstGLUpload * upload)
gl->BindFramebuffer (GL_FRAMEBUFFER, upload->fbo);
/* setup a texture to render to */
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->out_texture);
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, upload->out_texture);
/* attach the texture to the FBO to renderer to */
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_RECTANGLE_ARB, upload->out_texture, 0);
GL_TEXTURE_2D, upload->out_texture, 0);
gst_gl_context_clear_shader (context);
@ -1318,21 +1306,17 @@ _do_upload_draw_opengl (GstGLContext * context, GstGLUpload * upload)
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->Enable (GL_TEXTURE_2D);
for (i = upload->priv->n_textures - 1; i >= 0; i--) {
gl->ActiveTexture (GL_TEXTURE0 + i);
gst_gl_shader_set_uniform_1i (upload->shader, texnames[i], i);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[i]);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[i]);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
gl->EnableClientState (GL_VERTEX_ARRAY);
@ -1351,7 +1335,7 @@ _do_upload_draw_opengl (GstGLContext * context, GstGLUpload * upload)
/* we are done with the shader */
gst_gl_context_clear_shader (context);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gl->Disable (GL_TEXTURE_2D);
gl->MatrixMode (GL_PROJECTION);
gl->PopMatrix ();
@ -1401,11 +1385,11 @@ _do_upload_draw_gles2 (GstGLContext * context, GstGLUpload * upload)
gl->BindFramebuffer (GL_FRAMEBUFFER, upload->fbo);
/* setup a texture to render to */
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->out_texture);
gl->BindTexture (GL_TEXTURE_2D, upload->out_texture);
/* attach the texture to the FBO to renderer to */
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_RECTANGLE_ARB, upload->out_texture, 0);
GL_TEXTURE_2D, upload->out_texture, 0);
gst_gl_context_clear_shader (context);
@ -1433,12 +1417,10 @@ _do_upload_draw_gles2 (GstGLContext * context, GstGLUpload * upload)
case GST_VIDEO_FORMAT_NV21:
texnames[0] = "Ytex";
texnames[1] = "UVtex";
tex_scaling[2] = tex_scaling[3] = 0.5;
case GST_VIDEO_FORMAT_YUY2:
case GST_VIDEO_FORMAT_UYVY:
texnames[0] = "Ytex";
texnames[1] = "UVtex";
tex_scaling[2] = tex_scaling[4] = 0.5;
break;
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12:
@ -1448,13 +1430,6 @@ _do_upload_draw_gles2 (GstGLContext * context, GstGLUpload * upload)
texnames[0] = "Ytex";
texnames[1] = "Utex";
texnames[2] = "Vtex";
if (v_format == GST_VIDEO_FORMAT_I420
|| v_format == GST_VIDEO_FORMAT_YV12)
tex_scaling[2] = tex_scaling[3] = tex_scaling[4] = tex_scaling[5] = 0.5;
else if (v_format == GST_VIDEO_FORMAT_Y42B)
tex_scaling[2] = tex_scaling[4] = 0.5;
else if (v_format == GST_VIDEO_FORMAT_Y41B)
tex_scaling[2] = tex_scaling[4] = 0.25;
break;
case GST_VIDEO_FORMAT_AYUV:
texnames[0] = "tex";
@ -1486,15 +1461,11 @@ _do_upload_draw_gles2 (GstGLContext * context, GstGLUpload * upload)
gl->ActiveTexture (GL_TEXTURE0 + i);
gst_gl_shader_set_uniform_1i (upload->shader, texnames[i], i);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[i]);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
gl->BindTexture (GL_TEXTURE_2D, upload->in_texture[i]);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);

View file

@ -106,18 +106,14 @@ _gen_texture (GstGLContext * context, GenTexture * data)
data->width, data->height);
gl->GenTextures (1, &data->result);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, data->result);
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, data->width,
gl->BindTexture (GL_TEXTURE_2D, data->result);
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, data->width,
data->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
GST_LOG ("generated texture id:%d", data->result);
}

View file

@ -156,10 +156,10 @@ draw_render (gpointer data)
-1.0f, -1.0f,
1.0f, -1.0f
};
GLfloat texcoords[8] = { 320.0f, 0.0f,
GLfloat texcoords[8] = { 1.0f, 0.0f,
0.0f, 0.0f,
0.0f, 240.0f,
320.0f, 240.0f
0.0f, 1.0f,
1.0f, 1.0f
};
gl->Viewport (0, 0, 320, 240);
@ -169,8 +169,8 @@ draw_render (gpointer data)
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, tex);
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, tex);
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
@ -182,7 +182,7 @@ draw_render (gpointer data)
gl->DisableClientState (GL_VERTEX_ARRAY);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gl->Disable (GL_TEXTURE_2D);
#endif
#if GST_GL_HAVE_GLES2
const GLfloat vVertices[] = { 1.0f, 1.0f, 0.0f,