mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
[105/906] up Sobel filter and gl/glew version checker
git-svn-id: svn://svn.wobow.com/GStreamer_playground/gst-plugins-gl@518 93df14bb-0f41-7a43-8087-d3e2a2f0e464
This commit is contained in:
parent
f0a68351b3
commit
646aaf4cd3
2 changed files with 46 additions and 22 deletions
|
@ -496,24 +496,26 @@ gst_gl_display_glutCreateWindow (GstGLDisplay *display)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//OpenGL > 2.1.0 and Glew > 1.5.0
|
//OpenGL > 2.1.0 and Glew > 1.5.0
|
||||||
GString* opengl_version = g_string_new ((gchar*) glGetString (GL_VERSION));
|
GString* opengl_version = g_string_truncate (g_string_new ((gchar*) glGetString (GL_VERSION)), 3);
|
||||||
gboolean check_versions = g_str_has_prefix (opengl_version->str, "2.1");
|
gfloat opengl_version_f = 0.0f;
|
||||||
GString* glew_version = g_string_new ((gchar*) glewGetString (GLEW_VERSION));
|
GString* glew_version = g_string_truncate (g_string_new ((gchar*) glewGetString (GLEW_VERSION)), 3);
|
||||||
check_versions = check_versions && g_str_has_prefix (glew_version->str, "1.5");
|
gfloat glew_version_f = 0.0f;
|
||||||
|
|
||||||
|
sscanf(opengl_version->str, "%f", &opengl_version_f);
|
||||||
|
sscanf(glew_version->str, "%f", &glew_version_f);
|
||||||
|
|
||||||
GST_DEBUG ("GL_VERSION: %s", opengl_version->str);
|
GST_DEBUG ("GL_VERSION: %s", glGetString (GL_VERSION));
|
||||||
GST_DEBUG ("GLEW_VERSION: %s", glew_version->str);
|
GST_DEBUG ("GLEW_VERSION: %s", glewGetString (GLEW_VERSION));
|
||||||
|
|
||||||
GST_DEBUG ("GL_VENDOR: %s\n", glGetString (GL_VENDOR));
|
GST_DEBUG ("GL_VENDOR: %s", glGetString (GL_VENDOR));
|
||||||
GST_DEBUG ("GL_RENDERER: %s\n", glGetString (GL_RENDERER));
|
GST_DEBUG ("GL_RENDERER: %s", glGetString (GL_RENDERER));
|
||||||
|
|
||||||
g_string_free (opengl_version, TRUE);
|
g_string_free (opengl_version, TRUE);
|
||||||
g_string_free (glew_version, TRUE);
|
g_string_free (glew_version, TRUE);
|
||||||
|
|
||||||
if (!check_versions)
|
if (opengl_version_f < 1.4f || glew_version_f < 1.4)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("Required OpenGL > 2.1.0 and Glew > 1.5.0");
|
GST_DEBUG ("Required OpenGL >= 1.4.0 and Glew >= 1.4.0");
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
||||||
static const GstElementDetails element_details =
|
static const GstElementDetails element_details =
|
||||||
GST_ELEMENT_DETAILS ("OpenGL edge filter",
|
GST_ELEMENT_DETAILS ("OpenGL edge filter",
|
||||||
"Filter/Effect",
|
"Filter/Effect",
|
||||||
"Edge detection",
|
"Edge detection using GLSL",
|
||||||
"Julien Isorce <julien.isorce@gmail.com>");
|
"Julien Isorce <julien.isorce@gmail.com>");
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -86,12 +86,33 @@ gst_gl_filter_edge_init (GstGLFilterEdge* filter,
|
||||||
filter->textShader =
|
filter->textShader =
|
||||||
"uniform sampler2DRect tex;\n"
|
"uniform sampler2DRect tex;\n"
|
||||||
"void main(void) {\n"
|
"void main(void) {\n"
|
||||||
" float r,g,b,y;\n"
|
" const int N = 8;\n"
|
||||||
" vec2 nxy=gl_TexCoord[0].xy;\n"
|
" const vec2 delta[N] = vec2[N](\n"
|
||||||
" r=texture2DRect(tex,nxy).r;\n"
|
" vec2( -1.0, -1.0 ),\n"
|
||||||
" g=texture2DRect(tex,nxy).g;\n"
|
" vec2( -1.0 , 0.0 ),\n"
|
||||||
" b=texture2DRect(tex,nxy).b;\n"
|
" vec2( -1.0 , 1.0 ),\n"
|
||||||
" gl_FragColor=vec4(b,g,r,1.0);\n"
|
" vec2( 0.0 , 1.0 ),\n"
|
||||||
|
" vec2( 1.0 , 1.0 ),\n"
|
||||||
|
" vec2( 1.0 , 0.0 ),\n"
|
||||||
|
" vec2( 1.0 , -1.0 ),\n"
|
||||||
|
" vec2( 0.0 , -1.0 )\n"
|
||||||
|
" );\n"
|
||||||
|
" const float filterH[N] = float[N]\n"
|
||||||
|
" (-1.0, 0.0, 1.0, 2.0, 1.0, 0.0, -1.0, -2.0);\n"
|
||||||
|
" const float filterV[N] = float[N]\n"
|
||||||
|
" (-1.0, -2.0, -1.0, 0.0, 1.0, 2.0, 1.0, 0.0);\n"
|
||||||
|
" float gH = 0.0;\n"
|
||||||
|
" float gV = 0.0;\n"
|
||||||
|
" int i;\n"
|
||||||
|
" vec2 nxy = gl_TexCoord[0].xy;\n"
|
||||||
|
" for (i = 0; i < N; i++) {\n"
|
||||||
|
" vec4 vcolor_i = texture2DRect(tex, nxy + delta[i]);\n"
|
||||||
|
" float gray_i = (vcolor_i.r + vcolor_i.g + vcolor_i.b) / 3.0;\n"
|
||||||
|
" gH += gH + filterH[i] * gray_i;\n"
|
||||||
|
" gV += gV + filterV[i] * gray_i;\n"
|
||||||
|
" }\n"
|
||||||
|
" float g = sqrt(gH * gH + gV * gV) / 8.0;\n"
|
||||||
|
" gl_FragColor = vec4(g, g, g, 1.0);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,13 +207,14 @@ gst_gl_filter_edge_callback (guint width, guint height, guint texture, GLhandleA
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
||||||
|
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
glTexCoord2i (width, 0);
|
|
||||||
glVertex2f (1.0f, 1.0f);
|
|
||||||
glTexCoord2i (0, 0);
|
glTexCoord2i (0, 0);
|
||||||
glVertex2f (-1.0f, 1.0f);
|
|
||||||
glTexCoord2i (0, height);
|
|
||||||
glVertex2f (-1.0f, -1.0f);
|
glVertex2f (-1.0f, -1.0f);
|
||||||
glTexCoord2i (width, height);
|
glTexCoord2i (width, 0);
|
||||||
glVertex2f (1.0f, -1.0f);
|
glVertex2f (1.0f, -1.0f);
|
||||||
|
glTexCoord2i (width, height);
|
||||||
|
glVertex2f (1.0f, 1.0f);
|
||||||
|
glTexCoord2i (0, height);
|
||||||
|
glVertex2f (-1.0f, 1.0f);
|
||||||
|
|
||||||
glEnd ();
|
glEnd ();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue