mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
[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:
parent
52a9869596
commit
b90d824626
42 changed files with 654 additions and 785 deletions
|
@ -848,8 +848,8 @@ bottom_up_to_top_down (gint width, gint height, guint texture,
|
|||
GstVisualGL * visual)
|
||||
{
|
||||
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glBindTexture (GL_TEXTURE_2D, texture);
|
||||
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
@ -867,8 +867,8 @@ bottom_up_to_top_down (gint width, gint height, guint texture,
|
|||
glVertex2i (-1, -1);
|
||||
glEnd ();
|
||||
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
glDisable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
|
||||
GST_DEBUG_OBJECT (visual, "bottom up to top down");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ gst_gl_effects_bulge_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ gst_gl_effects_fisheye_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ gst_gl_effects_glow_step_one (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
|
@ -100,12 +100,13 @@ gst_gl_effects_glow_step_two (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (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 (shader, "tex", 1);
|
||||
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7, gauss_kernel);
|
||||
gst_gl_shader_set_uniform_1f (shader, "height", height);
|
||||
|
||||
gst_gl_effects_draw_texture (effects, texture, width, height);
|
||||
}
|
||||
|
@ -140,12 +141,13 @@ gst_gl_effects_glow_step_three (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (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 (shader, "tex", 1);
|
||||
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7, gauss_kernel);
|
||||
gst_gl_shader_set_uniform_1f (shader, "width", width);
|
||||
|
||||
gst_gl_effects_draw_texture (effects, texture, width, height);
|
||||
}
|
||||
|
@ -180,17 +182,17 @@ gst_gl_effects_glow_step_four (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE2);
|
||||
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, effects->intexture);
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Enable (GL_TEXTURE_2D);
|
||||
gl->BindTexture (GL_TEXTURE_2D, effects->intexture);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
|
||||
gst_gl_shader_set_uniform_1f (shader, "alpha", 1.0);
|
||||
gst_gl_shader_set_uniform_1i (shader, "base", 2);
|
||||
|
||||
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_1f (shader, "beta", (gfloat) 1 / 3.5f);
|
||||
gst_gl_shader_set_uniform_1i (shader, "blend", 1);
|
||||
|
|
|
@ -75,8 +75,8 @@ gst_gl_effects_identity_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
}
|
||||
|
|
|
@ -71,12 +71,12 @@ gst_gl_effects_luma_to_curve (GstGLEffects * effects,
|
|||
}
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE2);
|
||||
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
||||
gl->Enable (GL_TEXTURE_2D);
|
||||
gl->BindTexture (GL_TEXTURE_2D, texture);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 2);
|
||||
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE1);
|
||||
gl->Enable (GL_TEXTURE_1D);
|
||||
|
|
|
@ -95,8 +95,8 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
|
|
|
@ -71,12 +71,12 @@ gst_gl_effects_rgb_to_curve (GstGLEffects * effects,
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE1);
|
||||
gl->Enable (GL_TEXTURE_1D);
|
||||
|
|
|
@ -53,8 +53,8 @@ gst_gl_effects_sin_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ gst_gl_effects_square_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
|
|
|
@ -94,8 +94,8 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
|
|
|
@ -88,17 +88,14 @@ const gchar *identity_fragment_source =
|
|||
/* Mirror effect */
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
const gchar *mirror_fragment_source_opengl =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform float width, height;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec2 tex_size = vec2 (width, height);"
|
||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||
" vec2 normcoord;"
|
||||
" normcoord = texturecoord / tex_size - 1.0;"
|
||||
" normcoord = texturecoord - 0.5;"
|
||||
" normcoord.x *= sign (normcoord.x);"
|
||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||
" texturecoord = normcoord + 0.5;"
|
||||
" vec4 color = texture2D (tex, texturecoord);"
|
||||
" gl_FragColor = color * gl_Color;"
|
||||
"}";
|
||||
#endif
|
||||
|
@ -111,7 +108,7 @@ const gchar *mirror_fragment_source_gles2 =
|
|||
" vec2 texturecoord = v_texCoord.xy;"
|
||||
" float normcoord = texturecoord.x - 0.5;"
|
||||
" normcoord *= sign (normcoord);"
|
||||
" texturecoord.x = (normcoord + 0.5);"
|
||||
" texturecoord.x = normcoord + 0.5;"
|
||||
" gl_FragColor = texture2D (tex, texturecoord);"
|
||||
"}";
|
||||
#endif
|
||||
|
@ -119,20 +116,15 @@ const gchar *mirror_fragment_source_gles2 =
|
|||
/* Squeeze effect */
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
const gchar *squeeze_fragment_source_opengl =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform float width, height;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec2 tex_size = vec2 (width, height);"
|
||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||
" vec2 normcoord;"
|
||||
" normcoord = texturecoord / tex_size - 1.0; "
|
||||
" vec2 normcoord = texturecoord - 0.5;"
|
||||
" float r = length (normcoord);"
|
||||
" r = pow(r, 0.40)*1.3;"
|
||||
" normcoord = normcoord / r;"
|
||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||
" vec4 color = texture2DRect (tex, texturecoord); "
|
||||
" gl_FragColor = color * gl_Color;"
|
||||
" texturecoord = (normcoord + 0.5);"
|
||||
" gl_FragColor = texture2D (tex, texturecoord);"
|
||||
"}";
|
||||
#endif
|
||||
#if GST_GL_HAVE_GLES2
|
||||
|
@ -153,137 +145,116 @@ const gchar *squeeze_fragment_source_gles2 =
|
|||
|
||||
/* Stretch Effect */
|
||||
const gchar *stretch_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform float width, height;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec2 tex_size = vec2 (width, height);"
|
||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||
" vec2 normcoord;"
|
||||
" normcoord = texturecoord / tex_size - 1.0;"
|
||||
" normcoord = texturecoord - 0.5;"
|
||||
" float r = length (normcoord);"
|
||||
" normcoord *= 2.0 - smoothstep(0.0, 0.7, r);"
|
||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||
" normcoord *= 2.0 - smoothstep(0.0, 0.35, r);"
|
||||
" texturecoord = normcoord + 0.5;"
|
||||
" vec4 color = texture2D (tex, texturecoord);"
|
||||
" gl_FragColor = color * gl_Color;"
|
||||
"}";
|
||||
|
||||
/* Light Tunnel effect */
|
||||
const gchar *tunnel_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform float width, height;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec2 tex_size = vec2 (width, height);"
|
||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||
" vec2 normcoord;"
|
||||
/* little trick with normalized coords to obtain a circle with
|
||||
* rect textures */
|
||||
" normcoord = (texturecoord - tex_size) / tex_size.x;"
|
||||
" normcoord = (texturecoord - 0.5);"
|
||||
" float r = length(normcoord);"
|
||||
" normcoord *= clamp (r, 0.0, 0.5) / r;"
|
||||
" texturecoord = (normcoord * tex_size.x) + tex_size;"
|
||||
" vec4 color = texture2DRect (tex, texturecoord); "
|
||||
" normcoord *= clamp (r, 0.0, 0.275) / r;"
|
||||
" texturecoord = normcoord + 0.5;"
|
||||
" vec4 color = texture2D (tex, texturecoord); "
|
||||
" gl_FragColor = color;"
|
||||
"}";
|
||||
|
||||
/* FishEye effect */
|
||||
const gchar *fisheye_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform float width, height;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec2 tex_size = vec2 (width, height);"
|
||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||
" vec2 normcoord;"
|
||||
" normcoord = texturecoord / tex_size - 1.0;"
|
||||
" float r = length (normcoord);"
|
||||
" normcoord *= r/sqrt(2.0);"
|
||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||
" normcoord = texturecoord - 0.5;"
|
||||
" float r = length (normcoord);"
|
||||
" normcoord *= r * sqrt(2);"
|
||||
" texturecoord = normcoord + 0.5;"
|
||||
" vec4 color = texture2D (tex, texturecoord);"
|
||||
" gl_FragColor = color;"
|
||||
"}";
|
||||
|
||||
|
||||
/* Twirl effect */
|
||||
const gchar *twirl_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform float width, height;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec2 tex_size = vec2 (width, height);"
|
||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||
" vec2 normcoord;"
|
||||
" normcoord = texturecoord / tex_size - 1.0;"
|
||||
" normcoord = texturecoord - 0.5;"
|
||||
" float r = length (normcoord);"
|
||||
/* calculate rotation angle: maximum (about pi/2) at the origin and
|
||||
* gradually decrease it up to 0.6 of each quadrant */
|
||||
" float phi = (1.0 - smoothstep (0.0, 0.6, r)) * 1.6;"
|
||||
" float phi = (1.0 - smoothstep (0.0, 0.3, r)) * 1.6;"
|
||||
/* precalculate sin phi and cos phi, save some alu */
|
||||
" float s = sin(phi);"
|
||||
" float c = cos(phi);"
|
||||
/* rotate */
|
||||
" normcoord *= mat2(c, s, -s, c);"
|
||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||
" vec4 color = texture2DRect (tex, texturecoord); "
|
||||
" texturecoord = normcoord + 0.5;"
|
||||
" vec4 color = texture2D (tex, texturecoord); "
|
||||
" gl_FragColor = color;"
|
||||
"}";
|
||||
|
||||
|
||||
/* Bulge effect */
|
||||
const gchar *bulge_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform float width, height;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec2 tex_size = vec2 (width, height);"
|
||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||
" vec2 normcoord;"
|
||||
" normcoord = texturecoord / tex_size - 1.0;"
|
||||
" normcoord = texturecoord - 0.5;"
|
||||
" float r = length (normcoord);"
|
||||
" normcoord *= smoothstep (-0.1, 0.5, r);"
|
||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||
" normcoord *= smoothstep (-0.05, 0.25, r);"
|
||||
" texturecoord = normcoord + 0.5;"
|
||||
" vec4 color = texture2D (tex, texturecoord);"
|
||||
" gl_FragColor = color;"
|
||||
"}";
|
||||
|
||||
|
||||
/* Square Effect */
|
||||
const gchar *square_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform float width;"
|
||||
"uniform float height;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec2 tex_size = vec2 (width, height);"
|
||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||
" vec2 normcoord;"
|
||||
" normcoord = texturecoord / tex_size - 1.0;"
|
||||
" normcoord = texturecoord - 0.5;"
|
||||
" float r = length (normcoord);"
|
||||
" normcoord *= 1.0 + smoothstep(0.25, 0.5, abs(normcoord));"
|
||||
" normcoord *= 1.0 + smoothstep(0.125, 0.25, abs(normcoord));"
|
||||
" normcoord /= 2.0; /* zoom amount */"
|
||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||
" texturecoord = normcoord + 0.5;"
|
||||
" vec4 color = texture2D (tex, texturecoord);"
|
||||
" gl_FragColor = color * gl_Color;"
|
||||
"}";
|
||||
|
||||
|
||||
const gchar *luma_threshold_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec2 texturecoord = gl_TexCoord[0].st;"
|
||||
" vec4 color = texture2DRect(tex, texturecoord);"
|
||||
" vec4 color = texture2D(tex, texturecoord);"
|
||||
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));" /* BT.709 (from orange book) */
|
||||
" gl_FragColor = vec4 (vec3 (smoothstep (0.30, 0.50, luma)), color.a);"
|
||||
"}";
|
||||
|
||||
const gchar *sep_sobel_length_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform sampler2D tex;"
|
||||
"uniform bool invert;"
|
||||
"void main () {"
|
||||
" vec4 g = texture2DRect (tex, gl_TexCoord[0].st);"
|
||||
" vec4 g = texture2D (tex, gl_TexCoord[0].st);"
|
||||
/* restore black background with grey edges */
|
||||
" g -= vec4(0.5, 0.5, 0.0, 0.0);"
|
||||
" float len = length (g);"
|
||||
|
@ -293,22 +264,22 @@ const gchar *sep_sobel_length_fragment_source =
|
|||
"}";
|
||||
|
||||
const gchar *desaturate_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec4 color = texture2DRect (tex, gl_TexCoord[0].st);"
|
||||
" vec4 color = texture2D (tex, gl_TexCoord[0].st);"
|
||||
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));"
|
||||
" gl_FragColor = vec4(vec3(luma), color.a);"
|
||||
"}";
|
||||
|
||||
const gchar *sep_sobel_hconv3_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform sampler2D tex;"
|
||||
"uniform float width;"
|
||||
"void main () {"
|
||||
" float w = 1.0 / width;"
|
||||
" vec2 texturecoord[3];"
|
||||
" texturecoord[1] = gl_TexCoord[0].st;"
|
||||
" texturecoord[0] = texturecoord[1] - vec2(1.0, 0.0);"
|
||||
" texturecoord[2] = texturecoord[1] + vec2(1.0, 0.0);"
|
||||
" texturecoord[0] = texturecoord[1] - vec2(w, 0.0);"
|
||||
" texturecoord[2] = texturecoord[1] + vec2(w, 0.0);"
|
||||
" float grad_kern[3];"
|
||||
" grad_kern[0] = 1.0;"
|
||||
" grad_kern[1] = 0.0;"
|
||||
|
@ -320,7 +291,7 @@ const gchar *sep_sobel_hconv3_fragment_source =
|
|||
" int i;"
|
||||
" vec4 sum = vec4 (0.0);"
|
||||
" for (i = 0; i < 3; i++) { "
|
||||
" vec4 neighbor = texture2DRect(tex, texturecoord[i]); "
|
||||
" vec4 neighbor = texture2D(tex, texturecoord[i]); "
|
||||
" sum.r = neighbor.r * blur_kern[i] + sum.r;"
|
||||
" sum.g = neighbor.g * grad_kern[i] + sum.g;"
|
||||
" }"
|
||||
|
@ -328,13 +299,14 @@ const gchar *sep_sobel_hconv3_fragment_source =
|
|||
"}";
|
||||
|
||||
const gchar *sep_sobel_vconv3_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform sampler2D tex;"
|
||||
"uniform float height;"
|
||||
"void main () {"
|
||||
" float h = 1.0 / height;"
|
||||
" vec2 texturecoord[3];"
|
||||
" texturecoord[1] = gl_TexCoord[0].st;"
|
||||
" texturecoord[0] = texturecoord[1] - vec2(0.0, 1.0);"
|
||||
" texturecoord[2] = texturecoord[1] + vec2(0.0, 1.0);"
|
||||
" texturecoord[0] = texturecoord[1] - vec2(0.0, h);"
|
||||
" texturecoord[2] = texturecoord[1] + vec2(0.0, h);"
|
||||
" float grad_kern[3];"
|
||||
" grad_kern[0] = 1.0;"
|
||||
" grad_kern[1] = 0.0;"
|
||||
|
@ -346,7 +318,7 @@ const gchar *sep_sobel_vconv3_fragment_source =
|
|||
" int i;"
|
||||
" vec4 sum = vec4 (0.0);"
|
||||
" for (i = 0; i < 3; i++) { "
|
||||
" vec4 neighbor = texture2DRect(tex, texturecoord[i]); "
|
||||
" vec4 neighbor = texture2D(tex, texturecoord[i]); "
|
||||
" sum.r = neighbor.r * grad_kern[i] + sum.r;"
|
||||
" sum.g = neighbor.g * blur_kern[i] + sum.g;"
|
||||
" }"
|
||||
|
@ -355,22 +327,23 @@ const gchar *sep_sobel_vconv3_fragment_source =
|
|||
|
||||
/* horizontal convolution 7x7 */
|
||||
const gchar *hconv7_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform sampler2D tex;"
|
||||
"uniform float kernel[7];"
|
||||
"uniform float width;"
|
||||
"void main () {"
|
||||
" float w = 1.0 / width;"
|
||||
" vec2 texturecoord[7];"
|
||||
" texturecoord[3] = gl_TexCoord[0].st;"
|
||||
" texturecoord[2] = texturecoord[3] - vec2(1.0, 0.0);"
|
||||
" texturecoord[1] = texturecoord[2] - vec2(1.0, 0.0);"
|
||||
" texturecoord[0] = texturecoord[1] - vec2(1.0, 0.0);"
|
||||
" texturecoord[4] = texturecoord[3] + vec2(1.0, 0.0);"
|
||||
" texturecoord[5] = texturecoord[4] + vec2(1.0, 0.0);"
|
||||
" texturecoord[6] = texturecoord[5] + vec2(1.0, 0.0);"
|
||||
" texturecoord[2] = texturecoord[3] - vec2(w, 0.0);"
|
||||
" texturecoord[1] = texturecoord[2] - vec2(w, 0.0);"
|
||||
" texturecoord[0] = texturecoord[1] - vec2(w, 0.0);"
|
||||
" texturecoord[4] = texturecoord[3] + vec2(w, 0.0);"
|
||||
" texturecoord[5] = texturecoord[4] + vec2(w, 0.0);"
|
||||
" texturecoord[6] = texturecoord[5] + vec2(w, 0.0);"
|
||||
" int i;"
|
||||
" vec4 sum = vec4 (0.0);"
|
||||
" for (i = 0; i < 7; i++) { "
|
||||
" vec4 neighbor = texture2DRect(tex, texturecoord[i]); "
|
||||
" vec4 neighbor = texture2D(tex, texturecoord[i]); "
|
||||
" sum += neighbor * kernel[i];"
|
||||
" }"
|
||||
" gl_FragColor = sum;"
|
||||
|
@ -378,22 +351,23 @@ const gchar *hconv7_fragment_source =
|
|||
|
||||
/* vertical convolution 7x7 */
|
||||
const gchar *vconv7_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform sampler2D tex;"
|
||||
"uniform float kernel[7];"
|
||||
"uniform float height;"
|
||||
"void main () {"
|
||||
" float h = 1.0 / height;"
|
||||
" vec2 texturecoord[7];"
|
||||
" texturecoord[3] = gl_TexCoord[0].st;"
|
||||
" texturecoord[2] = texturecoord[3] - vec2(0.0, 1.0);"
|
||||
" texturecoord[1] = texturecoord[2] - vec2(0.0, 1.0);"
|
||||
" texturecoord[0] = texturecoord[1] - vec2(0.0, 1.0);"
|
||||
" texturecoord[4] = texturecoord[3] + vec2(0.0, 1.0);"
|
||||
" texturecoord[5] = texturecoord[4] + vec2(0.0, 1.0);"
|
||||
" texturecoord[6] = texturecoord[5] + vec2(0.0, 1.0);"
|
||||
" texturecoord[2] = texturecoord[3] - vec2(0.0, h);"
|
||||
" texturecoord[1] = texturecoord[2] - vec2(0.0, h);"
|
||||
" texturecoord[0] = texturecoord[1] - vec2(0.0, h);"
|
||||
" texturecoord[4] = texturecoord[3] + vec2(0.0, h);"
|
||||
" texturecoord[5] = texturecoord[4] + vec2(0.0, h);"
|
||||
" texturecoord[6] = texturecoord[5] + vec2(0.0, h);"
|
||||
" int i;"
|
||||
" vec4 sum = vec4 (0.0);"
|
||||
" for (i = 0; i < 7; i++) { "
|
||||
" vec4 neighbor = texture2DRect(tex, texturecoord[i]);"
|
||||
" vec4 neighbor = texture2D(tex, texturecoord[i]);"
|
||||
" sum += neighbor * kernel[i];"
|
||||
" }"
|
||||
" gl_FragColor = sum;"
|
||||
|
@ -402,36 +376,33 @@ const gchar *vconv7_fragment_source =
|
|||
|
||||
/* TODO: support several blend modes */
|
||||
const gchar *sum_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect base;"
|
||||
"uniform sampler2DRect blend;"
|
||||
"uniform sampler2D base;"
|
||||
"uniform sampler2D blend;"
|
||||
"uniform float alpha;"
|
||||
"uniform float beta;"
|
||||
"void main () {"
|
||||
" vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);"
|
||||
" vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
|
||||
" vec4 basecolor = texture2D (base, gl_TexCoord[0].st);"
|
||||
" vec4 blendcolor = texture2D (blend, gl_TexCoord[0].st);"
|
||||
" gl_FragColor = alpha * basecolor + beta * blendcolor;"
|
||||
"}";
|
||||
|
||||
const gchar *multiply_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect base;"
|
||||
"uniform sampler2DRect blend;"
|
||||
"uniform sampler2D base;"
|
||||
"uniform sampler2D blend;"
|
||||
"uniform float alpha;"
|
||||
"void main () {"
|
||||
" vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);"
|
||||
" vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
|
||||
" vec4 basecolor = texture2D (base, gl_TexCoord[0].st);"
|
||||
" vec4 blendcolor = texture2D (blend, gl_TexCoord[0].st);"
|
||||
" gl_FragColor = (1.0 - alpha) * basecolor + alpha * basecolor * blendcolor;"
|
||||
"}";
|
||||
|
||||
/* lut operations, map luma to tex1d, see orange book (chapter 19) */
|
||||
const gchar *luma_to_curve_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform sampler2D tex;"
|
||||
"uniform sampler1D curve;"
|
||||
"void main () {"
|
||||
" vec2 texturecoord = gl_TexCoord[0].st;"
|
||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||
" vec4 color = texture2D (tex, texturecoord);"
|
||||
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));"
|
||||
" color = texture1D(curve, luma);"
|
||||
" gl_FragColor = color;"
|
||||
|
@ -440,11 +411,10 @@ const gchar *luma_to_curve_fragment_source =
|
|||
|
||||
/* lut operations, map rgb to tex1d, see orange book (chapter 19) */
|
||||
const gchar *rgb_to_curve_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform sampler2D tex;"
|
||||
"uniform sampler1D curve;"
|
||||
"void main () {"
|
||||
" vec4 color = texture2DRect (tex, gl_TexCoord[0].st);"
|
||||
" vec4 color = texture2D (tex, gl_TexCoord[0].st);"
|
||||
" vec4 outcolor;"
|
||||
" outcolor.r = texture1D(curve, color.r).r;"
|
||||
" outcolor.g = texture1D(curve, color.g).g;"
|
||||
|
@ -454,10 +424,9 @@ const gchar *rgb_to_curve_fragment_source =
|
|||
"}";
|
||||
|
||||
const gchar *sin_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec4 color = texture2DRect (tex, vec2(gl_TexCoord[0].st));"
|
||||
" vec4 color = texture2D (tex, vec2(gl_TexCoord[0].st));"
|
||||
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));"
|
||||
/* calculate hue with the Preucil formula */
|
||||
" float cosh = color.r - 0.5*(color.g + color.b);"
|
||||
|
@ -480,48 +449,32 @@ const gchar *sin_fragment_source =
|
|||
"}";
|
||||
|
||||
const gchar *interpolate_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect base;"
|
||||
"uniform sampler2DRect blend;"
|
||||
"uniform sampler2D base;"
|
||||
"uniform sampler2D blend;"
|
||||
"void main () {"
|
||||
"vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);"
|
||||
"vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
|
||||
"vec4 basecolor = texture2D (base, gl_TexCoord[0].st);"
|
||||
"vec4 blendcolor = texture2D (blend, gl_TexCoord[0].st);"
|
||||
"vec4 white = vec4(1.0);"
|
||||
"gl_FragColor = blendcolor + (1.0 - blendcolor.a) * basecolor;"
|
||||
"}";
|
||||
|
||||
const gchar *texture_interp_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect base;"
|
||||
"uniform sampler2DRect blend;"
|
||||
"uniform sampler2DRect alpha;"
|
||||
"uniform float final_width, final_height;"
|
||||
"uniform float base_width, base_height;"
|
||||
/*
|
||||
"uniform float blend_width, blend_height;"
|
||||
"uniform float alpha_width, alpha_height;"
|
||||
*/
|
||||
"uniform sampler2D base;"
|
||||
"uniform sampler2D blend;"
|
||||
"uniform sampler2D alpha;"
|
||||
"void main () {"
|
||||
"vec2 base_scale = vec2 (base_width, base_height) / vec2 (final_width, final_height);"
|
||||
/*
|
||||
"vec2 blend_scale = vec2 (blend_width, blend_height) / vec2 (final_width, final_height);"
|
||||
"vec2 alpha_scale = vec2 (alpha_width, alpha_height) / vec2 (final_width, final_height);"
|
||||
*/
|
||||
|
||||
"vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st * base_scale);"
|
||||
"vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
|
||||
"vec4 alphacolor = texture2DRect (alpha, gl_TexCoord[0].st);"
|
||||
// "gl_FragColor = alphacolor;"
|
||||
"gl_FragColor = (alphacolor * blendcolor) + (1.0 - alphacolor) * basecolor;"
|
||||
" vec4 basecolor = texture2D (base, gl_TexCoord[0].st);"
|
||||
" vec4 blendcolor = texture2D (blend, gl_TexCoord[0].st);"
|
||||
" vec4 alphacolor = texture2D (alpha, gl_TexCoord[0].st);"
|
||||
" gl_FragColor = (alphacolor * blendcolor) + (1.0 - alphacolor) * basecolor;"
|
||||
"}";
|
||||
|
||||
const gchar *difference_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect saved;"
|
||||
"uniform sampler2DRect current;"
|
||||
"uniform sampler2D saved;"
|
||||
"uniform sampler2D current;"
|
||||
"void main () {"
|
||||
"vec4 savedcolor = texture2DRect (saved, gl_TexCoord[0].st);"
|
||||
"vec4 currentcolor = texture2DRect (current, gl_TexCoord[0].st);"
|
||||
"vec4 savedcolor = texture2D (saved, gl_TexCoord[0].st);"
|
||||
"vec4 currentcolor = texture2D (current, gl_TexCoord[0].st);"
|
||||
"gl_FragColor = vec4 (step (0.12, length (savedcolor - currentcolor)));"
|
||||
"}";
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ gst_gl_effects_stretch_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ gst_gl_effects_tunnel_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ gst_gl_effects_twirl_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
|
|
|
@ -73,12 +73,13 @@ gst_gl_effects_xray_step_two (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (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 (shader, "tex", 1);
|
||||
gst_gl_shader_set_uniform_1fv (shader, "kernel", 9, gauss_kernel);
|
||||
gst_gl_shader_set_uniform_1f (shader, "width", width);
|
||||
|
||||
gst_gl_effects_draw_texture (effects, texture, width, height);
|
||||
}
|
||||
|
@ -113,12 +114,13 @@ gst_gl_effects_xray_step_three (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (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 (shader, "tex", 1);
|
||||
gst_gl_shader_set_uniform_1fv (shader, "kernel", 9, gauss_kernel);
|
||||
gst_gl_shader_set_uniform_1f (shader, "height", height);
|
||||
|
||||
gst_gl_effects_draw_texture (effects, texture, width, height);
|
||||
}
|
||||
|
@ -155,9 +157,9 @@ gst_gl_effects_xray_desaturate (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (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 (shader, "tex", 1);
|
||||
gst_gl_effects_draw_texture (effects, texture, width, height);
|
||||
|
@ -194,11 +196,13 @@ gst_gl_effects_xray_sobel_hconv (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (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 (shader, "tex", 1);
|
||||
gst_gl_shader_set_uniform_1f (shader, "width", width);
|
||||
|
||||
gst_gl_effects_draw_texture (effects, texture, width, height);
|
||||
}
|
||||
|
||||
|
@ -233,11 +237,13 @@ gst_gl_effects_xray_sobel_vconv (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (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 (shader, "tex", 1);
|
||||
gst_gl_shader_set_uniform_1f (shader, "height", height);
|
||||
|
||||
gst_gl_effects_draw_texture (effects, texture, width, height);
|
||||
}
|
||||
|
||||
|
@ -272,9 +278,9 @@ gst_gl_effects_xray_sobel_length (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (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 (shader, "tex", 1);
|
||||
gst_gl_shader_set_uniform_1i (shader, "invert", TRUE);
|
||||
|
@ -313,16 +319,16 @@ gst_gl_effects_xray_step_five (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (shader);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE2);
|
||||
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, effects->midtexture[2]);
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Enable (GL_TEXTURE_2D);
|
||||
gl->BindTexture (GL_TEXTURE_2D, effects->midtexture[2]);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "base", 2);
|
||||
|
||||
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_1f (shader, "alpha", (gfloat) 0.5f);
|
||||
gst_gl_shader_set_uniform_1i (shader, "blend", 1);
|
||||
|
|
|
@ -92,7 +92,7 @@ gst_gl_test_src_smpte (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
|
|||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glDisable (GL_CULL_FACE);
|
||||
glDisable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
|
|
|
@ -107,9 +107,8 @@ static const gchar *bumper_v_src =
|
|||
|
||||
//fragment source
|
||||
static const gchar *bumper_f_src =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect texture0;\n"
|
||||
"uniform sampler2DRect texture1;\n"
|
||||
"uniform sampler2D texture0;\n"
|
||||
"uniform sampler2D texture1;\n"
|
||||
"\n"
|
||||
"varying vec3 vNormal;\n"
|
||||
"varying vec3 vTangent;\n"
|
||||
|
@ -119,8 +118,8 @@ static const gchar *bumper_f_src =
|
|||
"void main()\n"
|
||||
"{\n"
|
||||
" // get the color of the textures\n"
|
||||
" vec4 textureColor = texture2DRect(texture0, gl_TexCoord[0].st);\n"
|
||||
" vec3 normalmapItem = texture2DRect(texture1, gl_TexCoord[1].st).xyz * 2.0 - 1.0;\n"
|
||||
" vec4 textureColor = texture2D(texture0, gl_TexCoord[0].st);\n"
|
||||
" vec3 normalmapItem = texture2D(texture1, gl_TexCoord[1].st).xyz * 2.0 - 1.0;\n"
|
||||
"\n"
|
||||
" // calculate matrix that transform from tangent space to normalmap space (contrary of intuition)\n"
|
||||
" vec3 binormal = cross(vNormal, vTangent);\n"
|
||||
|
@ -154,6 +153,7 @@ gst_gl_bumper_init_resources (GstGLFilter * filter)
|
|||
{
|
||||
GstGLBumper *bumper = GST_GL_BUMPER (filter);
|
||||
GstGLContext *context = filter->context;
|
||||
const GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
|
@ -247,11 +247,15 @@ gst_gl_bumper_init_resources (GstGLFilter * filter)
|
|||
bumper->bumpmap_width = width;
|
||||
bumper->bumpmap_height = height;
|
||||
|
||||
glGenTextures (1, &bumper->bumpmap);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, bumper->bumpmap);
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
|
||||
gl->GenTextures (1, &bumper->bumpmap);
|
||||
gl->BindTexture (GL_TEXTURE_2D, bumper->bumpmap);
|
||||
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
|
||||
bumper->bumpmap_width, bumper->bumpmap_height, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, raw_data);
|
||||
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);
|
||||
|
||||
free (raw_data);
|
||||
}
|
||||
|
@ -411,40 +415,33 @@ gst_gl_bumper_callback (gint width, gint height, guint texture, gpointer stuff)
|
|||
GLfloat light_diffuse1[] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
GLfloat mat_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
|
||||
/* image size */
|
||||
gfloat i_w = (gfloat) width;
|
||||
gfloat i_h = (gfloat) height;
|
||||
/* bumpmap size */
|
||||
gfloat b_w = (gfloat) bumper->bumpmap_width;
|
||||
gfloat b_h = (gfloat) bumper->bumpmap_height;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
MeshData mesh[] = {
|
||||
/* | Vertex | Normal |TexCoord0|TexCoord1| VertexAttrib | */
|
||||
/*F*/ { 1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0},
|
||||
/*r*/ { 1.0, -1.0, -1.0, 0.0, 0.0, -1.0, i_w, 0.0, b_w, 0.0, 0.0, 1.0, 0.0},
|
||||
/*o*/ {-1.0, -1.0, -1.0, 0.0, 0.0, -1.0, i_w, i_h, b_w, b_h, 0.0, 1.0, 0.0},
|
||||
{-1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, i_h, 0.0, b_h, 0.0, 1.0, 0.0},
|
||||
/*r*/ { 1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0},
|
||||
/*o*/ {-1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0},
|
||||
{-1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0},
|
||||
/*R*/ {-1.0, 1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0},
|
||||
/*i*/ {-1.0, -1.0, -1.0, -1.0, 0.0, 0.0, i_w, 0.0, b_w, 0.0, 0.0, 1.0, 0.0},
|
||||
/*g*/ {-1.0, -1.0, 1.0, -1.0, 0.0, 0.0, i_w, i_h, b_w, b_h, 0.0, 1.0, 0.0},
|
||||
{-1.0, 1.0, 1.0, -1.0, 0.0, 0.0, 0.0, i_h, 0.0, b_h, 0.0, 1.0, 0.0},
|
||||
/*i*/ {-1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0},
|
||||
/*g*/ {-1.0, -1.0, 1.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0},
|
||||
{-1.0, 1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0},
|
||||
/*B*/ {-1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0},
|
||||
/*a*/ {-1.0, -1.0, 1.0, 0.0, 0.0, 1.0, i_w, 0.0, b_w, 0.0, 0.0, 1.0, 0.0},
|
||||
/*c*/ { 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, i_w, i_h, b_w, b_h, 0.0, 1.0, 0.0},
|
||||
{ 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, i_h, 0.0, b_h, 0.0, 1.0, 0.0},
|
||||
/*a*/ {-1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0},
|
||||
/*c*/ { 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0},
|
||||
{ 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0},
|
||||
/*L*/ { 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0},
|
||||
/*e*/ { 1.0, -1.0, 1.0, 1.0, 0.0, 0.0, i_w, 0.0, b_w, 0.0, 0.0, 1.0, 0.0},
|
||||
/*f*/ { 1.0, -1.0, -1.0, 1.0, 0.0, 0.0, i_w, i_h, b_w, b_h, 0.0, 1.0, 0.0},
|
||||
{ 1.0, 1.0, -1.0, 1.0, 0.0, 0.0, 0.0, i_h, 0.0, b_h, 0.0, 1.0, 0.0},
|
||||
/*e*/ { 1.0, -1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0},
|
||||
/*f*/ { 1.0, -1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0},
|
||||
{ 1.0, 1.0, -1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0},
|
||||
/*T*/ { 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0},
|
||||
/*o*/ { 1.0, 1.0, -1.0, 0.0, 1.0, 0.0, i_w, 0.0, b_w, 0.0, 0.0, 0.0, 1.0},
|
||||
/*p*/ {-1.0, 1.0, -1.0, 0.0, 1.0, 0.0, i_w, i_h, b_w, b_h, 0.0, 0.0, 1.0},
|
||||
{-1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, i_h, 0.0, b_h, 0.0, 0.0, 1.0},
|
||||
/*o*/ { 1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0},
|
||||
/*p*/ {-1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0},
|
||||
{-1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0},
|
||||
/*B*/ { 1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0},
|
||||
/*o*/ { 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, i_w, 0.0, b_w, 0.0, 0.0, 0.0, -1.0},
|
||||
/*t*/ {-1.0, -1.0, 1.0, 0.0, -1.0, 0.0, i_w, i_h, b_w, b_h, 0.0, 0.0, -1.0},
|
||||
{-1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, i_h, 0.0, b_h, 0.0, 0.0, -1.0},
|
||||
/*o*/ { 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.0},
|
||||
/*t*/ {-1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, -1.0},
|
||||
{-1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0},
|
||||
};
|
||||
|
||||
GLushort indices[] = {
|
||||
|
@ -497,12 +494,12 @@ gst_gl_bumper_callback (gint width, gint height, guint texture, gpointer stuff)
|
|||
//set the normal map
|
||||
gl->ActiveTexture (GL_TEXTURE1);
|
||||
gst_gl_shader_set_uniform_1i (bumper->shader, "texture1", 1);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, bumper->bumpmap);
|
||||
gl->BindTexture (GL_TEXTURE_2D, bumper->bumpmap);
|
||||
|
||||
//set the video texture
|
||||
gl->ActiveTexture (GL_TEXTURE0);
|
||||
gst_gl_shader_set_uniform_1i (bumper->shader, "texture0", 0);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
||||
gl->BindTexture (GL_TEXTURE_2D, texture);
|
||||
|
||||
gl->Rotatef (xrot, 1.0f, 0.0f, 0.0f);
|
||||
gl->Rotatef (yrot, 0.0f, 1.0f, 0.0f);
|
||||
|
|
|
@ -68,45 +68,44 @@ static void gst_gl_deinterlace_callback (gint width, gint height,
|
|||
|
||||
/* *INDENT-OFF* */
|
||||
static const gchar *greedyh_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;\n"
|
||||
"uniform sampler2DRect tex_prev;\n"
|
||||
"uniform sampler2D tex;\n"
|
||||
"uniform sampler2D tex_prev;\n"
|
||||
"uniform float max_comb;\n"
|
||||
"uniform float motion_threshold;\n"
|
||||
"uniform float motion_sense;\n"
|
||||
"uniform int width;\n"
|
||||
"uniform int height;\n"
|
||||
"uniform float width;\n"
|
||||
"uniform float height;\n"
|
||||
|
||||
"void main () {\n"
|
||||
" vec2 texcoord = gl_TexCoord[0].xy;\n"
|
||||
" if (int(mod(texcoord.y, 2.0)) == 0) {\n"
|
||||
" gl_FragColor = vec4(texture2DRect(tex_prev, texcoord).rgb, 1.0);\n"
|
||||
" if (int(mod(texcoord.y * width, 2.0)) == 0) {\n"
|
||||
" gl_FragColor = vec4(texture2D(tex_prev, texcoord).rgb, 1.0);\n"
|
||||
" } else {\n"
|
||||
" vec2 texcoord_L1_a1, texcoord_L3_a1, texcoord_L1, texcoord_L3, texcoord_L1_1, texcoord_L3_1;\n"
|
||||
" vec3 L1_a1, L3_a1, L1, L3, L1_1, L3_1;\n"
|
||||
|
||||
" texcoord_L1 = vec2(texcoord.x, texcoord.y - 1.0);\n"
|
||||
" texcoord_L3 = vec2(texcoord.x, texcoord.y + 1.0);\n"
|
||||
" L1 = texture2DRect(tex_prev, texcoord_L1).rgb;\n"
|
||||
" L3 = texture2DRect(tex_prev, texcoord_L3).rgb;\n"
|
||||
" if (int(ceil(texcoord.x)) == width && int(ceil(texcoord.y)) == height) {\n"
|
||||
" texcoord_L1 = vec2(texcoord.x, texcoord.y - 1.0 / height);\n"
|
||||
" texcoord_L3 = vec2(texcoord.x, texcoord.y + 1.0 / height);\n"
|
||||
" L1 = texture2D(tex_prev, texcoord_L1).rgb;\n"
|
||||
" L3 = texture2D(tex_prev, texcoord_L3).rgb;\n"
|
||||
" if (texcoord.x == 1.0 && texcoord.y == 1.0) {\n"
|
||||
" L1_1 = L1;\n"
|
||||
" L3_1 = L3;\n"
|
||||
" } else {\n"
|
||||
" texcoord_L1_1 = vec2(texcoord.x + 1.0, texcoord.y - 1.0);\n"
|
||||
" texcoord_L3_1 = vec2(texcoord.x + 1.0, texcoord.y + 1.0);\n"
|
||||
" L1_1 = texture2DRect(tex_prev, texcoord_L1_1).rgb;\n"
|
||||
" L3_1 = texture2DRect(tex_prev, texcoord_L3_1).rgb;\n"
|
||||
" texcoord_L1_1 = vec2(texcoord.x + 1.0 / width, texcoord.y - 1.0 / height);\n"
|
||||
" texcoord_L3_1 = vec2(texcoord.x + 1.0 / width, texcoord.y + 1.0 / height);\n"
|
||||
" L1_1 = texture2D(tex_prev, texcoord_L1_1).rgb;\n"
|
||||
" L3_1 = texture2D(tex_prev, texcoord_L3_1).rgb;\n"
|
||||
" }\n"
|
||||
|
||||
" if (int(ceil(texcoord.x + texcoord.y)) == 0) {\n"
|
||||
" L1_a1 = L1;\n"
|
||||
" L3_a1 = L3;\n"
|
||||
" } else {\n"
|
||||
" texcoord_L1_a1 = vec2(texcoord.x - 1.0, texcoord.y - 1.0);\n"
|
||||
" texcoord_L3_a1 = vec2(texcoord.x - 1.0, texcoord.y + 1.0);\n"
|
||||
" L1_a1 = texture2DRect(tex_prev, texcoord_L1_a1).rgb;\n"
|
||||
" L3_a1 = texture2DRect(tex_prev, texcoord_L3_a1).rgb;\n"
|
||||
" texcoord_L1_a1 = vec2(texcoord.x - 1.0 / width, texcoord.y - 1.0 / height);\n"
|
||||
" texcoord_L3_a1 = vec2(texcoord.x - 1.0 / width, texcoord.y + 1.0 / height);\n"
|
||||
" L1_a1 = texture2D(tex_prev, texcoord_L1_a1).rgb;\n"
|
||||
" L3_a1 = texture2D(tex_prev, texcoord_L3_a1).rgb;\n"
|
||||
" }\n"
|
||||
//STEP 1
|
||||
" vec3 avg_a1 = (L1_a1 + L3_a1) / 2.0;\n"
|
||||
|
@ -114,8 +113,8 @@ static const gchar *greedyh_fragment_source =
|
|||
" vec3 avg_1 = (L1_1 + L3_1) / 2.0;\n"
|
||||
" vec3 avg_s = (avg_a1 + avg_1) / 2.0;\n"
|
||||
" vec3 avg_sc = (avg_s + avg) / 2.0;\n"
|
||||
" vec3 L2 = texture2DRect(tex, texcoord).rgb;\n"
|
||||
" vec3 LP2 = texture2DRect(tex_prev, texcoord).rgb;\n"
|
||||
" vec3 L2 = texture2D(tex, texcoord).rgb;\n"
|
||||
" vec3 LP2 = texture2D(tex_prev, texcoord).rgb;\n"
|
||||
" vec3 best;\n"
|
||||
" if (abs(L2.r - avg_sc.r) < abs(LP2.r - avg_sc.r)) {\n"
|
||||
" best.r = L2.r;\n" " } else {\n"
|
||||
|
@ -274,15 +273,15 @@ gst_gl_deinterlace_callback (gint width, gint height, guint texture,
|
|||
1.0, 1.0,
|
||||
-1.0, 1.0
|
||||
};
|
||||
GLfloat texcoords0[] = { 0, 0,
|
||||
width, 0,
|
||||
width, height,
|
||||
0, height
|
||||
GLfloat texcoords0[] = { 0.0f, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, 1.0f,
|
||||
0.0f, 1.0f
|
||||
};
|
||||
GLfloat texcoords1[] = { 0, 0,
|
||||
width, 0,
|
||||
width, height,
|
||||
0, height
|
||||
GLfloat texcoords1[] = { 0.0f, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, 1.0f,
|
||||
0.0f, 1.0f
|
||||
};
|
||||
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
|
@ -290,7 +289,7 @@ gst_gl_deinterlace_callback (gint width, gint height, guint texture,
|
|||
|
||||
gst_gl_shader_use (deinterlace_filter->shader);
|
||||
|
||||
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Enable (GL_TEXTURE_2D);
|
||||
|
||||
if (G_UNLIKELY (deinterlace_filter->prev_tex == 0)) {
|
||||
gst_gl_context_gen_texture (filter->context,
|
||||
|
@ -301,12 +300,12 @@ gst_gl_deinterlace_callback (gint width, gint height, guint texture,
|
|||
} else {
|
||||
gl->ActiveTexture (GL_TEXTURE1);
|
||||
gst_gl_shader_set_uniform_1i (deinterlace_filter->shader, "tex_prev", 1);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, deinterlace_filter->prev_tex);
|
||||
gl->BindTexture (GL_TEXTURE_2D, deinterlace_filter->prev_tex);
|
||||
}
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE0);
|
||||
gst_gl_shader_set_uniform_1i (deinterlace_filter->shader, "tex", 0);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
||||
gl->BindTexture (GL_TEXTURE_2D, texture);
|
||||
|
||||
gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "max_comb",
|
||||
5.0f / 255.0f);
|
||||
|
@ -315,9 +314,9 @@ gst_gl_deinterlace_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "motion_sense",
|
||||
30.0f / 255.0f);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (deinterlace_filter->shader, "width",
|
||||
gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "width",
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info));
|
||||
gst_gl_shader_set_uniform_1i (deinterlace_filter->shader, "height",
|
||||
gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "height",
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info));
|
||||
|
||||
gl->ClientActiveTexture (GL_TEXTURE0);
|
||||
|
@ -340,7 +339,7 @@ gst_gl_deinterlace_callback (gint width, gint height, guint texture,
|
|||
gl->ClientActiveTexture (GL_TEXTURE0);
|
||||
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
|
||||
if (texture == filter->in_tex_id) {
|
||||
temp = filter->in_tex_id;
|
||||
|
|
|
@ -86,19 +86,15 @@ gst_gl_differencematte_init_gl_resources (GstGLFilter * filter)
|
|||
|
||||
for (i = 0; i < 4; i++) {
|
||||
gl->GenTextures (1, &differencematte->midtexture[i]);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, differencematte->midtexture[i]);
|
||||
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->midtexture[i]);
|
||||
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
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);
|
||||
differencematte->shader[i] = gst_gl_shader_new (filter->context);
|
||||
}
|
||||
|
||||
|
@ -284,26 +280,26 @@ init_pixbuf_texture (GstGLContext * context, gpointer data)
|
|||
|
||||
gl->DeleteTextures (1, &differencematte->newbgtexture);
|
||||
gl->GenTextures (1, &differencematte->newbgtexture);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, differencematte->newbgtexture);
|
||||
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->newbgtexture);
|
||||
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
|
||||
(gint) differencematte->pbuf_width, (gint) differencematte->pbuf_height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, differencematte->pixbuf);
|
||||
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);
|
||||
|
||||
if (differencematte->savedbgtexture == 0) {
|
||||
gl->GenTextures (1, &differencematte->savedbgtexture);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, differencematte->savedbgtexture);
|
||||
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->savedbgtexture);
|
||||
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,16 +317,16 @@ gst_gl_differencematte_diff (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (differencematte->shader[0]);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE0);
|
||||
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 (differencematte->shader[0], "current", 0);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE1);
|
||||
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, differencematte->savedbgtexture);
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Enable (GL_TEXTURE_2D);
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->savedbgtexture);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (differencematte->shader[0], "saved", 1);
|
||||
|
||||
|
@ -351,14 +347,15 @@ gst_gl_differencematte_hblur (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (differencematte->shader[1]);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE0);
|
||||
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 (differencematte->shader[1], "tex", 0);
|
||||
|
||||
gst_gl_shader_set_uniform_1fv (differencematte->shader[1], "kernel", 7,
|
||||
differencematte->kernel);
|
||||
gst_gl_shader_set_uniform_1f (differencematte->shader[1], "width", width);
|
||||
|
||||
gst_gl_filter_draw_texture (filter, texture, width, height);
|
||||
}
|
||||
|
@ -377,14 +374,15 @@ gst_gl_differencematte_vblur (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (differencematte->shader[2]);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE0);
|
||||
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 (differencematte->shader[2], "tex", 0);
|
||||
|
||||
gst_gl_shader_set_uniform_1fv (differencematte->shader[2], "kernel", 7,
|
||||
differencematte->kernel);
|
||||
gst_gl_shader_set_uniform_1f (differencematte->shader[2], "height", height);
|
||||
|
||||
gst_gl_filter_draw_texture (filter, texture, width, height);
|
||||
}
|
||||
|
@ -403,32 +401,23 @@ gst_gl_differencematte_interp (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (differencematte->shader[3]);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE0);
|
||||
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 (differencematte->shader[3], "blend", 0);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE1);
|
||||
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, differencematte->newbgtexture);
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Enable (GL_TEXTURE_2D);
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->newbgtexture);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (differencematte->shader[3], "base", 1);
|
||||
gst_gl_shader_set_uniform_1f (differencematte->shader[3],
|
||||
"base_width", (gfloat) differencematte->pbuf_width);
|
||||
gst_gl_shader_set_uniform_1f (differencematte->shader[3],
|
||||
"base_height", (gfloat) differencematte->pbuf_height);
|
||||
|
||||
gst_gl_shader_set_uniform_1f (differencematte->shader[3],
|
||||
"final_width", (gfloat) GST_VIDEO_INFO_WIDTH (&filter->out_info));
|
||||
gst_gl_shader_set_uniform_1f (differencematte->shader[3],
|
||||
"final_height", (gfloat) GST_VIDEO_INFO_HEIGHT (&filter->out_info));
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE2);
|
||||
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, differencematte->midtexture[2]);
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Enable (GL_TEXTURE_2D);
|
||||
gl->BindTexture (GL_TEXTURE_2D, differencematte->midtexture[2]);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (differencematte->shader[3], "alpha", 2);
|
||||
|
||||
|
|
|
@ -197,19 +197,15 @@ gst_gl_effects_init_gl_resources (GstGLFilter * filter)
|
|||
|
||||
for (i = 0; i < NEEDED_TEXTURES; i++) {
|
||||
glGenTextures (1, &effects->midtexture[i]);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, effects->midtexture[i]);
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||
glBindTexture (GL_TEXTURE_2D, effects->midtexture[i]);
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
0, GL_RGBA, 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);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,16 +281,16 @@ gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex, guint width,
|
|||
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
|
||||
};
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE0);
|
||||
|
||||
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);
|
||||
|
|
|
@ -70,19 +70,15 @@ gst_gl_filterblur_init_resources (GstGLFilter * filter)
|
|||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gl->GenTextures (1, &filterblur->midtexture);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, filterblur->midtexture);
|
||||
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||
gl->BindTexture (GL_TEXTURE_2D, filterblur->midtexture);
|
||||
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
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);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -221,13 +217,14 @@ gst_gl_filterblur_hcallback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (filterblur->shader0);
|
||||
|
||||
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 (filterblur->shader0, "tex", 1);
|
||||
gst_gl_shader_set_uniform_1fv (filterblur->shader0, "kernel", 7,
|
||||
filterblur->gauss_kernel);
|
||||
gst_gl_shader_set_uniform_1f (filterblur->shader0, "width", width);
|
||||
|
||||
gst_gl_filter_draw_texture (filter, texture, width, height);
|
||||
}
|
||||
|
@ -247,13 +244,14 @@ gst_gl_filterblur_vcallback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (filterblur->shader1);
|
||||
|
||||
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 (filterblur->shader1, "tex", 1);
|
||||
gst_gl_shader_set_uniform_1fv (filterblur->shader1, "kernel", 7,
|
||||
filterblur->gauss_kernel);
|
||||
gst_gl_shader_set_uniform_1f (filterblur->shader1, "height", height);
|
||||
|
||||
gst_gl_filter_draw_texture (filter, texture, width, height);
|
||||
}
|
||||
|
|
|
@ -352,42 +352,39 @@ _callback_opengl (gint width, gint height, guint texture, gpointer stuff)
|
|||
static GLfloat yrot = 0;
|
||||
static GLfloat zrot = 0;
|
||||
|
||||
gfloat w = (gfloat) width;
|
||||
gfloat h = (gfloat) height;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
const GLfloat v_vertices[] = {
|
||||
/*| Vertex | TexCoord |*/
|
||||
/* front face */
|
||||
1.0, 1.0, -1.0, 0.0, 0.0,
|
||||
1.0, -1.0, -1.0, w, 0.0,
|
||||
-1.0, -1.0, -1.0, w, h,
|
||||
-1.0, 1.0, -1.0, 0.0, h,
|
||||
1.0, -1.0, -1.0, 1.0, 0.0,
|
||||
-1.0, -1.0, -1.0, 1.0, 1.0,
|
||||
-1.0, 1.0, -1.0, 0.0, 1.0,
|
||||
/* back face */
|
||||
-1.0, 1.0, 1.0, 0.0, 0.0,
|
||||
-1.0, -1.0, 1.0, w, 0.0,
|
||||
1.0, -1.0, 1.0, w, h,
|
||||
1.0, 1.0, 1.0, 0.0, h,
|
||||
-1.0, -1.0, 1.0, 1.0, 0.0,
|
||||
1.0, -1.0, 1.0, 1.0, 1.0,
|
||||
1.0, 1.0, 1.0, 0.0, 1.0,
|
||||
/* right face */
|
||||
-1.0, 1.0, -1.0, 0.0, 0.0,
|
||||
-1.0, -1.0, -1.0, w, 0.0,
|
||||
-1.0, -1.0, 1.0, w, h,
|
||||
-1.0, 1.0, 1.0, 0.0, h,
|
||||
-1.0, -1.0, -1.0, 1.0, 0.0,
|
||||
-1.0, -1.0, 1.0, 1.0, 1.0,
|
||||
-1.0, 1.0, 1.0, 0.0, 1.0,
|
||||
/* left face */
|
||||
1.0, 1.0, 1.0, 0.0, 0.0,
|
||||
1.0, -1.0, 1.0, w, 0.0,
|
||||
1.0, -1.0, -1.0, w, h,
|
||||
1.0, 1.0, -1.0, 0.0, h,
|
||||
1.0, -1.0, 1.0, 1.0, 0.0,
|
||||
1.0, -1.0, -1.0, 1.0, 1.0,
|
||||
1.0, 1.0, -1.0, 0.0, 1.0,
|
||||
/* top face */
|
||||
1.0, 1.0, 1.0, 0.0, 0.0,
|
||||
1.0, 1.0, -1.0, w, 0.0,
|
||||
-1.0, 1.0, -1.0, w, h,
|
||||
-1.0, 1.0, 1.0, 0.0, h,
|
||||
1.0, 1.0, -1.0, 1.0, 0.0,
|
||||
-1.0, 1.0, -1.0, 1.0, 1.0,
|
||||
-1.0, 1.0, 1.0, 0.0, 1.0,
|
||||
/* bottom face */
|
||||
1.0, -1.0, 1.0, 0.0, 0.0,
|
||||
1.0, -1.0, -1.0, w, 0.0,
|
||||
-1.0, -1.0, -1.0, w, h,
|
||||
-1.0, -1.0, 1.0, 0.0, h,
|
||||
1.0, -1.0, -1.0, 1.0, 0.0,
|
||||
-1.0, -1.0, -1.0, 1.0, 1.0,
|
||||
-1.0, -1.0, 1.0, 0.0, 1.0,
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
|
@ -408,8 +405,8 @@ _callback_opengl (gint width, gint height, guint texture, gpointer stuff)
|
|||
|
||||
gl->Enable (GL_DEPTH_TEST);
|
||||
|
||||
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->ClearColor (cube_filter->red, cube_filter->green, cube_filter->blue, 0.0);
|
||||
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
|
|
@ -76,15 +76,13 @@ static void gst_gl_filter_glass_callback (gpointer stuff);
|
|||
|
||||
/* *INDENT-OFF* */
|
||||
static const gchar *glass_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;\n"
|
||||
"uniform float width, height;\n"
|
||||
"uniform sampler2D tex;\n"
|
||||
"varying float alpha;\n"
|
||||
"void main () {\n"
|
||||
" float p = 0.0525;\n"
|
||||
" float L1 = p*width;\n"
|
||||
" float L2 = width - L1;\n"
|
||||
" float L3 = height - L1;\n"
|
||||
" float L1 = p*1.0;\n"
|
||||
" float L2 = 1.0 - L1;\n"
|
||||
" float L3 = 1.0 - L1;\n"
|
||||
" float w = 1.0;\n"
|
||||
" float r = L1;\n"
|
||||
" if (gl_TexCoord[0].x < L1 && gl_TexCoord[0].y < L1)\n"
|
||||
|
@ -97,13 +95,13 @@ static const gchar *glass_fragment_source =
|
|||
" r = sqrt( (gl_TexCoord[0].x - L1) * (gl_TexCoord[0].x - L1) + (gl_TexCoord[0].y - L3) * (gl_TexCoord[0].y - L3) );\n"
|
||||
" if (r > L1)\n"
|
||||
" w = 0.0;\n"
|
||||
" vec4 color = texture2DRect (tex, gl_TexCoord[0].st);\n"
|
||||
" vec4 color = texture2D (tex, gl_TexCoord[0].st);\n"
|
||||
" gl_FragColor = vec4(color.rgb, alpha * w);\n"
|
||||
"}\n";
|
||||
|
||||
static const gchar *glass_vertex_source =
|
||||
"uniform float yrot;\n"
|
||||
"uniform float width, height;\n"
|
||||
"uniform float aspect;\n"
|
||||
"const float fovy = 80.0;\n"
|
||||
"const float znear = 1.0;\n"
|
||||
"const float zfar = 5000.0;\n"
|
||||
|
@ -111,7 +109,6 @@ static const gchar *glass_vertex_source =
|
|||
"void main () {\n"
|
||||
" float f = 1.0/(tan(radians(fovy/2.0)));\n"
|
||||
" float rot = radians (yrot);\n"
|
||||
" float aspect = width/height;\n"
|
||||
" // replacement for gluPerspective\n"
|
||||
" mat4 perspective = mat4 (\n"
|
||||
" f/aspect, 0.0, 0.0, 0.0,\n"
|
||||
|
@ -306,17 +303,15 @@ gst_gl_filter_glass_draw_video_plane (GstGLFilter * filter,
|
|||
GstGLFilterGlass *glass_filter = GST_GL_FILTER_GLASS (filter);
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gfloat w = (gfloat) width;
|
||||
gfloat h = (gfloat) height;
|
||||
gfloat topy = reversed ? center_y - 1.0f : center_y + 1.0f;
|
||||
gfloat bottomy = reversed ? center_y + 1.0f : center_y - 1.0f;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
gfloat mesh[] = {
|
||||
/*| Vertex |TexCoord0| Colour |*/
|
||||
center_x-1.6, topy, 0.0, 0.0, h, 1.0, 1.0, 1.0, start_alpha,
|
||||
center_x+1.6, topy, 0.0, w, h, 1.0, 1.0, 1.0, start_alpha,
|
||||
center_x+1.6, bottomy, 0.0, w, 0.0, 1.0, 1.0, 1.0, stop_alpha,
|
||||
center_x-1.6, topy, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, start_alpha,
|
||||
center_x+1.6, topy, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, start_alpha,
|
||||
center_x+1.6, bottomy, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, stop_alpha,
|
||||
center_x-1.6, bottomy, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, stop_alpha,
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
@ -327,15 +322,14 @@ gst_gl_filter_glass_draw_video_plane (GstGLFilter * filter,
|
|||
};
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE0);
|
||||
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 (glass_filter->shader, "tex", 0);
|
||||
gst_gl_shader_set_uniform_1f (glass_filter->shader, "width", (gfloat) width);
|
||||
gst_gl_shader_set_uniform_1f (glass_filter->shader, "height",
|
||||
(gfloat) height);
|
||||
gst_gl_shader_set_uniform_1f (glass_filter->shader, "yrot", rotation);
|
||||
gst_gl_shader_set_uniform_1f (glass_filter->shader, "aspect",
|
||||
(gfloat) width / (gfloat) height);
|
||||
|
||||
gl->ClientActiveTexture (GL_TEXTURE0);
|
||||
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
|
@ -407,6 +401,6 @@ gst_gl_filter_glass_callback (gpointer stuff)
|
|||
|
||||
gst_gl_context_clear_shader (filter->context);
|
||||
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
gl->Disable (GL_BLEND);
|
||||
}
|
||||
|
|
|
@ -72,24 +72,26 @@ static void gst_gl_filter_laplacian_callback (gint width, gint height,
|
|||
kernel into the shader and remove unneeded zero multiplications in
|
||||
the convolution */
|
||||
static const gchar *convolution_fragment_source =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform sampler2D tex;"
|
||||
"uniform float kernel[9];"
|
||||
"uniform float width, height;"
|
||||
"void main () {"
|
||||
" float w = 1.0 / width;"
|
||||
" float h = 1.0 / height;"
|
||||
" vec2 texturecoord[9];"
|
||||
" texturecoord[4] = gl_TexCoord[0].st;" /* 0 0 */
|
||||
" texturecoord[5] = texturecoord[4] + vec2(1.0, 0.0);" /* 1 0 */
|
||||
" texturecoord[2] = texturecoord[5] - vec2(0.0, 1.0);" /* 1 -1 */
|
||||
" texturecoord[1] = texturecoord[2] - vec2(1.0, 0.0);" /* 0 -1 */
|
||||
" texturecoord[0] = texturecoord[1] - vec2(1.0, 0.0);" /* -1 -1 */
|
||||
" texturecoord[3] = texturecoord[0] + vec2(0.0, 1.0);" /* -1 0 */
|
||||
" texturecoord[6] = texturecoord[3] + vec2(0.0, 1.0);" /* -1 1 */
|
||||
" texturecoord[7] = texturecoord[6] + vec2(1.0, 0.0);" /* 0 1 */
|
||||
" texturecoord[8] = texturecoord[7] + vec2(1.0, 0.0);" /* 1 1 */
|
||||
" texturecoord[5] = texturecoord[4] + vec2(w, 0.0);" /* 1 0 */
|
||||
" texturecoord[2] = texturecoord[5] - vec2(0.0, h);" /* 1 -1 */
|
||||
" texturecoord[1] = texturecoord[2] - vec2(w, 0.0);" /* 0 -1 */
|
||||
" texturecoord[0] = texturecoord[1] - vec2(w, 0.0);" /* -1 -1 */
|
||||
" texturecoord[3] = texturecoord[0] + vec2(0.0, h);" /* -1 0 */
|
||||
" texturecoord[6] = texturecoord[3] + vec2(0.0, h);" /* -1 1 */
|
||||
" texturecoord[7] = texturecoord[6] + vec2(w, 0.0);" /* 0 1 */
|
||||
" texturecoord[8] = texturecoord[7] + vec2(w, 0.0);" /* 1 1 */
|
||||
" int i;"
|
||||
" vec4 sum = vec4 (0.0);"
|
||||
" for (i = 0; i < 9; i++) { "
|
||||
" vec4 neighbor = texture2DRect(tex, texturecoord[i]);"
|
||||
" vec4 neighbor = texture2D(tex, texturecoord[i]);"
|
||||
" sum += neighbor * kernel[i];"
|
||||
" }"
|
||||
" gl_FragColor = sum;"
|
||||
|
@ -206,11 +208,15 @@ gst_gl_filter_laplacian_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (laplacian_filter->shader);
|
||||
|
||||
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);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (laplacian_filter->shader, "tex", 0);
|
||||
gst_gl_shader_set_uniform_1fv (laplacian_filter->shader, "kernel", 9, kernel);
|
||||
gst_gl_shader_set_uniform_1f (laplacian_filter->shader, "width",
|
||||
(gfloat) width);
|
||||
gst_gl_shader_set_uniform_1f (laplacian_filter->shader, "height",
|
||||
(gfloat) height);
|
||||
|
||||
gst_gl_filter_draw_texture (filter, texture, width, height);
|
||||
}
|
||||
|
|
|
@ -249,47 +249,45 @@ gst_gl_filter_reflected_screen_draw_separated_screen (GstGLFilter * filter,
|
|||
{
|
||||
//enable ARB Rectangular texturing
|
||||
//that's necessary to have the video displayed on our screen (with gstreamer)
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glBindTexture (GL_TEXTURE_2D, texture);
|
||||
//configure parameters for the texturing
|
||||
//the two first are used to specified how the texturing will be done if the screen is greater than the texture herself
|
||||
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_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
//the next two specified how the texture will comport near the limits
|
||||
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);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
//creating screen and setting the texture (depending on texture's height and width)
|
||||
glBegin (GL_QUADS);
|
||||
|
||||
// right Face
|
||||
glColor4f (1.0f, 1.0f, 1.0f, alphs);
|
||||
glTexCoord2f ((gfloat) (width / 2.0), (gfloat) height);
|
||||
glTexCoord2f (0.5f, 1.0f);
|
||||
glVertex3f (-0.75f, 0.0f, -1.0f);
|
||||
glColor4f (1.0f, 1.0f, 1.0f, alphe);
|
||||
glTexCoord2f ((gfloat) (width / 2.0), 0.0f);
|
||||
glTexCoord2f (0.5f, 0.0f);
|
||||
glVertex3f (-0.75f, 1.25f, -1.0f);
|
||||
glTexCoord2f ((gfloat) width, 0.0f);
|
||||
glTexCoord2f (1.0f, 0.0f);
|
||||
glVertex3f (1.25f, 1.25f, -1.0f);
|
||||
glColor4f (1.0f, 1.0f, 1.0f, alphs);
|
||||
glTexCoord2f ((gfloat) width, (gfloat) height);
|
||||
glTexCoord2f (1.0f, 1.0f);
|
||||
glVertex3f (1.25f, 0.0f, -1.0f);
|
||||
// Left Face
|
||||
glColor4f (1.0f, 1.0f, 1.0f, alphs);
|
||||
glTexCoord2f (((gfloat) width / 2.0f), (gfloat) height);
|
||||
glTexCoord2f (0.5f, 1.0f);
|
||||
glVertex3f (-1.0f, 0.0f, -0.75f);
|
||||
glTexCoord2f (0.0f, (gfloat) height);
|
||||
glTexCoord2f (0.0f, 1.0f);
|
||||
glVertex3f (-1.0f, 0.0f, 1.25f);
|
||||
glColor4f (1.0f, 1.0f, 1.0f, alphe);
|
||||
glTexCoord2f (0.0f, 0.0f);
|
||||
glVertex3f (-1.0f, 1.25f, 1.25f);
|
||||
glTexCoord2f (((gfloat) width / 2.0f), 0.0f);
|
||||
glTexCoord2f (0.5f, 0.0f);
|
||||
glVertex3f (-1.0f, 1.25f, -0.75f);
|
||||
|
||||
glEnd ();
|
||||
glDisable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -298,43 +296,41 @@ gst_gl_filter_reflected_screen_draw_screen (GstGLFilter * filter,
|
|||
{
|
||||
//enable ARB Rectangular texturing
|
||||
//that's necessary to have the video displayed on our screen (with gstreamer)
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glBindTexture (GL_TEXTURE_2D, texture);
|
||||
//configure parameters for the texturing
|
||||
//the two first are used to specified how the texturing will be done if the screen is greater than the texture herself
|
||||
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_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
//the next two specified how the texture will comport near the limits
|
||||
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);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
//creating screen and setting the texture (depending on texture's height and width)
|
||||
glBegin (GL_QUADS);
|
||||
|
||||
glTexCoord2f ((gfloat) (width / 2.0), (gfloat) height);
|
||||
glTexCoord2f (0.5f, 1.0f);
|
||||
glVertex3f (-1.0f, 0.0f, -1.0f);
|
||||
glTexCoord2f ((gfloat) (width / 2.0), 0.0f);
|
||||
glTexCoord2f (0.5f, 0.0f);
|
||||
glVertex3f (-1.0f, 1.0f, -1.0f);
|
||||
glTexCoord2f ((gfloat) width, 0.0f);
|
||||
glTexCoord2f (1.0f, 0.0f);
|
||||
glVertex3f (1.0f, 1.0f, -1.0f);
|
||||
glTexCoord2f ((gfloat) width, (gfloat) height);
|
||||
glTexCoord2f (1.0f, 1.0f);
|
||||
glVertex3f (1.0f, 0.0f, -1.0f);
|
||||
// Left Face
|
||||
glTexCoord2f (((gfloat) width / 2.0f), (gfloat) height);
|
||||
glTexCoord2f (0.5f, 1.0f);
|
||||
glVertex3f (-1.0f, 0.0f, -1.0f);
|
||||
glTexCoord2f (0.0f, (gfloat) height);
|
||||
glTexCoord2f (0.0f, 1.0f);
|
||||
glVertex3f (-1.0f, 0.0f, 1.0f);
|
||||
glTexCoord2f (0.0f, 0.0f);
|
||||
glVertex3f (-1.0f, 1.0f, 1.0f);
|
||||
glTexCoord2f (((gfloat) width / 2.0f), 0.0f);
|
||||
glTexCoord2f (0.5f, 0.0f);
|
||||
glVertex3f (-1.0f, 1.0f, -1.0f);
|
||||
|
||||
glEnd ();
|
||||
|
||||
//disable this kind of texturing (useless for the gluDisk)
|
||||
glDisable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -89,16 +89,14 @@ static void gst_gl_filtershader_hcallback (gint width, gint height,
|
|||
static void
|
||||
gst_gl_filtershader_init_resources (GstGLFilter * filter)
|
||||
{
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
0, GL_RGBA, 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);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -360,9 +358,9 @@ gst_gl_filtershader_hcallback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (filtershader->shader0);
|
||||
|
||||
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 (filtershader->shader0, "tex", 1);
|
||||
|
||||
|
|
|
@ -76,19 +76,15 @@ gst_gl_filtersobel_init_resources (GstGLFilter * filter)
|
|||
|
||||
for (i = 0; i < 2; i++) {
|
||||
gl->GenTextures (1, &filtersobel->midtexture[i]);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, filtersobel->midtexture[i]);
|
||||
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||
gl->BindTexture (GL_TEXTURE_2D, filtersobel->midtexture[i]);
|
||||
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,9 +257,9 @@ gst_gl_filtersobel_length (gint width, gint height, guint texture,
|
|||
gst_gl_shader_use (filtersobel->len);
|
||||
|
||||
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 (filtersobel->len, "tex", 1);
|
||||
gst_gl_shader_set_uniform_1i (filtersobel->len, "invert",
|
||||
|
|
|
@ -1009,10 +1009,10 @@ gst_glimage_sink_on_draw (const GstGLImageSink * gl_sink)
|
|||
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (USING_OPENGL (gl_sink->context))
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
#endif
|
||||
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
gl->BindTexture (GL_TEXTURE_2D, 0);
|
||||
|
||||
/* check if a client draw callback is registered */
|
||||
if (gl_sink->clientDrawCallback) {
|
||||
|
@ -1037,19 +1037,18 @@ gst_glimage_sink_on_draw (const GstGLImageSink * gl_sink)
|
|||
-1.0f, -1.0f,
|
||||
1.0f, -1.0f
|
||||
};
|
||||
GLfloat texcoords[8] = { GST_VIDEO_INFO_WIDTH (&gl_sink->info), 0,
|
||||
0, 0,
|
||||
0, GST_VIDEO_INFO_HEIGHT (&gl_sink->info),
|
||||
GST_VIDEO_INFO_WIDTH (&gl_sink->info),
|
||||
GST_VIDEO_INFO_HEIGHT (&gl_sink->info)
|
||||
GLfloat texcoords[8] = { 1.0f, 0.0f,
|
||||
0.0f, 0.0f,
|
||||
0.0f, 1.0f,
|
||||
1.0f, 1.0f
|
||||
};
|
||||
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
gl->LoadIdentity ();
|
||||
|
||||
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, gl_sink->redisplay_texture);
|
||||
gl->Enable (GL_TEXTURE_2D);
|
||||
gl->BindTexture (GL_TEXTURE_2D, gl_sink->redisplay_texture);
|
||||
|
||||
gl->EnableClientState (GL_VERTEX_ARRAY);
|
||||
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
|
@ -1061,7 +1060,7 @@ gst_glimage_sink_on_draw (const GstGLImageSink * gl_sink)
|
|||
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
|
||||
|
|
|
@ -70,7 +70,6 @@ static void gst_gl_mosaic_callback (gpointer stuff);
|
|||
|
||||
//vertex source
|
||||
static const gchar *mosaic_v_src =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform mat4 u_matrix; \n"
|
||||
"uniform float xrot_degree, yrot_degree, zrot_degree; \n"
|
||||
"attribute vec4 a_position; \n"
|
||||
|
@ -103,13 +102,12 @@ static const gchar *mosaic_v_src =
|
|||
|
||||
//fragment source
|
||||
static const gchar *mosaic_f_src =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect s_texture; \n"
|
||||
"uniform sampler2D s_texture; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
//" gl_FragColor = vec4( 1.0, 0.5, 1.0, 1.0 );\n"
|
||||
" gl_FragColor = texture2DRect( s_texture, v_texCoord );\n"
|
||||
" gl_FragColor = texture2D( s_texture, v_texCoord );\n"
|
||||
"} \n";
|
||||
|
||||
static void
|
||||
|
@ -238,8 +236,8 @@ gst_gl_mosaic_callback (gpointer stuff)
|
|||
guint count = 0;
|
||||
|
||||
gst_gl_context_clear_shader (mixer->context);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->BindTexture (GL_TEXTURE_2D, 0);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
|
||||
gl->Enable (GL_DEPTH_TEST);
|
||||
|
||||
|
@ -277,58 +275,58 @@ gst_gl_mosaic_callback (gpointer stuff)
|
|||
v_vertices = (GLfloat[]) {
|
||||
/* front face */
|
||||
1.0f, 1.0f, -1.0f,
|
||||
width, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
width, height,
|
||||
1.0f, 1.0f,
|
||||
-1.0f, -1.0f, -1.0f,
|
||||
0.0f, height,
|
||||
0.0f, 1.0f,
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
0.0f, 0.0f,
|
||||
/* right face */
|
||||
1.0f, 1.0f, 1.0f,
|
||||
width, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, -1.0f, 1.0f,
|
||||
0.0f, 0.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
0.0f, height,
|
||||
0.0f, 1.0f,
|
||||
1.0f, 1.0f, -1.0f,
|
||||
width, height,
|
||||
1.0f, 1.0f,
|
||||
/* left face */
|
||||
-1.0f, 1.0f, 1.0f,
|
||||
width, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
width, height,
|
||||
1.0f, 1.0f,
|
||||
-1.0f, -1.0f, -1.0f,
|
||||
0.0f, height,
|
||||
0.0f, 1.0f,
|
||||
-1.0f, -1.0f, 1.0f,
|
||||
0.0f, 0.0f,
|
||||
/* top face */
|
||||
1.0f, -1.0f, 1.0f,
|
||||
width, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
-1.0f, -1.0f, 1.0f,
|
||||
0.0f, 0.0f,
|
||||
-1.0f, -1.0f, -1.0f,
|
||||
0.0f, height,
|
||||
0.0f, 1.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
width, height,
|
||||
1.0f, 1.0f,
|
||||
/* bottom face */
|
||||
1.0f, 1.0f, 1.0f,
|
||||
width, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, 1.0f, -1.0f,
|
||||
width, height,
|
||||
1.0f, 1.0f,
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
0.0f, height,
|
||||
0.0f, 1.0f,
|
||||
-1.0f, 1.0f, 1.0f,
|
||||
0.0f, 0.0f,
|
||||
/* back face */
|
||||
1.0f, 1.0f, 1.0f,
|
||||
width, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
-1.0f, 1.0f, 1.0f,
|
||||
0.0f, 0.0f,
|
||||
-1.0f, -1.0f, 1.0f,
|
||||
0.0f, height,
|
||||
0.0f, 1.0f,
|
||||
1.0f, -1.0f, 1.0f,
|
||||
width, height
|
||||
1.0f, 1.0f
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
|
@ -342,7 +340,7 @@ gst_gl_mosaic_callback (gpointer stuff)
|
|||
gl->EnableVertexAttribArray (attr_texture_loc);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE0);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, in_tex);
|
||||
gl->BindTexture (GL_TEXTURE_2D, in_tex);
|
||||
gst_gl_shader_set_uniform_1i (mosaic->shader, "s_texture", 0);
|
||||
gst_gl_shader_set_uniform_1f (mosaic->shader, "xrot_degree", xrot);
|
||||
gst_gl_shader_set_uniform_1f (mosaic->shader, "yrot_degree", yrot);
|
||||
|
@ -358,7 +356,7 @@ gst_gl_mosaic_callback (gpointer stuff)
|
|||
gl->DisableVertexAttribArray (attr_position_loc);
|
||||
gl->DisableVertexAttribArray (attr_texture_loc);
|
||||
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
gl->BindTexture (GL_TEXTURE_2D, 0);
|
||||
|
||||
gl->Disable (GL_DEPTH_TEST);
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
* </refsect2>
|
||||
*/
|
||||
|
||||
/* FIXME: Redo this */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
@ -272,8 +274,8 @@ gst_gl_overlay_init_texture (GstGLOverlay * o, GLuint tex, int flag)
|
|||
gl->Enable (GL_TEXTURE_2D);
|
||||
gl->BindTexture (GL_TEXTURE_2D, tex);
|
||||
} else {
|
||||
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, tex);
|
||||
gl->Enable (GL_TEXTURE_2D);
|
||||
gl->BindTexture (GL_TEXTURE_2D, tex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,8 +305,8 @@ gst_gl_overlay_draw (GstGLOverlay * o, int flag)
|
|||
/* *INDENT-ON* */
|
||||
|
||||
if (flag == 1) {
|
||||
width = o->width_window;
|
||||
height = o->height_window;
|
||||
width = 1.0f;
|
||||
height = 1.0f;
|
||||
} else if (flag == 0 && o->type_file == 1) {
|
||||
width = (gfloat) o->width;
|
||||
height = (gfloat) o->height;
|
||||
|
@ -400,7 +402,7 @@ gst_gl_overlay_load_texture (GstGLOverlay * o, GLuint tex, int flag)
|
|||
|
||||
gst_gl_overlay_draw (o, flag);
|
||||
if (flag == 1)
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -620,8 +622,8 @@ init_pixbuf_texture (GstGLContext * context, gpointer data)
|
|||
gl->DeleteTextures (1, &overlay->pbuftexture);
|
||||
gl->GenTextures (1, &overlay->pbuftexture);
|
||||
if (overlay->type_file == 1) {
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, overlay->pbuftexture);
|
||||
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
|
||||
gl->BindTexture (GL_TEXTURE_2D, overlay->pbuftexture);
|
||||
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
|
||||
(gint) overlay->width, (gint) overlay->height, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, overlay->pixbuf);
|
||||
} else if (overlay->type_file == 2) {
|
||||
|
|
|
@ -70,7 +70,6 @@ static void gst_gl_video_mixer_callback (gpointer stuff);
|
|||
|
||||
/* vertex source */
|
||||
static const gchar *video_mixer_v_src =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"attribute vec4 a_position; \n"
|
||||
"attribute vec2 a_texCoord; \n"
|
||||
"uniform float x_scale; \n"
|
||||
|
@ -83,12 +82,11 @@ static const gchar *video_mixer_v_src =
|
|||
|
||||
/* fragment source */
|
||||
static const gchar *video_mixer_f_src =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect texture; \n"
|
||||
"uniform sampler2D texture; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" vec4 rgba = texture2DRect( texture, v_texCoord );\n"
|
||||
" vec4 rgba = texture2D( texture, v_texCoord );\n"
|
||||
" gl_FragColor = vec4(rgba.rgb, 1.0);\n"
|
||||
"} \n";
|
||||
|
||||
|
@ -206,8 +204,8 @@ gst_gl_video_mixer_callback (gpointer stuff)
|
|||
out_height = GST_VIDEO_INFO_HEIGHT (&mixer->out_info);
|
||||
|
||||
gst_gl_context_clear_shader (mixer->context);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->BindTexture (GL_TEXTURE_2D, 0);
|
||||
gl->Disable (GL_TEXTURE_2D);
|
||||
|
||||
gl->Disable (GL_DEPTH_TEST);
|
||||
gl->Disable (GL_CULL_FACE);
|
||||
|
@ -278,7 +276,7 @@ gst_gl_video_mixer_callback (gpointer stuff)
|
|||
gl->BlendEquation (GL_FUNC_ADD);
|
||||
|
||||
gl->ActiveTexture (GL_TEXTURE0);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, in_tex);
|
||||
gl->BindTexture (GL_TEXTURE_2D, in_tex);
|
||||
gst_gl_shader_set_uniform_1i (video_mixer->shader, "texture", 0);
|
||||
gst_gl_shader_set_uniform_1f (video_mixer->shader, "x_scale", w);
|
||||
gst_gl_shader_set_uniform_1f (video_mixer->shader, "y_scale", h);
|
||||
|
@ -291,7 +289,7 @@ gst_gl_video_mixer_callback (gpointer stuff)
|
|||
gl->DisableVertexAttribArray (attr_position_loc);
|
||||
gl->DisableVertexAttribArray (attr_texture_loc);
|
||||
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
gl->BindTexture (GL_TEXTURE_2D, 0);
|
||||
|
||||
gl->Disable (GL_BLEND);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -137,14 +137,14 @@ update_texture_actor (gpointer data)
|
|||
tex_id = *(guint *) frame.data[0];
|
||||
|
||||
/* Create a cogl texture from the gst gl texture */
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, tex_id);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glBindTexture (GL_TEXTURE_2D, tex_id);
|
||||
if (glGetError () != GL_NO_ERROR)
|
||||
g_debug ("failed to bind texture that comes from gst-gl\n");
|
||||
cogl_texture = cogl_texture_new_from_foreign (tex_id,
|
||||
GL_TEXTURE_RECTANGLE_ARB, v_meta->width, v_meta->height, 0, 0,
|
||||
GL_TEXTURE_2D, v_meta->width, v_meta->height, 0, 0,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
|
||||
gst_video_frame_unmap (&frame);
|
||||
|
||||
|
|
|
@ -100,14 +100,12 @@ DrawGLScene (GstGLBuffer * gst_gl_buf)
|
|||
glVertex3f (-1.0f, -1.0f, 0.0f); // Bottom Left
|
||||
glEnd (); // we're done with the polygon (smooth color interpolation)
|
||||
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
||||
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);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glBindTexture (GL_TEXTURE_2D, texture);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
|
||||
glLoadIdentity (); // make sure we're no longer rotated.
|
||||
|
@ -127,7 +125,7 @@ DrawGLScene (GstGLBuffer * gst_gl_buf)
|
|||
glVertex3f (-1.0f, -1.0f, 0.0f); // Bottom Left
|
||||
glEnd (); // done with the polygon
|
||||
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
|
||||
rtri += 1.0f; // Increase The Rotation Variable For The Triangle
|
||||
rquad -= 1.0f; // Decrease The Rotation Variable For The Quad
|
||||
|
|
Loading…
Reference in a new issue