[647/906] remove dependecy on glew

This commit is contained in:
Matthew Waters 2013-01-16 15:21:44 +11:00
parent 2f21abac2e
commit 7b03a572d9
36 changed files with 1641 additions and 1757 deletions

View file

@ -25,3 +25,4 @@
#include "glprototypes/gles1gles2opengl.h"
#include "glprototypes/gles2.h"
#include "glprototypes/gles2opengl.h"
#include "glprototypes/gles3opengl.h"

View file

@ -0,0 +1,56 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/* This lists functions that are unique to GL 2.1 or GLES 3.0 and are
* not in the old GLSL extensions */
GST_GL_EXT_BEGIN (shaders_2_1, 2, 1,
GST_GL_API_GLES3,
"\0",
"\0")
GST_GL_EXT_FUNCTION (void, UniformMatrix2x3fv,
(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
GST_GL_EXT_FUNCTION (void, UniformMatrix3x2fv,
(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
GST_GL_EXT_FUNCTION (void, UniformMatrix2x4fv,
(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
GST_GL_EXT_FUNCTION (void, UniformMatrix4x2fv,
(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
GST_GL_EXT_FUNCTION (void, UniformMatrix3x4fv,
(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
GST_GL_EXT_FUNCTION (void, UniformMatrix4x3fv,
(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
GST_GL_EXT_END ()
GST_GL_EXT_BEGIN (read_buffer, 1, 0,
GST_GL_API_GLES3,
"\0",
"\0")
GST_GL_EXT_FUNCTION (void, ReadBuffer,
(GLenum mode))
GST_GL_EXT_END ()
GST_GL_EXT_BEGIN (draw_buffers, 2, 1,
GST_GL_API_GLES3,
"ARB\0ATI\0",
"draw_buffers\0")
GST_GL_EXT_FUNCTION (void, DrawBuffers,
(GLsizei n, const GLenum *bufs))
GST_GL_EXT_END ()

View file

@ -22,3 +22,4 @@
#include "glprototypes/gles1opengl.h"
#include "glprototypes/gles1gles2opengl.h"
#include "glprototypes/gles2opengl.h"
#include "glprototypes/gles3opengl.h"

View file

@ -20,53 +20,6 @@
#include "gstglapi.h"
#define GST_GL_EXT_BEGIN(name, min_gl, maj_gl, in_gles, ext_suf, ext_name)
#define GST_GL_EXT_FUNCTION(ret, name, args) \
NULL,
#define GST_GL_EXT_END()
#if GST_GL_HAVE_OPENGL
static GstGLFuncs gst_gl = {
#include "glprototypes/opengl.h"
{NULL,},
#include "glprototypes/gles1opengl.h"
{NULL,},
#include "glprototypes/gles2opengl.h"
{NULL,},
#include "glprototypes/gles1gles2opengl.h"
{NULL,},
};
const GstGLFuncs *
gst_gl_get_opengl_vtable (void)
{
return &gst_gl;
}
#endif
#if GST_GL_HAVE_GLES2
static GstGLES2Funcs gst_gles2 = {
#include "glprototypes/gles1gles2.h"
{NULL,},
#include "glprototypes/gles1gles2opengl.h"
{NULL,},
#include "glprototypes/gles2.h"
{NULL,},
#include "glprototypes/gles2opengl.h"
{NULL,},
};
const GstGLES2Funcs *
gst_gl_get_gles2_vtable (void)
{
return &gst_gles2;
}
#endif
#undef GST_GL_EXT_BEGIN
#undef GST_GL_EXT_FUNCTION
#undef GST_GL_EXT_END
gchar *
gst_gl_api_string (GstGLAPI api)
{

View file

@ -35,11 +35,10 @@
/* OpenGL for desktop systems */
#if GST_GL_HAVE_OPENGL
# if __APPLE__
# include <GL/glew.h>
# include <OpenGL/OpenGL.h>
# include <OpenGL/gl.h>
# else
# include <GL/glew.h>
# include <GL/glu.h>
# include <GL/gl.h>
# endif
#endif
@ -75,37 +74,25 @@ typedef enum
ret (*name) args;
#define GST_GL_EXT_END()
#if GST_GL_HAVE_OPENGL
typedef struct _GstGLFuncs
{
#include "glprototypes/opengl.h"
gpointer padding1[GST_PADDING_LARGE];
#include "glprototypes/gles1opengl.h"
#include "glprototypes/gles1.h"
gpointer padding2[GST_PADDING_LARGE];
#include "glprototypes/gles2opengl.h"
gpointer padding3[GST_PADDING_LARGE*2];
#include "glprototypes/gles1gles2opengl.h"
gpointer padding4[GST_PADDING_LARGE*4];
} GstGLFuncs;
const GstGLFuncs *gst_gl_get_opengl_vtable (void);
#endif
#if GST_GL_HAVE_GLES2
typedef struct _GstGLES2Funcs
{
#include "glprototypes/gles1gles2.h"
gpointer padding1[GST_PADDING_LARGE];
#include "glprototypes/gles1gles2opengl.h"
gpointer padding3[GST_PADDING_LARGE];
#include "glprototypes/gles1opengl.h"
gpointer padding4[GST_PADDING_LARGE*2];
#include "glprototypes/gles2.h"
gpointer padding2[GST_PADDING_LARGE*2];
gpointer padding5[GST_PADDING_LARGE*2];
#include "glprototypes/gles2opengl.h"
gpointer padding4[GST_PADDING_LARGE*4];
} GstGLES2Funcs;
const GstGLES2Funcs *gst_gl_get_gles2_vtable (void);
#endif
gpointer padding6[GST_PADDING_LARGE*2];
#include "glprototypes/gles1gles2opengl.h"
gpointer padding7[GST_PADDING_LARGE*2];
#include "glprototypes/gles3opengl.h"
gpointer padding8[GST_PADDING_LARGE*4];
} GstGLFuncs;
#undef GST_GL_EXT_BEGIN
#undef GST_GL_EXT_FUNCTION

File diff suppressed because it is too large Load diff

View file

@ -159,6 +159,8 @@ struct _GstGLDisplay
gchar *error_message;
GstGLFuncs *gl_vtable;
GstGLDisplayPrivate *priv;
};
@ -219,13 +221,15 @@ void gst_gl_display_activate_gl_context (GstGLDisplay * display, gboolean activa
/* Must be called inside a lock/unlock on display, or within the glthread */
void gst_gl_display_set_error (GstGLDisplay * display, const char * format, ...);
void gst_gl_display_check_framebuffer_status (void);
gboolean gst_gl_display_check_framebuffer_status (GstGLDisplay * display);
void gst_gl_display_lock (GstGLDisplay * display);
void gst_gl_display_unlock (GstGLDisplay * display);
GstGLAPI gst_gl_display_get_gl_api (GstGLDisplay * display);
GstGLAPI gst_gl_display_get_gl_api_unlocked (GstGLDisplay * display);
gpointer gst_gl_display_get_gl_vtable (GstGLDisplay * display);
G_END_DECLS
#endif /* __GST_GL_H__ */

View file

@ -717,9 +717,11 @@ gst_gl_display_find_download (GstGLDisplay * display, GstVideoFormat v_format,
static void
_init_download (GstGLDisplay * display, GstGLDownload * download)
{
GstGLFuncs *gl;
GstVideoFormat v_format;
guint out_width, out_height;
gl = display->gl_vtable;
v_format = GST_VIDEO_INFO_FORMAT (&download->info);
out_width = GST_VIDEO_INFO_WIDTH (&download->info);
out_height = GST_VIDEO_INFO_HEIGHT (&download->info);
@ -764,7 +766,7 @@ _init_download (GstGLDisplay * display, GstGLDownload * download)
/* color space conversion is needed */
{
if (!GLEW_EXT_framebuffer_object) {
if (!gl->GenFramebuffers) {
/* Frame buffer object is a requirement
* when using GLSL colorspace conversion
*/
@ -775,107 +777,102 @@ _init_download (GstGLDisplay * display, GstGLDownload * download)
GST_INFO ("Context, EXT_framebuffer_object supported: yes");
/* setup FBO */
glGenFramebuffersEXT (1, &download->fbo);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, download->fbo);
gl->GenFramebuffers (1, &download->fbo);
gl->BindFramebuffer (GL_FRAMEBUFFER, download->fbo);
/* setup the render buffer for depth */
glGenRenderbuffersEXT (1, &download->depth_buffer);
glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, download->depth_buffer);
gl->GenRenderbuffers (1, &download->depth_buffer);
gl->BindRenderbuffer (GL_RENDERBUFFER, download->depth_buffer);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (display)) {
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT,
out_width, out_height);
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT,
gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
out_width, out_height);
}
#endif
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (display)) {
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
out_width, out_height);
}
#endif
/* setup a first texture to render to */
glGenTextures (1, &download->out_texture[0]);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, download->out_texture[0]);
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
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,
out_width, out_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
/* attach the first texture to the FBO to renderer to */
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_RECTANGLE_ARB, 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 */
glGenTextures (1, &download->out_texture[1]);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, download->out_texture[1]);
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
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,
out_width, out_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
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);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
/* attach the second texture to the FBO to renderer to */
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_ARB,
gl->FramebufferTexture2D (GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT1, GL_TEXTURE_RECTANGLE_ARB,
download->out_texture[1], 0);
/* setup a third texture to render to */
glGenTextures (1, &download->out_texture[2]);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, download->out_texture[2]);
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
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,
out_width, out_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
/* attach the third texture to the FBO to renderer to */
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_RECTANGLE_ARB,
gl->FramebufferTexture2D (GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT2, GL_TEXTURE_RECTANGLE_ARB,
download->out_texture[2], 0);
}
/* attach the depth render buffer to the FBO */
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, download->depth_buffer);
gl->FramebufferRenderbuffer (GL_FRAMEBUFFER,
GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, download->depth_buffer);
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (display)) {
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT,
GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT,
download->depth_buffer);
gl->FramebufferRenderbuffer (GL_FRAMEBUFFER,
GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, download->depth_buffer);
}
#endif
gst_gl_display_check_framebuffer_status ();
if (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) !=
GL_FRAMEBUFFER_COMPLETE_EXT) {
if (!gst_gl_display_check_framebuffer_status (display))
gst_gl_display_set_error (display, "GL framebuffer status incomplete");
}
/* unbind the FBO */
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
}
break;
default:
@ -908,7 +905,7 @@ _create_shader (GstGLDisplay * display, const gchar * vertex_src,
if (!gst_gl_shader_compile (shader, &error)) {
gst_gl_display_set_error (display, "%s", error->message);
g_error_free (error);
gst_gl_shader_use (NULL);
gst_gl_display_clear_shader (display);
g_object_unref (G_OBJECT (shader));
return FALSE;
}
@ -920,8 +917,10 @@ _create_shader (GstGLDisplay * display, const gchar * vertex_src,
static void
_init_download_shader (GstGLDisplay * display, GstGLDownload * download)
{
GstGLFuncs *gl;
GstVideoFormat v_format;
gl = display->gl_vtable;
v_format = GST_VIDEO_INFO_FORMAT (&download->info);
switch (v_format) {
@ -963,7 +962,7 @@ _init_download_shader (GstGLDisplay * display, GstGLDownload * download)
/* check if fragment shader is available, then load them
* GLSL is a requirement for download
*/
if (!GLEW_ARB_fragment_shader) {
if (!gl->CreateProgramObject && !gl->CreateProgram) {
/* colorspace conversion is not possible */
gst_gl_display_set_error (display,
"Context, ARB_fragment_shader supported: no");
@ -1097,41 +1096,43 @@ _do_download (GstGLDisplay * display, GstGLDownload * download)
static void
_do_download_draw_rgb_opengl (GstGLDisplay * display, GstGLDownload * download)
{
GstGLFuncs *gl;
GstVideoFormat v_format;
if (download->display->colorspace_conversion ==
GST_GL_DISPLAY_CONVERSION_GLSL)
glUseProgramObjectARB (0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
gl = display->gl_vtable;
gst_gl_display_clear_shader (display);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
v_format = GST_VIDEO_INFO_FORMAT (&download->info);
switch (v_format) {
case GST_VIDEO_FORMAT_RGBA:
case GST_VIDEO_FORMAT_RGBx:
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 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
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8, download->data[0]);
#else
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 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:
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 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
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
GL_UNSIGNED_INT_8_8_8_8, download->data[0]);
#else
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
@ -1139,11 +1140,11 @@ _do_download_draw_rgb_opengl (GstGLDisplay * display, GstGLDownload * download)
#endif /* G_BYTE_ORDER */
break;
case GST_VIDEO_FORMAT_RGB:
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
GL_UNSIGNED_BYTE, download->data[0]);
break;
case GST_VIDEO_FORMAT_BGR:
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGR,
gl->GetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGR,
GL_UNSIGNED_BYTE, download->data[0]);
break;
default:
@ -1163,6 +1164,7 @@ _do_download_draw_rgb_opengl (GstGLDisplay * display, GstGLDownload * download)
static void
_do_download_draw_rgb_gles2 (GstGLDisplay * display, GstGLDownload * download)
{
GstGLFuncs *gl;
GstVideoFormat v_format;
guint out_width, out_height;
@ -1178,54 +1180,56 @@ _do_download_draw_rgb_gles2 (GstGLDisplay * display, GstGLDownload * download)
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
gl = display->gl_vtable;
out_width = GST_VIDEO_INFO_WIDTH (&download->info);
out_height = GST_VIDEO_INFO_HEIGHT (&download->info);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, download->fbo);
gl->BindFramebuffer (GL_FRAMEBUFFER, download->fbo);
glViewport (0, 0, out_width, out_height);
gl->Viewport (0, 0, out_width, out_height);
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (download->shader);
glVertexAttribPointer (download->shader_attr_position_loc, 3,
gl->VertexAttribPointer (download->shader_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
glVertexAttribPointer (download->shader_attr_texture_loc, 2,
gl->VertexAttribPointer (download->shader_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
glEnableVertexAttribArray (download->shader_attr_position_loc);
glEnableVertexAttribArray (download->shader_attr_texture_loc);
gl->EnableVertexAttribArray (download->shader_attr_position_loc);
gl->EnableVertexAttribArray (download->shader_attr_texture_loc);
glActiveTextureARB (GL_TEXTURE0_ARB);
gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (download->shader, "s_texture", 0);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
glUseProgramObjectARB (0);
gst_gl_display_clear_shader (display);
v_format = GST_VIDEO_INFO_FORMAT (&download->info);
switch (v_format) {
case GST_VIDEO_FORMAT_RGBA:
case GST_VIDEO_FORMAT_RGBx:
glReadPixels (0, 0, out_width, out_height, GL_RGBA, GL_UNSIGNED_BYTE,
gl->ReadPixels (0, 0, out_width, out_height, 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
glReadPixels (0, 0, out_width, out_height, GL_BGRA,
gl->ReadPixels (0, 0, out_width, out_height, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8, download->data[0]);
#else
glReadPixels (0, 0, out_width, out_eight, GL_BGRA,
gl->ReadPixels (0, 0, out_width, out_eight, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV, download->data[0]);
#endif /* G_BYTE_ORDER */
break;
case GST_VIDEO_FORMAT_RGB:
glReadPixels (0, 0, out_width, out_height, GL_RGB, GL_UNSIGNED_BYTE,
gl->ReadPixels (0, 0, out_width, out_height, GL_RGB, GL_UNSIGNED_BYTE,
download->data[0]);
break;
case GST_VIDEO_FORMAT_BGRx:
@ -1247,76 +1251,89 @@ _do_download_draw_rgb_gles2 (GstGLDisplay * display, GstGLDownload * download)
static void
_do_download_draw_yuv_opengl (GstGLDisplay * display, GstGLDownload * download)
{
GstGLFuncs *gl;
GstVideoFormat v_format;
guint out_width, out_height;
guint out_width = GST_VIDEO_INFO_WIDTH (&download->info);
guint out_height = GST_VIDEO_INFO_HEIGHT (&download->info);
GLenum multipleRT[] = {
GL_COLOR_ATTACHMENT0_EXT,
GL_COLOR_ATTACHMENT1_EXT,
GL_COLOR_ATTACHMENT2_EXT
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2
};
out_width = GST_VIDEO_INFO_WIDTH (&download->info);
out_height = GST_VIDEO_INFO_HEIGHT (&download->info);
gfloat verts[8] = { -1.0f, -1.0f,
1.0f, -1.0f,
1.0f, 1.0f,
-1.0f, 1.0f
};
gint texcoords[8] = { 0, 0,
out_width, 0,
out_width, out_height,
0, out_height
};
gl = display->gl_vtable;
v_format = GST_VIDEO_INFO_FORMAT (&download->info);
GST_TRACE ("doing YUV download of texture:%u (%ux%u) using fbo:%u",
download->in_texture, out_width, out_height, download->fbo);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, download->fbo);
gl->BindFramebuffer (GL_FRAMEBUFFER, download->fbo);
glPushAttrib (GL_VIEWPORT_BIT);
gl->PushAttrib (GL_VIEWPORT_BIT);
glMatrixMode (GL_PROJECTION);
glPushMatrix ();
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->PushMatrix ();
gl->LoadIdentity ();
gluOrtho2D (0.0, out_width, 0.0, out_height);
glMatrixMode (GL_MODELVIEW);
glPushMatrix ();
glLoadIdentity ();
gl->MatrixMode (GL_MODELVIEW);
gl->PushMatrix ();
gl->LoadIdentity ();
glViewport (0, 0, out_width, out_height);
gl->Viewport (0, 0, out_width, out_height);
switch (v_format) {
case GST_VIDEO_FORMAT_YUY2:
case GST_VIDEO_FORMAT_UYVY:
case GST_VIDEO_FORMAT_AYUV:
{
glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT);
gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (download->shader);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
glActiveTextureARB (GL_TEXTURE0_ARB);
gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (download->shader, "tex", 0);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
}
break;
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12:
{
glDrawBuffers (3, multipleRT);
gl->DrawBuffers (3, multipleRT);
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (download->shader);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
glActiveTextureARB (GL_TEXTURE0_ARB);
gl->ActiveTexture (GL_TEXTURE0_ARB);
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);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
}
break;
@ -1324,92 +1341,91 @@ _do_download_draw_yuv_opengl (GstGLDisplay * display, GstGLDownload * download)
break;
gst_gl_display_set_error (display,
"Download video format inconsistensy %d", v_format);
}
glBegin (GL_QUADS);
glTexCoord2i (0, 0);
glVertex2f (-1.0f, -1.0f);
glTexCoord2i (out_width, 0);
glVertex2f (1.0f, -1.0f);
glTexCoord2i (out_width, out_height);
glVertex2f (1.0f, 1.0f);
glTexCoord2i (0, out_height);
glVertex2f (-1.0f, 1.0f);
glEnd ();
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
glDrawBuffer (GL_NONE);
gl->VertexPointer (2, GL_FLOAT, 0, &verts);
gl->TexCoordPointer (2, GL_FLOAT, 0, &texcoords);
gl->DrawArrays (GL_TRIANGLE_FAN, 0, 4);
gl->DisableClientState (GL_VERTEX_ARRAY);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
gl->DrawBuffer (GL_NONE);
/* don't check if GLSL is available
* because download yuv is not available
* without GLSL (whereas rgb is)
*/
glUseProgramObjectARB (0);
gl->UseProgramObject (0);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
glMatrixMode (GL_PROJECTION);
glPopMatrix ();
glMatrixMode (GL_MODELVIEW);
glPopMatrix ();
glPopAttrib ();
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gl->MatrixMode (GL_PROJECTION);
gl->PopMatrix ();
gl->MatrixMode (GL_MODELVIEW);
gl->PopMatrix ();
gl->PopAttrib ();
gst_gl_display_check_framebuffer_status ();
gst_gl_display_check_framebuffer_status (display);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, download->fbo);
glReadBuffer (GL_COLOR_ATTACHMENT0_EXT);
gl->BindFramebuffer (GL_FRAMEBUFFER, download->fbo);
gl->ReadBuffer (GL_COLOR_ATTACHMENT0);
switch (v_format) {
case GST_VIDEO_FORMAT_AYUV:
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
glReadPixels (0, 0, out_width, out_height, GL_BGRA,
gl->ReadPixels (0, 0, out_width, out_height, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8, download->data[0]);
#else
glReadPixels (0, 0, out_width, out_height, GL_BGRA,
gl->ReadPixels (0, 0, out_width, out_height, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV, download->data[0]);
#endif
break;
case GST_VIDEO_FORMAT_YUY2:
case GST_VIDEO_FORMAT_UYVY:
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
glReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2, out_height, GL_BGRA,
gl->ReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2, out_height, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV, download->data[0]);
#else
glReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2, out_height, GL_BGRA,
gl->ReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2, out_height, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8, download->data[0]);
#endif
break;
case GST_VIDEO_FORMAT_I420:
{
glReadPixels (0, 0, out_width, out_height, GL_LUMINANCE, GL_UNSIGNED_BYTE,
download->data[0]);
gl->ReadPixels (0, 0, out_width, out_height, GL_LUMINANCE,
GL_UNSIGNED_BYTE, download->data[0]);
glReadBuffer (GL_COLOR_ATTACHMENT1_EXT);
gl->ReadBuffer (GL_COLOR_ATTACHMENT1);
glReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
gl->ReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
GST_ROUND_UP_2 (out_height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE,
download->data[1]);
glReadBuffer (GL_COLOR_ATTACHMENT2_EXT);
gl->ReadBuffer (GL_COLOR_ATTACHMENT2);
glReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
gl->ReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
GST_ROUND_UP_2 (out_height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE,
download->data[2]);
}
break;
case GST_VIDEO_FORMAT_YV12:
{
glReadPixels (0, 0, out_width, out_height, GL_LUMINANCE, GL_UNSIGNED_BYTE,
download->data[0]);
gl->ReadPixels (0, 0, out_width, out_height, GL_LUMINANCE,
GL_UNSIGNED_BYTE, download->data[0]);
glReadBuffer (GL_COLOR_ATTACHMENT1_EXT);
gl->ReadBuffer (GL_COLOR_ATTACHMENT1);
glReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
gl->ReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
GST_ROUND_UP_2 (out_height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE,
download->data[2]);
glReadBuffer (GL_COLOR_ATTACHMENT2_EXT);
gl->ReadBuffer (GL_COLOR_ATTACHMENT2);
glReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
gl->ReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
GST_ROUND_UP_2 (out_height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE,
download->data[1]);
}
@ -1420,11 +1436,11 @@ _do_download_draw_yuv_opengl (GstGLDisplay * display, GstGLDownload * download)
"Download video format inconsistensy %d", v_format);
g_assert_not_reached ();
}
glReadBuffer (GL_NONE);
gl->ReadBuffer (GL_NONE);
gst_gl_display_check_framebuffer_status ();
gst_gl_display_check_framebuffer_status (display);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
}
#endif
@ -1432,6 +1448,7 @@ _do_download_draw_yuv_opengl (GstGLDisplay * display, GstGLDownload * download)
static void
_do_download_draw_yuv_gles2 (GstGLDisplay * display, GstGLDownload * download)
{
GstGLFuncs *gl;
GstVideoFormat v_format;
guint out_width, out_height;
@ -1449,6 +1466,8 @@ _do_download_draw_yuv_gles2 (GstGLDisplay * display, GstGLDownload * download)
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
gl = display->gl_vtable;
out_width = GST_VIDEO_INFO_WIDTH (&download->info);
out_height = GST_VIDEO_INFO_HEIGHT (&download->info);
v_format = GST_VIDEO_INFO_FORMAT (&download->info);
@ -1456,49 +1475,49 @@ _do_download_draw_yuv_gles2 (GstGLDisplay * display, GstGLDownload * download)
GST_TRACE ("doing YUV download of texture:%u (%ux%u) using fbo:%u",
download->in_texture, out_width, out_height, download->fbo);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, download->fbo);
gl->BindFramebuffer (GL_FRAMEBUFFER, download->fbo);
glGetIntegerv (GL_VIEWPORT, viewport_dim);
gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
glViewport (0, 0, out_width, out_height);
gl->Viewport (0, 0, out_width, out_height);
switch (v_format) {
case GST_VIDEO_FORMAT_YUY2:
case GST_VIDEO_FORMAT_UYVY:
case GST_VIDEO_FORMAT_AYUV:
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (download->shader);
glVertexAttribPointer (download->shader_attr_position_loc, 3,
gl->VertexAttribPointer (download->shader_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
glVertexAttribPointer (download->shader_attr_texture_loc, 2,
gl->VertexAttribPointer (download->shader_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
glEnableVertexAttribArray (download->shader_attr_position_loc);
glEnableVertexAttribArray (download->shader_attr_texture_loc);
gl->EnableVertexAttribArray (download->shader_attr_position_loc);
gl->EnableVertexAttribArray (download->shader_attr_texture_loc);
glActiveTextureARB (GL_TEXTURE0_ARB);
gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (download->shader, "tex", 0);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
}
break;
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12:
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (download->shader);
glActiveTextureARB (GL_TEXTURE0_ARB);
gl->ActiveTexture (GL_TEXTURE0);
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);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
}
break;
@ -1509,65 +1528,65 @@ _do_download_draw_yuv_gles2 (GstGLDisplay * display, GstGLDownload * download)
}
glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
/* don't check if GLSL is available
* because download yuv is not available
* without GLSL (whereas rgb is)
*/
glUseProgramObjectARB (0);
gst_gl_display_clear_shader (display);
glViewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
viewport_dim[3]);
gst_gl_display_check_framebuffer_status ();
gst_gl_display_check_framebuffer_status (display);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, download->fbo);
gl->BindFramebuffer (GL_FRAMEBUFFER, download->fbo);
switch (v_format) {
case GST_VIDEO_FORMAT_AYUV:
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
glReadPixels (0, 0, out_width, out_height, GL_BGRA,
gl->ReadPixels (0, 0, out_width, out_height, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8, download->data[0]);
#else
glReadPixels (0, 0, out_width, out_height, GL_BGRA,
gl->ReadPixels (0, 0, out_width, out_height, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV, download->data[0]);
#endif
break;
case GST_VIDEO_FORMAT_YUY2:
case GST_VIDEO_FORMAT_UYVY:
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
glReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2, out_height, GL_BGRA,
gl->ReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2, out_height, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV, download->data[0]);
#else
glReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2, out_height, GL_BGRA,
gl->ReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2, out_height, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8, download->data[0]);
#endif
break;
case GST_VIDEO_FORMAT_I420:
{
glReadPixels (0, 0, out_width, out_height, GL_LUMINANCE, GL_UNSIGNED_BYTE,
download->data[0]);
gl->ReadPixels (0, 0, out_width, out_height, GL_LUMINANCE,
GL_UNSIGNED_BYTE, download->data[0]);
glReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
gl->ReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
GST_ROUND_UP_2 (out_height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE,
download->data[1]);
glReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
gl->ReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
GST_ROUND_UP_2 (out_height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE,
download->data[2]);
}
break;
case GST_VIDEO_FORMAT_YV12:
{
glReadPixels (0, 0, out_width, out_height, GL_LUMINANCE, GL_UNSIGNED_BYTE,
download->data[0]);
gl->ReadPixels (0, 0, out_width, out_height, GL_LUMINANCE,
GL_UNSIGNED_BYTE, download->data[0]);
glReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
gl->ReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
GST_ROUND_UP_2 (out_height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE,
download->data[2]);
glReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
gl->ReadPixels (0, 0, GST_ROUND_UP_2 (out_width) / 2,
GST_ROUND_UP_2 (out_height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE,
download->data[1]);
}
@ -1579,8 +1598,8 @@ _do_download_draw_yuv_gles2 (GstGLDisplay * display, GstGLDownload * download)
g_assert_not_reached ();
}
gst_gl_display_check_framebuffer_status ();
gst_gl_display_check_framebuffer_status (display);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
}
#endif

View file

@ -27,15 +27,6 @@
G_BEGIN_DECLS
/* GLEW */
#define GLEW_OK 0
#define GLEW_NO_ERROR 0
#define GLEW_VERSION 1
#define GLEW_VERSION_MAJOR 5
#define GLEW_VERSION_MINOR 1
#define GLEW_VERSION_MICRO 0
/* SUPPORTED */
//FIXME:
@ -46,91 +37,20 @@ G_BEGIN_DECLS
//END FIXME
#define GL_TEXTURE_RECTANGLE_ARB GL_TEXTURE_2D
#define GL_TEXTURE0_ARB GL_TEXTURE0
#define GL_TEXTURE1_ARB GL_TEXTURE1
#define GL_TEXTURE2_ARB GL_TEXTURE2
#define GLEW_EXT_framebuffer_object 1
#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER
#define GL_RENDERBUFFER_EXT GL_RENDERBUFFER
#define GL_STENCIL_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT
#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT
#define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE
#define GL_FRAMEBUFFER_UNSUPPORTED_EXT GL_FRAMEBUFFER_UNSUPPORTED
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS
#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0
#define glFramebufferTexture2DEXT glFramebufferTexture2D
#define glFramebufferRenderbufferEXT glFramebufferRenderbuffer
#define glGenFramebuffersEXT glGenFramebuffers
#define glBindFramebufferEXT glBindFramebuffer
#define glRenderbufferStorageEXT glRenderbufferStorage
#define glDeleteRenderbuffersEXT glDeleteRenderbuffers
#define glDeleteFramebuffersEXT glDeleteFramebuffers
#define glCheckFramebufferStatusEXT glCheckFramebufferStatus
#define glGenRenderbuffersEXT glGenRenderbuffers
#define glBindRenderbufferEXT glBindRenderbuffer
#define glFramebufferTexture2DEXT glFramebufferTexture2D
#define glActiveTextureARB glActiveTexture
#define GLEW_ARB_fragment_shader 1
#define GLhandleARB GLuint
#define GL_FRAGMENT_SHADER_ARB GL_FRAGMENT_SHADER
#define GL_VERTEX_SHADER_ARB GL_VERTEX_SHADER
#define GL_OBJECT_COMPILE_STATUS_ARB GL_COMPILE_STATUS
#define glUseProgramObjectARB glUseProgram
#define glCreateProgramObjectARB glCreateProgram
#define glCreateShaderObjectARB glCreateShader
#define glCompileShaderARB glCompileShader
#define glShaderSourceARB glShaderSource
#define glGetInfoLogARB glGetProgramInfoLog
#define glAttachObjectARB glAttachShader
#define glDetachObjectARB glDetachShader
#define glDeleteObjectARB glDeleteProgram
#define glLinkProgramARB glLinkProgram
#define glGetObjectParameterivARB glGetShaderiv
#define glUniform1fARB glUniform1f
#define glUniform1fvARB glUniform1fv
#define glUniform1iARB glUniform1i
#define glUniform1ivARB glUniform1iv
#define glUniform2fARB glUniform2f
#define glUniform2fvARB glUniform2fv
#define glUniform2iARB glUniform2i
#define glUniform2ivARB glUniform2iv
#define glUniform3fARB glUniform3f
#define glUniform3fvARB glUniform3fv
#define glUniform3iARB glUniform3i
#define glUniform3ivARB glUniform3iv
#define glUniform4fARB glUniform4f
#define glUniform4fvARB glUniform4fv
#define glUniform4iARB glUniform4i
#define glUniform4ivARB glUniform4iv
#define glUniformMatrix2fvARB glUniformMatrix2fv
#define glUniformMatrix3fvARB glUniformMatrix3fv
#define glUniformMatrix4fvARB glUniformMatrix4fv
#define glGetUniformLocationARB glGetUniformLocation
#define glGetAttribLocationARB glGetAttribLocation
#define glBindAttribLocationARB glBindAttribLocation
/* UNSUPPORTED */
#define GLEW_ARB_imaging 0
#define GLEW_MESA_ycbcr_texture 0
#define GL_BGR 0
#define GL_YCBCR_MESA 0
#define GL_UNSIGNED_SHORT_8_8_MESA 0
#define GL_UNSIGNED_SHORT_8_8_MESA 0
#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0
#define GL_COLOR_ATTACHMENT1_EXT 0
#define GL_COLOR_ATTACHMENT2_EXT 0
#define GL_COLOR_ATTACHMENT1 0
#define GL_COLOR_ATTACHMENT2 0
#define GL_TEXTURE_ENV 0
#define GL_TEXTURE_ENV_MODE 0
#define GL_DEPTH24_STENCIL8 0
G_END_DECLS

View file

@ -54,18 +54,17 @@ gst_gl_check_extension (const char *name, const gchar * ext)
/* Define a set of arrays containing the functions required from GL
for each feature */
#if GST_GL_HAVE_OPENGL
#define GST_GL_EXT_BEGIN(name, \
min_gl_major, min_gl_minor, \
gles_availability, \
namespaces, extension_names) \
static const GstGLFeatureFunction gst_gl_ext_ ## name ## _funcs_opengl[] = {
static const GstGLFeatureFunction gst_gl_ext_ ## name ## _funcs[] = {
#define GST_GL_EXT_FUNCTION(ret, name, args) \
{ G_STRINGIFY (name), G_STRUCT_OFFSET (GstGLFuncs, name) },
#define GST_GL_EXT_END() \
{ NULL, 0 }, \
};
#include "glprototypes/opengl_functions.h"
#include "glprototypes/all_functions.h"
#undef GST_GL_EXT_BEGIN
#define GST_GL_EXT_BEGIN(name, \
@ -74,51 +73,15 @@ gst_gl_check_extension (const char *name, const gchar * ext)
namespaces, extension_names) \
{ min_gl_major, min_gl_minor, gles_availability, namespaces, \
extension_names, \
gst_gl_ext_ ## name ## _funcs_opengl },
gst_gl_ext_ ## name ## _funcs },
#undef GST_GL_EXT_FUNCTION
#define GST_GL_EXT_FUNCTION(ret, name, args)
#undef GST_GL_EXT_END
#define GST_GL_EXT_END()
static const GstGLFeatureData gst_gl_feature_ext_functions_data_opengl[] = {
#include "glprototypes/opengl_functions.h"
static const GstGLFeatureData gst_gl_feature_ext_functions_data[] = {
#include "glprototypes/all_functions.h"
};
#endif /* GST_GL_HAVE_OPENGL */
#undef GST_GL_EXT_BEGIN
#undef GST_GL_EXT_FUNCTION
#undef GST_GL_EXT_END
#if GST_GL_HAVE_GLES2
#define GST_GL_EXT_BEGIN(name, \
min_gl_major, min_gl_minor, \
gles_availability, \
namespaces, extension_names) \
static const GstGLFeatureFunction gst_gl_ext_ ## name ## _funcs_gles2[] = {
#define GST_GL_EXT_FUNCTION(ret, name, args) \
{ G_STRINGIFY (name), G_STRUCT_OFFSET (GstGLES2Funcs, name) },
#define GST_GL_EXT_END() \
{ NULL, 0 }, \
};
#include "glprototypes/gles2_functions.h"
#undef GST_GL_EXT_BEGIN
#define GST_GL_EXT_BEGIN(name, \
min_gl_major, min_gl_minor, \
gles_availability, \
namespaces, extension_names) \
{ min_gl_major, min_gl_minor, gles_availability, namespaces, \
extension_names, \
gst_gl_ext_ ## name ## _funcs_gles2 },
#undef GST_GL_EXT_FUNCTION
#define GST_GL_EXT_FUNCTION(ret, name, args)
#undef GST_GL_EXT_END
#define GST_GL_EXT_END()
static const GstGLFeatureData gst_gl_feature_ext_functions_data_gles2[] = {
#include "glprototypes/gles2_functions.h"
};
#endif /* GST_GL_HAVE_GLES2 */
#undef GST_GL_EXT_BEGIN
#undef GST_GL_EXT_FUNCTION
@ -132,21 +95,7 @@ _gst_gl_feature_check (GstGLDisplay * display,
{
const char *suffix = NULL;
int func_num;
#if GST_GL_HAVE_OPENGL
static const GstGLFuncs *gst_gl = NULL;
#endif
#if GST_GL_HAVE_GLES2
static const GstGLES2Funcs *gst_gles2 = NULL;
#endif
#if GST_GL_HAVE_OPENGL
if (!gst_gl)
gst_gl = gst_gl_get_opengl_vtable ();
#endif
#if GST_GL_HAVE_GLES2
if (!gst_gles2)
gst_gles2 = gst_gl_get_gles2_vtable ();
#endif
GstGLFuncs *gst_gl = display->gl_vtable;
/* First check whether the functions should be directly provided by
GL */
@ -219,18 +168,8 @@ _gst_gl_feature_check (GstGLDisplay * display,
goto error;
/* Set the function pointer in the context */
#if GST_GL_HAVE_OPENGL
if (display->gl_api & GST_GL_API_OPENGL) {
*(void **) ((guint8 *) gst_gl +
data->functions[func_num].pointer_offset) = func;
}
#endif
#if GST_GL_HAVE_GLES2
if (display->gl_api & GST_GL_API_GLES2) {
*(void **) ((guint8 *) gst_gles2 +
data->functions[func_num].pointer_offset) = func;
}
#endif
*(void **) ((guint8 *) gst_gl +
data->functions[func_num].pointer_offset) = func;
}
return TRUE;
@ -240,18 +179,8 @@ _gst_gl_feature_check (GstGLDisplay * display,
* do feature testing by just looking at the function pointers */
error:
for (func_num = 0; data->functions[func_num].name; func_num++) {
#if GST_GL_HAVE_OPENGL
if (display->gl_api & GST_GL_API_OPENGL) {
*(void **) ((guint8 *) gst_gl +
data->functions[func_num].pointer_offset) = NULL;
}
#endif
#if GST_GL_HAVE_GLES2
if (display->gl_api & GST_GL_API_GLES2) {
*(void **) ((guint8 *) gst_gles2 +
data->functions[func_num].pointer_offset) = NULL;
}
#endif
*(void **) ((guint8 *) gst_gl +
data->functions[func_num].pointer_offset) = NULL;
}
return FALSE;
@ -263,21 +192,9 @@ _gst_gl_feature_check_ext_functions (GstGLDisplay * display,
{
int i;
#if GST_GL_HAVE_OPENGL
if (display->gl_api & GST_GL_API_OPENGL) {
for (i = 0; i < G_N_ELEMENTS (gst_gl_feature_ext_functions_data_opengl);
i++)
_gst_gl_feature_check (display, "GL",
gst_gl_feature_ext_functions_data_opengl + i, gl_major, gl_minor,
gl_extensions);
for (i = 0; i < G_N_ELEMENTS (gst_gl_feature_ext_functions_data); i++) {
_gst_gl_feature_check (display, "GL",
gst_gl_feature_ext_functions_data + i, gl_major, gl_minor,
gl_extensions);
}
#endif
#if GST_GL_HAVE_GLES2
if (display->gl_api & GST_GL_API_GLES2) {
for (i = 0; i < G_N_ELEMENTS (gst_gl_feature_ext_functions_data_gles2); i++)
_gst_gl_feature_check (display, "GL",
gst_gl_feature_ext_functions_data_gles2 + i, gl_major, gl_minor,
gl_extensions);
}
#endif
}

View file

@ -24,7 +24,7 @@
#ifndef __COGL_FEATURE_PRIVATE_H
#define __COGL_FEATURE_PRIVATE_H
#include <glib.h>
#include <gst/gst.h>
#include "gstgldisplay.h"

View file

@ -1080,16 +1080,17 @@ static void
_draw_with_shader_cb (gint width, gint height, guint texture, gpointer stuff)
{
GstGLFilter *filter = GST_GL_FILTER (stuff);
GstGLFuncs *gl = filter->display->gl_vtable;
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (filter->default_shader);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1i (filter->default_shader, "tex", 1);
@ -1137,23 +1138,33 @@ void
gst_gl_filter_draw_texture (GstGLFilter * filter, GLuint texture,
guint width, guint height)
{
GstGLFuncs *gl = filter->display->gl_vtable;
gfloat verts[8] = { -1.0f, 1.0f,
1.0f, -1.0f,
1.0f, 1.0f,
-1.0f, 1.0f
};
gint texcoords[8] = { 0, 0,
width, 0,
0, height,
width, height
};
GST_DEBUG ("drawing texture:%u dimensions:%ux%u", texture, width, height);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glBegin (GL_QUADS);
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
gl->VertexPointer (2, GL_FLOAT, 0, &verts);
gl->TexCoordPointer (2, GL_INT, 0, &texcoords);
glTexCoord2f (0.0, 0.0);
glVertex2f (-1.0, -1.0);
glTexCoord2f ((gfloat) width, 0.0);
glVertex2f (1.0, -1.0);
glTexCoord2f ((gfloat) width, (gfloat) height);
glVertex2f (1.0, 1.0);
glTexCoord2f (0.0, (gfloat) height);
glVertex2f (-1.0, 1.0);
gl->DrawArrays (GL_TRIANGLE_FAN, 0, 4);
glEnd ();
gl->DisableClientState (GL_VERTEX_ARRAY);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
}
#endif /* GST_GL_HAVE_OPENGL */

View file

@ -191,10 +191,10 @@ _gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
GstGLMemory *src;
GLuint tex_id;
GLuint rboId, fboId;
GLenum status;
gsize width, height;
GLuint gl_format;
GstVideoFormat v_format;
GstGLFuncs *gl = display->gl_vtable;
copy_params = (GstGLMemoryCopyParams *) data;
src = copy_params->src;
@ -203,7 +203,7 @@ _gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
v_format = src->v_format;
gl_format = src->gl_format;
if (!GLEW_EXT_framebuffer_object) {
if (!gl->GenFramebuffers) {
gst_gl_display_set_error (display,
"Context, EXT_framebuffer_object not supported");
return;
@ -219,85 +219,49 @@ _gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
GST_CAT_DEBUG (GST_CAT_GL_MEMORY, "created texture %i", tex_id);
/* create a framebuffer object */
glGenFramebuffersEXT (1, &fboId);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fboId);
gl->GenFramebuffers (1, &fboId);
gl->BindFramebuffer (GL_FRAMEBUFFER, fboId);
/* create a renderbuffer object */
glGenRenderbuffersEXT (1, &rboId);
glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, rboId);
gl->GenRenderbuffers (1, &rboId);
gl->BindRenderbuffer (GL_RENDERBUFFER, rboId);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (display)) {
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width,
gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width,
height);
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT,
gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
width, height);
}
#endif
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (display)) {
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
width, height);
}
#endif
/* attach the renderbuffer to depth attachment point */
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, rboId);
gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER, rboId);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (display)) {
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT,
GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboId);
gl->FramebufferRenderbuffer (GL_FRAMEBUFFER,
GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rboId);
}
#endif
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_RECTANGLE_ARB, src->tex_id, 0);
/* check FBO status */
status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE) {
switch (status) {
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
GST_CAT_ERROR (GST_CAT_GL_MEMORY, "GL_FRAMEBUFFER_UNSUPPORTED");
break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
GST_CAT_ERROR (GST_CAT_GL_MEMORY,
"GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
GST_CAT_ERROR (GST_CAT_GL_MEMORY,
"GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
break;
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
GST_CAT_ERROR (GST_CAT_GL_MEMORY,
"GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
break;
#if GST_GL_HAVE_OPENGL
case GL_FRAMEBUFFER_UNDEFINED:
GST_CAT_ERROR (GST_CAT_GL_MEMORY, "GL_FRAMEBUFFER_UNDEFINED");
break;
#endif
default:
GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Unknown FBO error");
}
if (!gst_gl_display_check_framebuffer_status (display))
goto fbo_error;
}
/* copy tex */
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, tex_id);
glCopyTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, gl_format, 0, 0,
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, tex_id);
gl->CopyTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, gl_format, 0, 0,
width, height, 0);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
glBindFramebuffer (GL_FRAMEBUFFER_EXT, 0);
gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
glDeleteRenderbuffers (1, &rboId);
glDeleteFramebuffers (1, &fboId);
gl->DeleteRenderbuffers (1, &rboId);
gl->DeleteFramebuffers (1, &fboId);
copy_params->tex_id = tex_id;
@ -306,8 +270,8 @@ _gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
/* ERRORS */
fbo_error:
{
glDeleteRenderbuffers (1, &rboId);
glDeleteFramebuffers (1, &fboId);
gl->DeleteRenderbuffers (1, &rboId);
gl->DeleteFramebuffers (1, &fboId);
copy_params->tex_id = 0;
}

View file

@ -24,6 +24,13 @@
#include "gstglshader.h"
#ifndef GL_COMPILE_STATUS
#define GL_COMPILE_STATUS 0x8B81
#endif
#ifndef GLhandleARB
#define GLhandleARB GLuint
#endif
#define GST_GL_SHADER_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), GST_GL_TYPE_SHADER, GstGLShaderPrivate))
@ -33,6 +40,27 @@
#define USING_GLES2(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_GLES2)
#define USING_GLES3(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_GLES3)
typedef struct _GstGLShaderVTable
{
GLuint (*CreateProgram) (void);
void (*DeleteProgram) (GLuint program);
void (*UseProgram) (GLuint program);
void (*GetAttachedShaders) (GLuint program, GLsizei maxcount, GLsizei * count,
GLuint * shaders);
GLuint (*CreateShader) (GLenum shaderType);
void (*DeleteShader) (GLuint shader);
void (*AttachShader) (GLuint program, GLuint shader);
void (*DetachShader) (GLuint program, GLuint shader);
void (*GetShaderiv) (GLuint program, GLenum pname, GLint * params);
void (*GetProgramiv) (GLuint program, GLenum pname, GLint * params);
void (*GetShaderInfoLog) (GLuint shader, GLsizei maxLength, GLsizei * length,
char *log);
void (*GetProgramInfoLog) (GLuint shader, GLsizei maxLength, GLsizei * length,
char *log);
} GstGLShaderVTable;
enum
{
PROP_0,
@ -53,6 +81,8 @@ struct _GstGLShaderPrivate
gboolean compiled;
gboolean active;
GstGLShaderVTable vtable;
};
GST_DEBUG_CATEGORY_STATIC (gst_gl_shader_debug);
@ -67,11 +97,11 @@ gst_gl_shader_finalize (GObject * object)
{
GstGLShader *shader;
GstGLShaderPrivate *priv;
/* GLint status = GL_FALSE; */
/* GLenum err = 0; */
GstGLFuncs *gl;
shader = GST_GL_SHADER (object);
priv = shader->priv;
gl = shader->display->gl_vtable;
GST_TRACE ("finalizing shader %u", priv->program_handle);
@ -85,10 +115,10 @@ gst_gl_shader_finalize (GObject * object)
if (priv->program_handle) {
GST_TRACE ("finalizing program shader %u", priv->program_handle);
glDeleteObjectARB (priv->program_handle);
gl->DeleteObject (priv->program_handle);
/* err = glGetError (); */
/* GST_WARNING ("error: 0x%x", err); */
/* glGetObjectParameterivARB(priv->program_handle, GL_OBJECT_DELETE_STATUS_ARB, &status); */
/* glGetObjectParameteriv(priv->program_handle, GL_OBJECT_DELETE_STATUS_, &status); */
/* GST_INFO ("program deletion status:%s", status == GL_TRUE ? "true" : "false" ); */
}
@ -246,23 +276,73 @@ gst_gl_shader_init (GstGLShader * self)
priv->fragment_handle = 0;
priv->vertex_handle = 0;
priv->program_handle = glCreateProgramObjectARB ();
g_return_if_fail (priv->program_handle);
priv->compiled = FALSE;
priv->active = FALSE; /* unused at the moment */
}
GST_TRACE ("shader initialized %u", priv->program_handle);
gboolean
_fill_vtable (GstGLShader * shader, GstGLDisplay * display)
{
GstGLFuncs *gl = display->gl_vtable;
GstGLShaderVTable *vtable = &shader->priv->vtable;
if (gl->CreateProgram) {
vtable->CreateProgram = gl->CreateProgram;
vtable->DeleteProgram = gl->DeleteProgram;
vtable->UseProgram = gl->UseProgram;
vtable->CreateShader = gl->CreateShader;
vtable->DeleteShader = gl->DeleteShader;
vtable->AttachShader = gl->AttachShader;
vtable->DetachShader = gl->DetachShader;
vtable->GetAttachedShaders = gl->GetAttachedShaders;
vtable->GetShaderInfoLog = gl->GetShaderInfoLog;
vtable->GetShaderiv = gl->GetShaderiv;
vtable->GetProgramInfoLog = gl->GetProgramInfoLog;
vtable->GetProgramiv = gl->GetProgramiv;
} else if (gl->CreateProgramObject) {
vtable->CreateProgram = gl->CreateProgramObject;
vtable->DeleteProgram = gl->DeleteObject;
vtable->UseProgram = gl->UseProgramObject;
vtable->CreateShader = gl->CreateShaderObject;
vtable->DeleteShader = gl->DeleteObject;
vtable->AttachShader = gl->AttachObject;
vtable->DetachShader = gl->DetachObject;
vtable->GetAttachedShaders = gl->GetAttachedObjects;
vtable->GetShaderInfoLog = gl->GetInfoLog;
vtable->GetShaderiv = gl->GetObjectParameteriv;
vtable->GetProgramInfoLog = gl->GetInfoLog;
vtable->GetProgramiv = gl->GetObjectParameteriv;
} else {
return FALSE;
}
return TRUE;
}
GstGLShader *
gst_gl_shader_new (GstGLDisplay * display)
{
GstGLShader *shader = g_object_new (GST_GL_TYPE_SHADER, NULL);
GstGLShader *shader;
g_return_val_if_fail (GST_IS_GL_DISPLAY (display), NULL);
shader = g_object_new (GST_GL_TYPE_SHADER, NULL);
shader->display = display;
if (!_fill_vtable (shader, display))
return NULL;
shader->priv->program_handle = shader->priv->vtable.CreateProgram ();
GST_TRACE ("shader initialized %u", shader->priv->program_handle);
return shader;
}
@ -278,6 +358,7 @@ gboolean
gst_gl_shader_compile (GstGLShader * shader, GError ** error)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
gchar info_buffer[2048];
gint len = 0;
@ -286,6 +367,7 @@ gst_gl_shader_compile (GstGLShader * shader, GError ** error)
g_return_val_if_fail (GST_GL_IS_SHADER (shader), FALSE);
priv = shader->priv;
gl = shader->display->gl_vtable;
if (priv->compiled)
return priv->compiled;
@ -295,24 +377,15 @@ gst_gl_shader_compile (GstGLShader * shader, GError ** error)
if (priv->vertex_src) {
/* create vertex object */
const gchar *vertex_source = priv->vertex_src;
priv->vertex_handle = glCreateShaderObjectARB (GL_VERTEX_SHADER);
glShaderSourceARB (priv->vertex_handle, 1, &vertex_source, NULL);
priv->vertex_handle = priv->vtable.CreateShader (GL_VERTEX_SHADER);
gl->ShaderSource (priv->vertex_handle, 1, &vertex_source, NULL);
/* compile */
glCompileShaderARB (priv->vertex_handle);
gl->CompileShader (priv->vertex_handle);
/* check everything is ok */
glGetObjectParameterivARB (priv->vertex_handle,
GL_OBJECT_COMPILE_STATUS_ARB, &status);
gl->GetShaderiv (priv->vertex_handle, GL_COMPILE_STATUS, &status);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (shader->display))
glGetInfoLogARB (priv->vertex_handle,
sizeof (info_buffer) - 1, &len, info_buffer);
#endif
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (shader->display))
glGetShaderInfoLog (priv->vertex_handle,
sizeof (info_buffer) - 1, &len, info_buffer);
#endif
priv->vtable.GetShaderInfoLog (priv->vertex_handle,
sizeof (info_buffer) - 1, &len, info_buffer);
info_buffer[len] = '\0';
if (status != GL_TRUE) {
@ -320,13 +393,13 @@ gst_gl_shader_compile (GstGLShader * shader, GError ** error)
GST_GL_SHADER_ERROR_COMPILE,
"Vertex Shader compilation failed:\n%s", info_buffer);
glDeleteObjectARB (priv->vertex_handle);
priv->vtable.DeleteShader (priv->vertex_handle);
priv->compiled = FALSE;
return priv->compiled;
} else if (len > 1) {
GST_FIXME ("vertex shader info log:\n%s\n", info_buffer);
}
glAttachObjectARB (priv->program_handle, priv->vertex_handle);
priv->vtable.AttachShader (priv->program_handle, priv->vertex_handle);
GST_LOG ("vertex shader attached %u", priv->vertex_handle);
}
@ -334,54 +407,38 @@ gst_gl_shader_compile (GstGLShader * shader, GError ** error)
if (priv->fragment_src) {
/* create fragment object */
const gchar *fragment_source = priv->fragment_src;
priv->fragment_handle = glCreateShaderObjectARB (GL_FRAGMENT_SHADER_ARB);
glShaderSourceARB (priv->fragment_handle, 1, &fragment_source, NULL);
priv->fragment_handle = priv->vtable.CreateShader (GL_FRAGMENT_SHADER);
gl->ShaderSource (priv->fragment_handle, 1, &fragment_source, NULL);
/* compile */
glCompileShaderARB (priv->fragment_handle);
gl->CompileShader (priv->fragment_handle);
/* check everything is ok */
glGetObjectParameterivARB (priv->fragment_handle,
GL_OBJECT_COMPILE_STATUS_ARB, &status);
priv->vtable.GetShaderiv (priv->fragment_handle,
GL_COMPILE_STATUS, &status);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (shader->display))
glGetInfoLogARB (priv->fragment_handle,
sizeof (info_buffer) - 1, &len, info_buffer);
#endif
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (shader->display))
glGetShaderInfoLog (priv->fragment_handle,
sizeof (info_buffer) - 1, &len, info_buffer);
#endif
priv->vtable.GetShaderInfoLog (priv->fragment_handle,
sizeof (info_buffer) - 1, &len, info_buffer);
info_buffer[len] = '\0';
if (status != GL_TRUE) {
g_set_error (error, GST_GL_SHADER_ERROR,
GST_GL_SHADER_ERROR_COMPILE,
"Fragment Shader compilation failed:\n%s", info_buffer);
glDeleteObjectARB (priv->fragment_handle);
priv->vtable.DeleteShader (priv->fragment_handle);
priv->compiled = FALSE;
return priv->compiled;
} else if (len > 1) {
GST_FIXME ("vertex shader info log:\n%s\n", info_buffer);
}
glAttachObjectARB (priv->program_handle, priv->fragment_handle);
priv->vtable.AttachShader (priv->program_handle, priv->fragment_handle);
GST_LOG ("fragment shader attached %u", priv->fragment_handle);
}
/* if nothing failed link shaders */
glLinkProgramARB (priv->program_handle);
gl->LinkProgram (priv->program_handle);
priv->vtable.GetProgramiv (priv->program_handle, GL_LINK_STATUS, &status);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (shader->display))
glGetObjectParameterivARB (priv->program_handle, GL_LINK_STATUS, &status);
#endif
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (shader->display))
glGetProgramiv (priv->program_handle, GL_LINK_STATUS, &status);
#endif
glGetInfoLogARB (priv->program_handle,
priv->vtable.GetProgramInfoLog (priv->program_handle,
sizeof (info_buffer) - 1, &len, info_buffer);
info_buffer[len] = '\0';
@ -404,8 +461,6 @@ void
gst_gl_shader_release (GstGLShader * shader)
{
GstGLShaderPrivate *priv;
/* GLint status; */
/* GLenum err = 0; */
g_return_if_fail (GST_GL_IS_SHADER (shader));
@ -419,44 +474,19 @@ gst_gl_shader_release (GstGLShader * shader)
if (priv->vertex_handle) { /* not needed but nvidia doesn't care to respect the spec */
GST_TRACE ("finalizing vertex shader %u", priv->vertex_handle);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (shader->display))
glDeleteObjectARB (priv->vertex_handle);
#endif
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (shader->display))
glDeleteShader (priv->vertex_handle);
#endif
/* err = glGetError (); */
/* GST_WARNING ("error: 0x%x", err); */
/* glGetObjectParameterivARB(priv->vertex_handle, GL_OBJECT_DELETE_STATUS_ARB, &status); */
/* GST_INFO ("vertex deletion status:%s", status == GL_TRUE ? "true" : "false" ); */
priv->vtable.DeleteShader (priv->vertex_handle);
}
if (priv->fragment_handle) {
GST_TRACE ("finalizing fragment shader %u", priv->fragment_handle);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (shader->display))
glDeleteObjectARB (priv->fragment_handle);
#endif
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (shader->display))
glDeleteShader (priv->fragment_handle);
#endif
/* err = glGetError (); */
/* GST_WARNING ("error: 0x%x", err); */
/* glGetObjectParameterivARB(priv->fragment_handle, GL_OBJECT_DELETE_STATUS_ARB, &status); */
/* GST_INFO ("fragment deletion status:%s", status == GL_TRUE ? "true" : "false" ); */
priv->vtable.DeleteShader (priv->fragment_handle);
}
if (priv->vertex_handle)
glDetachObjectARB (priv->program_handle, priv->vertex_handle);
priv->vtable.DetachShader (priv->program_handle, priv->vertex_handle);
if (priv->fragment_handle)
glDetachObjectARB (priv->program_handle, priv->fragment_handle);
priv->vtable.DetachShader (priv->program_handle, priv->fragment_handle);
priv->compiled = FALSE;
g_object_notify (G_OBJECT (shader), "compiled");
@ -467,20 +497,32 @@ gst_gl_shader_use (GstGLShader * shader)
{
GstGLShaderPrivate *priv;
if (!shader) {
glUseProgramObjectARB (0);
return;
}
g_return_if_fail (GST_GL_IS_SHADER (shader));
priv = shader->priv;
g_return_if_fail (priv->program_handle);
glUseProgramObjectARB (priv->program_handle);
priv->vtable.UseProgram (priv->program_handle);
return;
}
void
gst_gl_display_clear_shader (GstGLDisplay * display)
{
GstGLFuncs *gl;
g_return_if_fail (GST_IS_GL_DISPLAY (display));
gl = display->gl_vtable;
if (gl->CreateProgram)
gl->UseProgram (0);
else if (gl->CreateProgramObject)
gl->UseProgramObject (0);
}
gboolean
gst_gl_shader_compile_and_check (GstGLShader * shader,
const gchar * source, GstGLShaderSourceType type)
@ -506,10 +548,10 @@ gst_gl_shader_compile_and_check (GstGLShader * shader,
gst_gl_shader_compile (shader, &error);
if (error) {
GST_WARNING ("%s", error->message);
gst_gl_display_set_error (shader->display, "%s", error->message);
g_error_free (error);
error = NULL;
gst_gl_shader_use (NULL);
gst_gl_display_clear_shader (shader->display);
return FALSE;
}
}
@ -521,15 +563,18 @@ gst_gl_shader_set_uniform_1f (GstGLShader * shader, const gchar * name,
gfloat value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
location = glGetUniformLocationARB (priv->program_handle, name);
gl = shader->display->gl_vtable;
glUniform1fARB (location, value);
location = gl->GetUniformLocation (priv->program_handle, name);
gl->Uniform1f (location, value);
}
void
@ -537,15 +582,17 @@ gst_gl_shader_set_uniform_1fv (GstGLShader * shader, const gchar * name,
guint count, gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform1fvARB (location, count, value);
gl->Uniform1fv (location, count, value);
}
void
@ -553,15 +600,17 @@ gst_gl_shader_set_uniform_1i (GstGLShader * shader, const gchar * name,
gint value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform1iARB (location, value);
gl->Uniform1i (location, value);
}
void
@ -569,15 +618,17 @@ gst_gl_shader_set_uniform_1iv (GstGLShader * shader, const gchar * name,
guint count, gint * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform1ivARB (location, count, value);
gl->Uniform1iv (location, count, value);
}
void
@ -585,15 +636,17 @@ gst_gl_shader_set_uniform_2f (GstGLShader * shader, const gchar * name,
gfloat value0, gfloat value1)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform2fARB (location, value0, value1);
gl->Uniform2f (location, value0, value1);
}
void
@ -601,15 +654,17 @@ gst_gl_shader_set_uniform_2fv (GstGLShader * shader, const gchar * name,
guint count, gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform2fvARB (location, count, value);
gl->Uniform2fv (location, count, value);
}
void
@ -617,15 +672,17 @@ gst_gl_shader_set_uniform_2i (GstGLShader * shader, const gchar * name,
gint v0, gint v1)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform2iARB (location, v0, v1);
gl->Uniform2i (location, v0, v1);
}
void
@ -633,15 +690,17 @@ gst_gl_shader_set_uniform_2iv (GstGLShader * shader, const gchar * name,
guint count, gint * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform2ivARB (location, count, value);
gl->Uniform2iv (location, count, value);
}
void
@ -649,15 +708,17 @@ gst_gl_shader_set_uniform_3f (GstGLShader * shader, const gchar * name,
gfloat v0, gfloat v1, gfloat v2)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform3fARB (location, v0, v1, v2);
gl->Uniform3f (location, v0, v1, v2);
}
void
@ -665,15 +726,17 @@ gst_gl_shader_set_uniform_3fv (GstGLShader * shader, const gchar * name,
guint count, gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform3fvARB (location, count, value);
gl->Uniform3fv (location, count, value);
}
void
@ -681,15 +744,17 @@ gst_gl_shader_set_uniform_3i (GstGLShader * shader, const gchar * name,
gint v0, gint v1, gint v2)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform3iARB (location, v0, v1, v2);
gl->Uniform3i (location, v0, v1, v2);
}
void
@ -697,15 +762,17 @@ gst_gl_shader_set_uniform_3iv (GstGLShader * shader, const gchar * name,
guint count, gint * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform3ivARB (location, count, value);
gl->Uniform3iv (location, count, value);
}
void
@ -713,15 +780,17 @@ gst_gl_shader_set_uniform_4f (GstGLShader * shader, const gchar * name,
gfloat v0, gfloat v1, gfloat v2, gfloat v3)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform4fARB (location, v0, v1, v2, v3);
gl->Uniform4f (location, v0, v1, v2, v3);
}
void
@ -729,15 +798,17 @@ gst_gl_shader_set_uniform_4fv (GstGLShader * shader, const gchar * name,
guint count, gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform4fvARB (location, count, value);
gl->Uniform4fv (location, count, value);
}
void
@ -745,15 +816,17 @@ gst_gl_shader_set_uniform_4i (GstGLShader * shader, const gchar * name,
gint v0, gint v1, gint v2, gint v3)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform4iARB (location, v0, v1, v2, v3);
gl->Uniform4i (location, v0, v1, v2, v3);
}
void
@ -761,15 +834,17 @@ gst_gl_shader_set_uniform_4iv (GstGLShader * shader, const gchar * name,
guint count, gint * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniform4ivARB (location, count, value);
gl->Uniform4iv (location, count, value);
}
void
@ -777,15 +852,17 @@ gst_gl_shader_set_uniform_matrix_2fv (GstGLShader * shader, const gchar * name,
gint count, gboolean transpose, const gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniformMatrix2fvARB (location, count, transpose, value);
gl->UniformMatrix2fv (location, count, transpose, value);
}
void
@ -793,15 +870,17 @@ gst_gl_shader_set_uniform_matrix_3fv (GstGLShader * shader, const gchar * name,
gint count, gboolean transpose, const gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniformMatrix3fvARB (location, count, transpose, value);
gl->UniformMatrix3fv (location, count, transpose, value);
}
void
@ -809,15 +888,17 @@ gst_gl_shader_set_uniform_matrix_4fv (GstGLShader * shader, const gchar * name,
gint count, gboolean transpose, const gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniformMatrix4fvARB (location, count, transpose, value);
gl->UniformMatrix4fv (location, count, transpose, value);
}
#if GST_GL_HAVE_OPENGL
@ -826,15 +907,17 @@ gst_gl_shader_set_uniform_matrix_2x3fv (GstGLShader * shader,
const gchar * name, gint count, gboolean transpose, const gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniformMatrix2x3fv (location, count, transpose, value);
gl->UniformMatrix2x3fv (location, count, transpose, value);
}
void
@ -842,15 +925,17 @@ gst_gl_shader_set_uniform_matrix_2x4fv (GstGLShader * shader,
const gchar * name, gint count, gboolean transpose, const gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniformMatrix2x4fv (location, count, transpose, value);
gl->UniformMatrix2x4fv (location, count, transpose, value);
}
void
@ -858,15 +943,17 @@ gst_gl_shader_set_uniform_matrix_3x2fv (GstGLShader * shader,
const gchar * name, gint count, gboolean transpose, const gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniformMatrix3x2fv (location, count, transpose, value);
gl->UniformMatrix3x2fv (location, count, transpose, value);
}
void
@ -874,15 +961,17 @@ gst_gl_shader_set_uniform_matrix_3x4fv (GstGLShader * shader,
const gchar * name, gint count, gboolean transpose, const gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniformMatrix3x4fv (location, count, transpose, value);
gl->UniformMatrix3x4fv (location, count, transpose, value);
}
void
@ -890,15 +979,17 @@ gst_gl_shader_set_uniform_matrix_4x2fv (GstGLShader * shader,
const gchar * name, gint count, gboolean transpose, const gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniformMatrix4x2fv (location, count, transpose, value);
gl->UniformMatrix4x2fv (location, count, transpose, value);
}
void
@ -906,15 +997,17 @@ gst_gl_shader_set_uniform_matrix_4x3fv (GstGLShader * shader,
const gchar * name, gint count, gboolean transpose, const gfloat * value)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
GLint location = -1;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
location = glGetUniformLocationARB (priv->program_handle, name);
location = gl->GetUniformLocation (priv->program_handle, name);
glUniformMatrix4x3fv (location, count, transpose, value);
gl->UniformMatrix4x3fv (location, count, transpose, value);
}
#endif /* GST_GL_HAVE_OPENGL */
@ -922,12 +1015,14 @@ GLint
gst_gl_shader_get_attribute_location (GstGLShader * shader, const gchar * name)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
g_return_val_if_fail (shader != NULL, 0);
priv = shader->priv;
g_return_val_if_fail (priv->program_handle != 0, 0);
gl = shader->display->gl_vtable;
return glGetAttribLocationARB (priv->program_handle, name);
return gl->GetAttribLocation (priv->program_handle, name);
}
void
@ -935,12 +1030,14 @@ gst_gl_shader_bind_attribute_location (GstGLShader * shader, GLuint index,
const gchar * name)
{
GstGLShaderPrivate *priv;
GstGLFuncs *gl;
g_return_if_fail (shader != NULL);
priv = shader->priv;
g_return_if_fail (priv->program_handle != 0);
gl = shader->display->gl_vtable;
glBindAttribLocationARB (priv->program_handle, index, name);
gl->BindAttribLocation (priv->program_handle, index, name);
}
GQuark

View file

@ -83,8 +83,9 @@ gboolean gst_gl_shader_is_compiled (GstGLShader *shader);
gboolean gst_gl_shader_compile (GstGLShader *shader, GError **error);
gboolean gst_gl_shader_compile_and_check (GstGLShader *shader, const gchar *source, GstGLShaderSourceType type);
void gst_gl_shader_release (GstGLShader *shader);
void gst_gl_shader_use (GstGLShader *shader);
void gst_gl_shader_release (GstGLShader *shader);
void gst_gl_shader_use (GstGLShader *shader);
void gst_gl_display_clear_shader (GstGLDisplay *display);
void gst_gl_shader_set_uniform_1i (GstGLShader *shader, const gchar *name, gint value);
void gst_gl_shader_set_uniform_1iv (GstGLShader *shader, const gchar *name, guint count, gint *value);

File diff suppressed because it is too large Load diff

View file

@ -24,34 +24,34 @@ static void
gst_gl_effects_bulge_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "bulge0");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "bulge0", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
bulge_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize bulge shader");
gst_gl_display_set_error (display, "Failed to initialize bulge shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);

View file

@ -24,34 +24,34 @@ static void
gst_gl_effects_fisheye_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "fisheye0");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "fisheye0", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
fisheye_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize fisheye shader");
gst_gl_display_set_error (display, "Failed to initialize fisheye shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);

View file

@ -27,34 +27,35 @@ static void
gst_gl_effects_glow_step_one (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "glow0");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "glow0", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
luma_threshold_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
gst_gl_display_set_error (display,
"Failed to initialize luma threshold shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
@ -63,15 +64,17 @@ gst_gl_effects_glow_step_one (gint width, gint height, guint texture,
static void
gst_gl_effects_glow_step_two (gint width, gint height, guint texture,
gpointer stuff)
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (stuff);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "glow1");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "glow1", shader);
}
@ -82,22 +85,21 @@ gst_gl_effects_glow_step_two (gint width, gint height, guint texture,
if (!gst_gl_shader_compile_and_check (shader,
hconv7_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize hconv7 shader");
gst_gl_display_set_error (display, "Failed to initialize hconv7 shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7, gauss_kernel);
@ -107,36 +109,37 @@ gst_gl_effects_glow_step_two (gint width, gint height, guint texture,
void
gst_gl_effects_glow_step_three (gint width, gint height, guint texture,
gpointer stuff)
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (stuff);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "glow2");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "glow2", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
vconv7_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize vcon7 shader");
gst_gl_display_set_error (display, "Failed to initialize vcon7 shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7, gauss_kernel);
@ -146,44 +149,45 @@ gst_gl_effects_glow_step_three (gint width, gint height, guint texture,
void
gst_gl_effects_glow_step_four (gint width, gint height, guint texture,
gpointer stuff)
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (stuff);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "glow3");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "glow3", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
sum_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize sum shader");
gst_gl_display_set_error (display, "Failed to initialize sum shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE2);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, effects->intexture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->ActiveTexture (GL_TEXTURE2);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, effects->intexture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1f (shader, "alpha", 1.0);
gst_gl_shader_set_uniform_1i (shader, "base", 2);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1f (shader, "beta", (gfloat) 1 / 3.5f);
gst_gl_shader_set_uniform_1i (shader, "blend", 1);

View file

@ -32,20 +32,22 @@ gst_gl_effects_identity_callback (gint width, gint height, guint texture,
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLDisplay *display = filter->display;
GstGLFuncs *gl = display->gl_vtable;
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (filter->display)) {
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
if (USING_OPENGL (display)) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (filter->display)) {
if (USING_GLES2 (display)) {
GstGLShader *shader =
g_hash_table_lookup (effects->shaderstable, "identity0");
if (!shader) {
shader = gst_gl_shader_new (filter->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "identity0", shader);
if (shader) {
@ -69,9 +71,9 @@ gst_gl_effects_identity_callback (gint width, gint height, guint texture,
}
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
}

View file

@ -27,59 +27,61 @@ gst_gl_effects_luma_to_curve (GstGLEffects * effects,
gint curve_index, gint width, gint height, GLuint texture)
{
GstGLShader *shader;
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "lumamap0");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "lumamap0", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
luma_to_curve_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
gst_gl_display_set_error (display,
"Failed to initialize luma to curve shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
if (effects->curve[curve_index] == 0) {
/* this parameters are needed to have a right, predictable, mapping */
glGenTextures (1, &effects->curve[curve_index]);
glEnable (GL_TEXTURE_1D);
glBindTexture (GL_TEXTURE_1D, effects->curve[curve_index]);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP);
gl->GenTextures (1, &effects->curve[curve_index]);
gl->Enable (GL_TEXTURE_1D);
gl->BindTexture (GL_TEXTURE_1D, effects->curve[curve_index]);
gl->TexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl->TexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl->TexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
gl->TexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage1D (GL_TEXTURE_1D, 0, curve.bytes_per_pixel,
gl->TexImage1D (GL_TEXTURE_1D, 0, curve.bytes_per_pixel,
curve.width, 0, GL_RGB, GL_UNSIGNED_BYTE, curve.pixel_data);
glDisable (GL_TEXTURE_1D);
gl->Disable (GL_TEXTURE_1D);
}
glActiveTexture (GL_TEXTURE2);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE2);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 2);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_1D);
glBindTexture (GL_TEXTURE_1D, effects->curve[curve_index]);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_1D);
gl->BindTexture (GL_TEXTURE_1D, effects->curve[curve_index]);
gst_gl_shader_set_uniform_1i (shader, "curve", 1);
glDisable (GL_TEXTURE_1D);
gl->Disable (GL_TEXTURE_1D);
gst_gl_effects_draw_texture (effects, texture, width, height);
}

View file

@ -30,18 +30,20 @@ static void
gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLShader *shader;
GstGLFilter *filter = GST_GL_FILTER (data);
GstGLEffects *effects = GST_GL_EFFECTS (filter);
GstGLDisplay *display = filter->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "mirror0");
if (!shader) {
shader = gst_gl_shader_new (filter->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "mirror0", shader);
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (filter->display)) {
if (USING_GLES2 (display)) {
if (shader) {
GError *error = NULL;
gst_gl_shader_set_vertex_source (shader, vertex_shader_source);
@ -50,14 +52,13 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
gst_gl_shader_compile (shader, &error);
if (error) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
gst_gl_display_set_error (display,
"Failed to initialize mirror shader, %s", error->message);
g_error_free (error);
error = NULL;
gst_gl_shader_use (NULL);
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display),
(NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
} else {
effects->draw_attr_position_loc =
gst_gl_shader_get_attribute_location (shader, "a_position");
@ -68,27 +69,27 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
}
#endif
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (filter->display)) {
if (USING_OPENGL (display)) {
if (!gst_gl_shader_compile_and_check (shader,
mirror_fragment_source_opengl, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
gst_gl_display_set_error (display,
"Failed to initialize mirror shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
}
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);

View file

@ -27,59 +27,61 @@ gst_gl_effects_rgb_to_curve (GstGLEffects * effects,
gint curve_index, gint width, gint height, GLuint texture)
{
GstGLShader *shader;
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "rgbmap0");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "rgbmap0", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
rgb_to_curve_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
gst_gl_display_set_error (display,
"Failed to initialize rgb to curve shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
if (effects->curve[curve_index] == 0) {
/* this parameters are needed to have a right, predictable, mapping */
glGenTextures (1, &effects->curve[curve_index]);
glEnable (GL_TEXTURE_1D);
glBindTexture (GL_TEXTURE_1D, effects->curve[curve_index]);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP);
gl->GenTextures (1, &effects->curve[curve_index]);
gl->Enable (GL_TEXTURE_1D);
gl->BindTexture (GL_TEXTURE_1D, effects->curve[curve_index]);
gl->TexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl->TexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl->TexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
gl->TexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage1D (GL_TEXTURE_1D, 0, curve.bytes_per_pixel,
gl->TexImage1D (GL_TEXTURE_1D, 0, curve.bytes_per_pixel,
curve.width, 0, GL_RGB, GL_UNSIGNED_BYTE, curve.pixel_data);
glDisable (GL_TEXTURE_1D);
gl->Disable (GL_TEXTURE_1D);
}
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_1D);
glBindTexture (GL_TEXTURE_1D, effects->curve[curve_index]);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_1D);
gl->BindTexture (GL_TEXTURE_1D, effects->curve[curve_index]);
gst_gl_shader_set_uniform_1i (shader, "curve", 1);
glDisable (GL_TEXTURE_1D);
gl->Disable (GL_TEXTURE_1D);
gst_gl_effects_draw_texture (effects, texture, width, height);
}

View file

@ -24,34 +24,34 @@ static void
gst_gl_effects_sin_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "sin0");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "sin0", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
sin_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize sin shader");
gst_gl_display_set_error (display, "Failed to initialize sin shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);

View file

@ -24,34 +24,34 @@ static void
gst_gl_effects_square_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "square0");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "square0", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
square_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize square shader");
gst_gl_display_set_error (display, "Failed to initialize square shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);

View file

@ -30,18 +30,20 @@ static void
gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLShader *shader;
GstGLFilter *filter = GST_GL_FILTER (data);
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = filter->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "squeeze0");
if (!shader) {
shader = gst_gl_shader_new (filter->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "squeeze0", shader);
#if GST_GL_HAVE_GLES2
if (USING_GLES2 (filter->display)) {
if (USING_GLES2 (display)) {
if (shader) {
GError *error = NULL;
gst_gl_shader_set_vertex_source (shader, vertex_shader_source);
@ -50,15 +52,13 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
gst_gl_shader_compile (shader, &error);
if (error) {
GstGLFilter *filter = GST_GL_FILTER (effects);
gst_gl_display_set_error (filter->display,
gst_gl_display_set_error (display,
"Failed to initialize squeeze shader, %s", error->message);
g_error_free (error);
error = NULL;
gst_gl_shader_use (NULL);
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display),
(NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
} else {
effects->draw_attr_position_loc =
gst_gl_shader_get_attribute_location (shader, "a_position");
@ -69,26 +69,26 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
}
#endif
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (filter->display)) {
if (USING_OPENGL (display)) {
if (!gst_gl_shader_compile_and_check (shader,
squeeze_fragment_source_opengl, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
gst_gl_display_set_error (display,
"Failed to initialize squeeze shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
}
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);

View file

@ -18,6 +18,12 @@
* Boston, MA 02110-1301, USA.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <gstglconfig.h>
#include <gstgleffects.h>
#include <gstgleffectssources.h>
#include <math.h>

View file

@ -21,10 +21,6 @@
#ifndef __GST_GL_EFFECTS_SOURCES_H__
#define __GST_GL_EFFECTS_SOURCES_H__
#if HAVE_CONFIG_H
#include "config.h"
#endif
extern const gchar *vertex_shader_source;
extern const gchar *identity_fragment_source;
#if GST_GL_HAVE_OPENGL

View file

@ -24,34 +24,34 @@ static void
gst_gl_effects_stretch_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "stretch0");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "stretch0", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
stretch_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize stretch shader");
gst_gl_display_set_error (display, "Failed to initialize stretch shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);

View file

@ -24,34 +24,34 @@ static void
gst_gl_effects_tunnel_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "tunnel0");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "tunnel0", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
tunnel_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize tunnel shader");
gst_gl_display_set_error (display, "Failed to initialize tunnel shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);

View file

@ -24,9 +24,10 @@ static void
gst_gl_effects_twirl_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "twirl0");
@ -37,21 +38,20 @@ gst_gl_effects_twirl_callback (gint width, gint height, guint texture,
if (!gst_gl_shader_compile_and_check (shader,
twirl_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize twirl shader");
gst_gl_display_set_error (display, "Failed to initialize twirl shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);

View file

@ -39,13 +39,15 @@ static void
gst_gl_effects_xray_step_two (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray1");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "xray1", shader);
}
@ -56,22 +58,21 @@ gst_gl_effects_xray_step_two (gint width, gint height, guint texture,
if (!gst_gl_shader_compile_and_check (shader,
hconv7_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize hconv7 shader");
gst_gl_display_set_error (display, "Failed to initialize hconv7 shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_shader_set_uniform_1fv (shader, "kernel", 9, gauss_kernel);
@ -83,34 +84,35 @@ static void
gst_gl_effects_xray_step_three (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray2");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "xray2", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
vconv7_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize vconv7 shader");
gst_gl_display_set_error (display, "Failed to initialize vconv7 shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_shader_set_uniform_1fv (shader, "kernel", 9, gauss_kernel);
@ -123,34 +125,36 @@ static void
gst_gl_effects_xray_desaturate (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray_desat");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "xray_desat", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
desaturate_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
gst_gl_display_set_error (display,
"Failed to initialize desaturate shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_effects_draw_texture (effects, texture, width, height);
@ -160,34 +164,36 @@ static void
gst_gl_effects_xray_sobel_hconv (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_hconv");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "xray_sob_hconv", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
sep_sobel_hconv3_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
gst_gl_display_set_error (display,
"Failed to initialize sobel hvonc3 shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_effects_draw_texture (effects, texture, width, height);
@ -197,34 +203,36 @@ static void
gst_gl_effects_xray_sobel_vconv (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_vconv");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "xray_sob_vconv", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
sep_sobel_vconv3_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
gst_gl_display_set_error (display,
"Failed to initialize sobel vconv3 shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_effects_draw_texture (effects, texture, width, height);
@ -234,34 +242,36 @@ static void
gst_gl_effects_xray_sobel_length (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_len");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "xray_sob_len", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
sep_sobel_length_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
gst_gl_display_set_error (display,
"Failed to initialize seobel length shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_shader_set_uniform_1i (shader, "invert", TRUE);
@ -272,43 +282,44 @@ gst_gl_effects_xray_sobel_length (gint width, gint height, guint texture,
void
gst_gl_effects_xray_step_five (gint width, gint height, guint texture,
gpointer stuff)
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (stuff);
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
shader = g_hash_table_lookup (effects->shaderstable, "xray4");
if (!shader) {
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
shader = gst_gl_shader_new (display);
g_hash_table_insert (effects->shaderstable, "xray4", shader);
}
if (!gst_gl_shader_compile_and_check (shader,
multiply_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
"Failed to initialize multiply shader");
gst_gl_display_set_error (display, "Failed to initialize multiply shader");
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
GST_GL_DISPLAY_ERR_MSG (display), (NULL));
return;
}
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (shader);
glActiveTexture (GL_TEXTURE2);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, effects->midtexture[2]);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
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);
gst_gl_shader_set_uniform_1i (shader, "base", 2);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gl->ActiveTexture (GL_TEXTURE1);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1f (shader, "alpha", (gfloat) 0.5f);
gst_gl_shader_set_uniform_1i (shader, "blend", 1);

View file

@ -382,25 +382,55 @@ gst_gl_bumper_callback (gint width, gint height, guint texture, gpointer stuff)
static GLfloat yrot = 0;
static GLfloat zrot = 0;
GstGLFuncs *gl;
GstGLBumper *bumper = GST_GL_BUMPER (stuff);
GLint locTangent = 0;
GstGLDisplay *display = GST_GL_FILTER (bumper)->display;
// GLint locTangent = 0;
#if 0
//choose the lights
GLfloat light_direction0[] = { 1.0, 0.0, -1.0, 0.0 }; // light goes along -x
GLfloat light_direction1[] = { -1.0, 0.0, -1.0, 0.0 }; // light goes along x
GLfloat light_diffuse0[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat light_diffuse1[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
#endif
gfloat verts_front[12] = {
1.0, 1.0, -1.0,
1.0, -1.0, -1.0,
-1.0, -1.0, -1.0,
-1.0, 1.0, -1.0
};
gfloat texcoords0_front[8] = {
0.0, 0.0,
0.0, height,
width, height,
width, 0.0
};
gfloat texcoords1_front[8] = {
0.0, 0.0,
0.0, bumper->bumpmap_height,
bumper->bumpmap_width, bumper->bumpmap_height,
bumper->bumpmap_width, 0.0
};
gfloat normal_front[12] = {
0.0, 0.0, -1.0,
0.0, 0.0, -1.0,
0.0, 0.0, -1.0,
0.0, 0.0, -1.0
};
gl = GST_GL_FILTER (bumper)->display->gl_vtable;
//eye point
glMatrixMode (GL_PROJECTION);
gl->MatrixMode (GL_PROJECTION);
gluLookAt (0.0, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glMatrixMode (GL_MODELVIEW);
gl->MatrixMode (GL_MODELVIEW);
//scene conf
glEnable (GL_DEPTH_TEST);
glDepthFunc (GL_LEQUAL);
glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
gl->Enable (GL_DEPTH_TEST);
gl->DepthFunc (GL_LEQUAL);
gl->Hint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
#if 0
glShadeModel (GL_SMOOTH);
//set the lights
@ -414,28 +444,60 @@ gst_gl_bumper_callback (gint width, gint height, guint texture, gpointer stuff)
glEnable (GL_LIGHTING);
glEnable (GL_LIGHT0);
glEnable (GL_LIGHT1);
#endif
//configure shader
gst_gl_shader_use (bumper->shader);
locTangent =
gst_gl_shader_get_attribute_location (bumper->shader, "aTangent");
// locTangent =
// gst_gl_shader_get_attribute_location (bumper->shader, "aTangent");
//set the normal map
glActiveTextureARB (GL_TEXTURE1_ARB);
gl->ActiveTexture (GL_TEXTURE1);
gst_gl_shader_set_uniform_1i (bumper->shader, "texture1", 1);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, bumper->bumpmap);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, bumper->bumpmap);
//set the video texture
glActiveTextureARB (GL_TEXTURE0_ARB);
gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (bumper->shader, "texture0", 0);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
//glTranslatef(2.0f, 2.0f, 5.0f);
glRotatef (xrot, 1.0f, 0.0f, 0.0f);
glRotatef (yrot, 0.0f, 1.0f, 0.0f);
glRotatef (zrot, 0.0f, 0.0f, 1.0f);
gl->Rotatef (xrot, 1.0f, 0.0f, 0.0f);
gl->Rotatef (yrot, 0.0f, 1.0f, 0.0f);
gl->Rotatef (zrot, 0.0f, 0.0f, 1.0f);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
// glVertexAttrib3d (locTangent, 0.0, 1.0, 0.0);
gl->VertexPointer (2, GL_FLOAT, 0, &verts_front);
gl->TexCoordPointer (2, GL_FLOAT, 0, &texcoords0_front);
gl->NormalPointer (GL_FLOAT, 0, &normal_front);
gl->ClientActiveTexture (GL_TEXTURE0);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->EnableClientState (GL_NORMAL_ARRAY);
gl->ClientActiveTexture (GL_TEXTURE1);
gl->TexCoordPointer (2, GL_FLOAT, 0, &texcoords1_front);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->EnableClientState (GL_NORMAL_ARRAY);
gl->DrawArrays (GL_TRIANGLE_FAN, 0, 4);
gl->DisableClientState (GL_VERTEX_ARRAY);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
gl->DisableClientState (GL_NORMAL_ARRAY);
gl->ClientActiveTexture (GL_TEXTURE0);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
#if 0
//Cube
glBegin (GL_QUADS);
@ -455,7 +517,9 @@ gst_gl_bumper_callback (gint width, gint height, guint texture, gpointer stuff)
glMultiTexCoord2dARB (GL_TEXTURE0_ARB, width, 0.0);
glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width, 0.0);
glVertex3d (-1.0, 1.0, -1.0); // C
#endif
#if 0
// right face
glNormal3d (-1.0, 0.0, 0.0);
glVertexAttrib3dARB (locTangent, 0.0, 1.0, 0.0);
@ -541,12 +605,13 @@ gst_gl_bumper_callback (gint width, gint height, guint texture, gpointer stuff)
glMultiTexCoord2dARB (GL_TEXTURE1_ARB, bumper->bumpmap_width, 0.0);
glVertex3d (-1.0, -1.0, -1.0); // D
glEnd ();
#endif
gst_gl_display_clear_shader (display);
glUseProgram (0);
glDisable (GL_LIGHT0);
glDisable (GL_LIGHT1);
glDisable (GL_LIGHTING);
glDisable (GL_COLOR_MATERIAL);
gl->Disable (GL_LIGHT0);
gl->Disable (GL_LIGHT1);
gl->Disable (GL_LIGHTING);
gl->Disable (GL_COLOR_MATERIAL);
xrot += 1.0f;
yrot += 0.9f;

View file

@ -32,6 +32,12 @@
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gstglconfig.h>
#include <gstgleffects.h>
#define GST_TYPE_GL_EFFECTS (gst_gl_effects_get_type())
@ -270,30 +276,41 @@ void
gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex, guint width,
guint height)
{
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
GstGLFuncs *gl = display->gl_vtable;
#if GST_GL_HAVE_OPENGL
if (gst_gl_display_get_gl_api_unlocked (GST_GL_FILTER (effects)->display) &
GST_GL_API_OPENGL) {
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, tex);
if (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_OPENGL) {
gfloat verts[] = { -1.0f, -1.0f,
1.0f, -1.0f,
1.0f, 1.0f,
-1.0f, 1.0f
};
gint texcoords[] = { 0, 0,
width, 0,
width, height,
0, height
};
glBegin (GL_QUADS);
gl->ActiveTexture (GL_TEXTURE0);
glTexCoord2f (0.0, 0.0);
glVertex2f (-1.0, -1.0);
glTexCoord2f ((gfloat) width, 0.0);
glVertex2f (1.0, -1.0);
glTexCoord2f ((gfloat) width, (gfloat) height);
glVertex2f (1.0, 1.0);
glTexCoord2f (0.0, (gfloat) height);
glVertex2f (-1.0, 1.0);
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, tex);
glEnd ();
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
gl->VertexPointer (2, GL_FLOAT, 0, &verts);
gl->TexCoordPointer (2, GL_INT, 0, &texcoords);
gl->DrawArrays (GL_TRIANGLE_FAN, 0, 4);
gl->DisableClientState (GL_VERTEX_ARRAY);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
}
#endif
#if GST_GL_HAVE_GLES2
if (gst_gl_display_get_gl_api_unlocked (GST_GL_FILTER (effects)->display) &
GST_GL_API_GLES2) {
if (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_GLES2) {
const GLfloat vVertices[] = {
-1.0f, -1.0f, 0.0f,
0.0f, 0.0f,
@ -307,35 +324,37 @@ gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex, guint width,
/* glClear (GL_COLOR_BUFFER_BIT); */
/* Load the vertex position */
glVertexAttribPointer (effects->draw_attr_position_loc, 3, GL_FLOAT,
gl->VertexAttribPointer (effects->draw_attr_position_loc, 3, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), vVertices);
/* Load the texture coordinate */
glVertexAttribPointer (effects->draw_attr_texture_loc, 2, GL_FLOAT,
gl->VertexAttribPointer (effects->draw_attr_texture_loc, 2, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
glEnableVertexAttribArray (effects->draw_attr_position_loc);
glEnableVertexAttribArray (effects->draw_attr_texture_loc);
gl->EnableVertexAttribArray (effects->draw_attr_position_loc);
gl->EnableVertexAttribArray (effects->draw_attr_texture_loc);
glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
}
#endif
glUseProgramObjectARB (0);
gst_gl_display_clear_shader (display);
}
static void
set_horizontal_swap (GstGLDisplay * display, gpointer data)
{
#if GST_GL_HAVE_OPENGL
GstGLFuncs *gl = display->gl_vtable;
if (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_OPENGL) {
const double mirrormatrix[16] = {
const gfloat mirrormatrix[16] = {
-1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0
};
glMatrixMode (GL_MODELVIEW);
glLoadMatrixd (mirrormatrix);
gl->MatrixMode (GL_MODELVIEW);
gl->LoadMatrixf (mirrormatrix);
}
#endif
}

View file

@ -21,10 +21,6 @@
#ifndef __GST_GL_EFFECTS_H__
#define __GST_GL_EFFECTS_H__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gstglfilter.h>
#include <gstgleffectssources.h>

View file

@ -212,6 +212,7 @@ static void
gst_gl_mosaic_callback (gpointer stuff)
{
GstGLMosaic *mosaic = GST_GL_MOSAIC (stuff);
GstGLFuncs *gl = GST_GL_MIXER (mosaic)->display->gl_vtable;
static GLfloat xrot = 0;
static GLfloat yrot = 0;
@ -233,14 +234,14 @@ gst_gl_mosaic_callback (gpointer stuff)
guint count = 0;
gst_gl_shader_use (NULL);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_display_clear_shader (NULL);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
glEnable (GL_DEPTH_TEST);
gl->Enable (GL_DEPTH_TEST);
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (mosaic->shader);
@ -328,17 +329,17 @@ gst_gl_mosaic_callback (gpointer stuff)
};
/* *INDENT-ON* */
glVertexAttribPointerARB (attr_position_loc, 3, GL_FLOAT,
gl->VertexAttribPointer (attr_position_loc, 3, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), &v_vertices[5 * 4 * count]);
glVertexAttribPointerARB (attr_texture_loc, 2, GL_FLOAT,
gl->VertexAttribPointer (attr_texture_loc, 2, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), &v_vertices[5 * 4 * count + 3]);
glEnableVertexAttribArrayARB (attr_position_loc);
glEnableVertexAttribArrayARB (attr_texture_loc);
gl->EnableVertexAttribArray (attr_position_loc);
gl->EnableVertexAttribArray (attr_texture_loc);
glActiveTextureARB (GL_TEXTURE0_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, in_tex);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, 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);
@ -346,19 +347,19 @@ gst_gl_mosaic_callback (gpointer stuff)
gst_gl_shader_set_uniform_matrix_4fv (mosaic->shader, "u_matrix", 1,
GL_FALSE, matrix);
glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
++count;
}
glDisableVertexAttribArrayARB (attr_position_loc);
glDisableVertexAttribArrayARB (attr_texture_loc);
gl->DisableVertexAttribArray (attr_position_loc);
gl->DisableVertexAttribArray (attr_texture_loc);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
glDisable (GL_DEPTH_TEST);
gl->Disable (GL_DEPTH_TEST);
gst_gl_shader_use (NULL);
gst_gl_display_clear_shader (NULL);
xrot += 0.6f;
yrot += 0.4f;