#include "glprototypes/gles1gles2opengl.h"
#include "glprototypes/gles2.h"
#include "glprototypes/gles2opengl.h"
+#include "glprototypes/gles3opengl.h"
--- /dev/null
+/*
+ * 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 ()
+
#include "glprototypes/gles1opengl.h"
#include "glprototypes/gles1gles2opengl.h"
#include "glprototypes/gles2opengl.h"
+#include "glprototypes/gles3opengl.h"
#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)
{
/* 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
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
#include <gst/gst.h>
#include <gst/video/gstvideosink.h>
-#include "gstgldisplay.h"
#include "gstgldownload.h"
#include "gstglmemory.h"
#include "gstglfeature.h"
+#include "gstglapi.h"
-#ifndef GLEW_VERSION_MAJOR
-#define GLEW_VERSION_MAJOR 4
-#endif
+#include "gstgldisplay.h"
-#ifndef GLEW_VERSION_MINOR
-#define GLEW_VERSION_MINOR 0
+#ifndef GL_FRAMEBUFFER_UNDEFINED
+#define GL_FRAMEBUFFER_UNDEFINED 0x8219
+#endif
+#ifndef GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#endif
+#ifndef GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#endif
+#ifndef GL_FRAMEBUFFER_UNSUPPORTED
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
+#endif
+#ifndef GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
#endif
#define USING_OPENGL(display) (display->gl_api & GST_GL_API_OPENGL)
void gst_gl_display_gen_texture_window_cb (GstGLDisplay * display);
-#if GST_GL_HAVE_OPENGL
-void _gen_fbo_opengl (GstGLDisplay * display);
-void _use_fbo_opengl (GstGLDisplay * display);
-void _use_fbo_v2_opengl (GstGLDisplay * display);
-void _del_fbo_opengl (GstGLDisplay * display);
-void _gen_shader_opengl (GstGLDisplay * display);
-void _del_shader_opengl (GstGLDisplay * display);
-#endif
-#if GST_GL_HAVE_GLES2
-void _gen_fbo_gles2 (GstGLDisplay * display);
-void _use_fbo_gles2 (GstGLDisplay * display);
-void _use_fbo_v2_gles2 (GstGLDisplay * display);
-void _del_fbo_gles2 (GstGLDisplay * display);
-void _gen_shader_gles2 (GstGLDisplay * display);
-void _del_shader_gles2 (GstGLDisplay * display);
-#endif
-
-typedef struct _GstGLVtable
-{
- GstGLWindowCB gen_fbo;
- GstGLWindowCB use_fbo;
- GstGLWindowCB use_fbo_v2;
- GstGLWindowCB del_fbo;
- GstGLWindowCB gen_shader;
- GstGLWindowCB del_shader;
-} GstGLVtable;
+void _gen_fbo (GstGLDisplay * display);
+void _del_fbo (GstGLDisplay * display);
+void _gen_shader (GstGLDisplay * display);
+void _del_shader (GstGLDisplay * display);
+void _use_fbo (GstGLDisplay * display);
+void _use_fbo_v2 (GstGLDisplay * display);
#if GST_GL_HAVE_GLES2
/* *INDENT-OFF* */
const gchar *gen_shader_vertex_source;
GstGLShader *gen_shader;
GstGLShader *del_shader;
-
- GstGLVtable vtable;
};
/*------------------------------------------------------------
display->priv->cond_create_context = g_cond_new ();
display->priv->cond_destroy_context = g_cond_new ();
+ display->gl_vtable = g_slice_alloc0 (sizeof (GstGLFuncs));
+
gst_gl_memory_init ();
}
g_slist_free_full (display->downloads, g_object_unref);
display->downloads = NULL;
}
+
+ if (display->gl_vtable) {
+ g_slice_free (GstGLFuncs, display->gl_vtable);
+ display->gl_vtable = NULL;
+ }
}
display->isAlive = FALSE;
}
-#if GST_GL_HAVE_GLES2
static gboolean
_create_context_gles2 (GstGLDisplay * display, gint * gl_major, gint * gl_minor)
{
+ GstGLFuncs *gl;
GLenum gl_err = GL_NO_ERROR;
- GST_INFO ("GL_VERSION: %s", glGetString (GL_VERSION));
+ gl = display->gl_vtable;
+
+ GST_INFO ("GL_VERSION: %s", gl->GetString (GL_VERSION));
GST_INFO ("GL_SHADING_LANGUAGE_VERSION: %s",
- glGetString (GL_SHADING_LANGUAGE_VERSION));
- GST_INFO ("GL_VENDOR: %s", glGetString (GL_VENDOR));
- GST_INFO ("GL_RENDERER: %s", glGetString (GL_RENDERER));
+ gl->GetString (GL_SHADING_LANGUAGE_VERSION));
+ GST_INFO ("GL_VENDOR: %s", gl->GetString (GL_VENDOR));
+ GST_INFO ("GL_RENDERER: %s", gl->GetString (GL_RENDERER));
- gl_err = glGetError ();
+ gl_err = gl->GetError ();
if (gl_err != GL_NO_ERROR) {
gst_gl_display_set_error (display, "glGetString error: 0x%x", gl_err);
+ return FALSE;
}
-
- if (!GL_ES_VERSION_2_0)
+#if GST_GL_HAVE_GLES2
+ if (!GL_ES_VERSION_2_0) {
gst_gl_display_set_error (display, "OpenGL|ES >= 2.0 is required");
+ return FALSE;
+ }
+#endif
_gst_gl_feature_check_ext_functions (display, 0, 0,
- (const gchar *) glGetString (GL_EXTENSIONS));
-
- display->priv->vtable.gen_fbo = (GstGLWindowCB) _gen_fbo_gles2;
- display->priv->vtable.use_fbo = (GstGLWindowCB) _use_fbo_gles2;
- display->priv->vtable.use_fbo_v2 = (GstGLWindowCB) _use_fbo_v2_gles2;
- display->priv->vtable.del_fbo = (GstGLWindowCB) _del_fbo_gles2;
- display->priv->vtable.gen_shader = (GstGLWindowCB) _gen_shader_gles2;
- display->priv->vtable.del_shader = (GstGLWindowCB) _del_shader_gles2;
+ (const gchar *) gl->GetString (GL_EXTENSIONS));
if (gl_major)
*gl_major = 2;
return TRUE;
}
-#endif
-#if GST_GL_HAVE_OPENGL
gboolean
_create_context_opengl (GstGLDisplay * display, gint * gl_major,
gint * gl_minor)
{
+ GstGLFuncs *gl;
guint maj, min;
GLenum gl_err = GL_NO_ERROR;
- GLenum err;
GString *opengl_version = NULL;
- if ((err = glewInit ()) != GLEW_OK) {
- gst_gl_display_set_error (display, "Failed to init GLEW: %s",
- glewGetErrorString (err));
- return TRUE;
- }
+ gl = display->gl_vtable;
- /* OpenGL > 1.2.0 and Glew > 1.4.0 */
- GST_INFO ("GL_VERSION: %s", glGetString (GL_VERSION));
+ GST_INFO ("GL_VERSION: %s", gl->GetString (GL_VERSION));
GST_INFO ("GL_SHADING_LANGUAGE_VERSION: %s",
- glGetString (GL_SHADING_LANGUAGE_VERSION));
- GST_INFO ("GL_VENDOR: %s", glGetString (GL_VENDOR));
- GST_INFO ("GL_RENDERER: %s", glGetString (GL_RENDERER));
+ gl->GetString (GL_SHADING_LANGUAGE_VERSION));
+ GST_INFO ("GL_VENDOR: %s", gl->GetString (GL_VENDOR));
+ GST_INFO ("GL_RENDERER: %s", gl->GetString (GL_RENDERER));
- gl_err = glGetError ();
+ gl_err = gl->GetError ();
if (gl_err != GL_NO_ERROR) {
gst_gl_display_set_error (display, "glGetString error: 0x%x", gl_err);
+ return FALSE;
}
opengl_version =
- g_string_truncate (g_string_new ((gchar *) glGetString (GL_VERSION)), 3);
+ g_string_truncate (g_string_new ((gchar *) gl->GetString (GL_VERSION)),
+ 3);
sscanf (opengl_version->str, "%d.%d", &maj, &min);
g_string_free (opengl_version, TRUE);
+ /* OpenGL > 1.2.0 */
if ((maj < 1) || (maj < 2 && maj >= 1 && min < 2)) {
- /* turn off the pipeline, the old drivers are not yet supported */
- gst_gl_display_set_error (display,
- "OpenGL >= 1.2.0 and Glew >= 1.4.0 is required");
+ gst_gl_display_set_error (display, "OpenGL >= 1.2.0 required, found %u.%u",
+ maj, min);
return FALSE;
}
_gst_gl_feature_check_ext_functions (display, maj, min,
- (const gchar *) glGetString (GL_EXTENSIONS));
-
- display->priv->vtable.gen_fbo = (GstGLWindowCB) _gen_fbo_opengl;
- display->priv->vtable.use_fbo = (GstGLWindowCB) _use_fbo_opengl;
- display->priv->vtable.use_fbo_v2 = (GstGLWindowCB) _use_fbo_v2_opengl;
- display->priv->vtable.del_fbo = (GstGLWindowCB) _del_fbo_opengl;
- display->priv->vtable.gen_shader = (GstGLWindowCB) _gen_shader_opengl;
- display->priv->vtable.del_shader = (GstGLWindowCB) _del_shader_opengl;
+ (const gchar *) gl->GetString (GL_EXTENSIONS));
if (gl_major)
*gl_major = maj;
return TRUE;
}
-#endif
GstGLAPI
_compiled_api (void)
gpointer
gst_gl_display_thread_create_context (GstGLDisplay * display)
{
+ GstGLFuncs *gl;
gint gl_major = 0;
gboolean ret = FALSE;
GError *error = NULL;
gst_gl_display_lock (display);
+ gl = display->gl_vtable;
+
compiled_api = _compiled_api ();
display->gl_window =
g_free (api_string);
g_free (compiled_api_s);
+ gl->GetError =
+ gst_gl_window_get_proc_address (display->gl_window, "glGetError");
+ gl->GetString =
+ gst_gl_window_get_proc_address (display->gl_window, "glGetString");
+
+ if (!gl->GetError || !gl->GetString) {
+ gst_gl_display_set_error (display,
+ "could not GetProcAddress core opengl functions");
+ goto failure;
+ }
+
/* gl api specific code */
-#if GST_GL_HAVE_OPENGL
if (!ret && USING_OPENGL (display))
ret = _create_context_opengl (display, &gl_major, NULL);
-#endif
-#if GST_GL_HAVE_GLES2
if (!ret && USING_GLES2 (display))
ret = _create_context_gles2 (display, &gl_major, NULL);
-#endif
if (!ret || !gl_major) {
- gst_gl_display_set_error (display,
- "failed to create context, unknown reason");
goto failure;
}
gst_gl_display_set_error (display, "%s", error->message);
g_error_free (error);
error = NULL;
- gst_gl_shader_use (NULL);
+ gst_gl_display_clear_shader (display);
} else {
display->priv->redisplay_attr_position_loc =
gst_gl_shader_get_attribute_location (display->priv->redisplay_shader,
}
#endif
-#if GST_GL_HAVE_OPENGL
void
-_gen_fbo_opengl (GstGLDisplay * display)
+_gen_fbo (GstGLDisplay * display)
{
/* a texture must be attached to the FBO */
+ GstGLFuncs *gl = display->gl_vtable;
GLuint fake_texture = 0;
GST_TRACE ("creating FBO dimensions:%ux%u", display->priv->gen_fbo_width,
/* -- generate frame buffer object */
- if (!GLEW_EXT_framebuffer_object) {
+ if (!gl->GenFramebuffers) {
gst_gl_display_set_error (display,
"Context, EXT_framebuffer_object not supported");
return;
}
/* setup FBO */
- glGenFramebuffersEXT (1, &display->priv->generated_fbo);
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->priv->generated_fbo);
+ gl->GenFramebuffers (1, &display->priv->generated_fbo);
+ gl->BindFramebuffer (GL_FRAMEBUFFER, display->priv->generated_fbo);
/* setup the render buffer for depth */
- glGenRenderbuffersEXT (1, &display->priv->generated_depth_buffer);
- glBindRenderbufferEXT (GL_RENDERBUFFER_EXT,
- display->priv->generated_depth_buffer);
-
- glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
- display->priv->gen_fbo_width, display->priv->gen_fbo_height);
- glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT,
- display->priv->gen_fbo_width, display->priv->gen_fbo_height);
+ gl->GenRenderbuffers (1, &display->priv->generated_depth_buffer);
+ gl->BindRenderbuffer (GL_RENDERBUFFER, display->priv->generated_depth_buffer);
+
+ if (USING_OPENGL (display)) {
+ gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT,
+ display->priv->gen_fbo_width, display->priv->gen_fbo_height);
+ gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
+ display->priv->gen_fbo_width, display->priv->gen_fbo_height);
+ }
+ if (USING_GLES2 (display)) {
+ gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
+ display->priv->gen_fbo_width, display->priv->gen_fbo_height);
+ }
/* setup a texture to render to */
- glGenTextures (1, &fake_texture);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, fake_texture);
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+ gl->GenTextures (1, &fake_texture);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, fake_texture);
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
display->priv->gen_fbo_width, display->priv->gen_fbo_height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, NULL);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+ gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ GL_LINEAR);
+ gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR);
+ gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
- 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 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, fake_texture, 0);
/* attach the depth render buffer to the FBO */
- glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT, display->priv->generated_depth_buffer);
+ gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
+ GL_RENDERBUFFER, display->priv->generated_depth_buffer);
- if (USING_OPENGL (display))
- glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT, display->priv->generated_depth_buffer);
+ if (USING_OPENGL (display)) {
+ gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
+ GL_RENDERBUFFER, display->priv->generated_depth_buffer);
+ }
- if (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) !=
- GL_FRAMEBUFFER_COMPLETE_EXT)
+ if (gl->CheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
gst_gl_display_set_error (display, "GL framebuffer status incomplete");
/* unbind the FBO */
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
+ gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
- glDeleteTextures (1, &fake_texture);
+ gl->DeleteTextures (1, &fake_texture);
}
-#endif
-#if GST_GL_HAVE_GLES2
void
-_gen_fbo_gles2 (GstGLDisplay * display)
+_use_fbo (GstGLDisplay * display)
{
- /* a texture must be attached to the FBO */
- GLuint fake_texture = 0;
-
- GST_TRACE ("creating FBO dimensions:%ux%u", display->priv->gen_fbo_width,
- display->priv->gen_fbo_height);
-
- /* -- generate frame buffer object */
-
- if (!GLEW_EXT_framebuffer_object) {
- gst_gl_display_set_error (display,
- "Context, EXT_framebuffer_object not supported");
- return;
- }
- /* setup FBO */
- glGenFramebuffersEXT (1, &display->priv->generated_fbo);
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->priv->generated_fbo);
-
- /* setup the render buffer for depth */
- glGenRenderbuffersEXT (1, &display->priv->generated_depth_buffer);
- glBindRenderbufferEXT (GL_RENDERBUFFER_EXT,
- display->priv->generated_depth_buffer);
-
- glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
- display->priv->gen_fbo_width, display->priv->gen_fbo_height);
-
- /* setup a texture to render to */
- glGenTextures (1, &fake_texture);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, fake_texture);
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
- display->priv->gen_fbo_width, display->priv->gen_fbo_height, 0, GL_RGBA,
- GL_UNSIGNED_BYTE, NULL);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
- GL_CLAMP_TO_EDGE);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
- GL_CLAMP_TO_EDGE);
-
- /* attach the texture to the FBO to renderer to */
- glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_RECTANGLE_ARB, fake_texture, 0);
-
- /* attach the depth render buffer to the FBO */
- glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT, display->priv->generated_depth_buffer);
-
- if (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) !=
- GL_FRAMEBUFFER_COMPLETE_EXT)
- gst_gl_display_set_error (display, "GL framebuffer status incomplete");
-
- /* unbind the FBO */
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
-
- glDeleteTextures (1, &fake_texture);
-}
+ GstGLFuncs *gl = display->gl_vtable;
+#if GST_GL_HAVE_GLES2
+ GLint viewport_dim[4];
#endif
-/* Called in the gl thread */
-#if GST_GL_HAVE_OPENGL
-void
-_use_fbo_opengl (GstGLDisplay * display)
-{
GST_TRACE ("Binding v1 FBO %u dimensions:%ux%u with texture:%u "
"dimensions:%ux%u", display->priv->use_fbo, display->priv->use_fbo_width,
display->priv->use_fbo_height, display->priv->use_fbo_texture,
display->priv->input_texture_width, display->priv->input_texture_height);
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->priv->use_fbo);
+ gl->BindFramebuffer (GL_FRAMEBUFFER, display->priv->use_fbo);
- /* setup a texture to render to */
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->priv->use_fbo_texture);
+ /*setup a texture to render to */
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, display->priv->use_fbo_texture);
/* attach the 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, display->priv->use_fbo_texture, 0);
- if (GLEW_ARB_fragment_shader)
- gst_gl_shader_use (NULL);
+ gst_gl_display_clear_shader (display);
- glPushAttrib (GL_VIEWPORT_BIT);
- glMatrixMode (GL_PROJECTION);
- glPushMatrix ();
- glLoadIdentity ();
-
- switch (display->priv->use_fbo_projection) {
- case GST_GL_DISPLAY_PROJECTION_ORTHO2D:
- gluOrtho2D (display->priv->use_fbo_proj_param1,
- display->priv->use_fbo_proj_param2,
- display->priv->use_fbo_proj_param3,
- display->priv->use_fbo_proj_param4);
- break;
- case GST_GL_DISPLAY_PROJECTION_PERSPECTIVE:
- gluPerspective (display->priv->use_fbo_proj_param1,
- display->priv->use_fbo_proj_param2,
- display->priv->use_fbo_proj_param3,
- display->priv->use_fbo_proj_param4);
- break;
- default:
- gst_gl_display_set_error (display, "Unknow fbo projection %d",
- display->priv->use_fbo_projection);
- }
- glMatrixMode (GL_MODELVIEW);
- glPushMatrix ();
- glLoadIdentity ();
+#if GST_GL_HAVE_OPENGL
+ if (USING_OPENGL (display)) {
+ gl->PushAttrib (GL_VIEWPORT_BIT);
+ gl->MatrixMode (GL_PROJECTION);
+ gl->PushMatrix ();
+ gl->LoadIdentity ();
+
+ switch (display->priv->use_fbo_projection) {
+ case GST_GL_DISPLAY_PROJECTION_ORTHO2D:
+ gluOrtho2D (display->priv->use_fbo_proj_param1,
+ display->priv->use_fbo_proj_param2,
+ display->priv->use_fbo_proj_param3,
+ display->priv->use_fbo_proj_param4);
+ break;
+ case GST_GL_DISPLAY_PROJECTION_PERSPECTIVE:
+ gluPerspective (display->priv->use_fbo_proj_param1,
+ display->priv->use_fbo_proj_param2,
+ display->priv->use_fbo_proj_param3,
+ display->priv->use_fbo_proj_param4);
+ break;
+ default:
+ gst_gl_display_set_error (display, "Unknow fbo projection %d",
+ display->priv->use_fbo_projection);
+ }
+ gl->MatrixMode (GL_MODELVIEW);
+ gl->PushMatrix ();
+ gl->LoadIdentity ();
+ }
+#endif
+#if GST_GL_HAVE_GLES2
+ if (USING_GLES2 (display))
+ gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
+#endif
- glViewport (0, 0, display->priv->use_fbo_width,
+ gl->Viewport (0, 0, display->priv->use_fbo_width,
display->priv->use_fbo_height);
- glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT);
+#if GST_GL_HAVE_OPENGL
+ if (USING_OPENGL (display)) {
+ const GLenum rt[] = { GL_COLOR_ATTACHMENT0 };
+ gl->DrawBuffers (1, rt);
+ }
+#endif
- 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);
- /* the opengl scene */
display->priv->use_fbo_scene_cb (display->priv->input_texture_width,
display->priv->input_texture_height, display->priv->input_texture,
display->priv->use_fbo_stuff);
- glDrawBuffer (GL_NONE);
- glMatrixMode (GL_PROJECTION);
- glPopMatrix ();
- glMatrixMode (GL_MODELVIEW);
- glPopMatrix ();
- glPopAttrib ();
-
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
-}
+#if GST_GL_HAVE_OPENGL
+ if (USING_OPENGL (display)) {
+ const GLenum rt[] = { GL_NONE };
+ gl->DrawBuffers (1, rt);
+ gl->MatrixMode (GL_PROJECTION);
+ gl->PopMatrix ();
+ gl->MatrixMode (GL_MODELVIEW);
+ gl->PopMatrix ();
+ gl->PopAttrib ();
+ }
#endif
-
#if GST_GL_HAVE_GLES2
-void
-_use_fbo_gles2 (GstGLDisplay * display)
-{
- GLint viewport_dim[4];
-
- GST_TRACE ("Binding v1 FBO %u dimensions:%ux%u with texture:%u "
- "dimensions:%ux%u", display->priv->use_fbo, display->priv->use_fbo_width,
- display->priv->use_fbo_height, display->priv->use_fbo_texture,
- display->priv->input_texture_width, display->priv->input_texture_height);
-
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->priv->use_fbo);
-
- /* setup a texture to render to */
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->priv->use_fbo_texture);
-
- /* attach the texture to the FBO to renderer to */
- glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_RECTANGLE_ARB, display->priv->use_fbo_texture, 0);
-
- glGetIntegerv (GL_VIEWPORT, viewport_dim);
-
- glViewport (0, 0, display->priv->use_fbo_width,
- display->priv->use_fbo_height);
-
- glClearColor (0.0, 0.0, 0.0, 0.0);
- glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- /* the opengl scene */
- display->priv->use_fbo_scene_cb (display->priv->input_texture_width,
- display->priv->input_texture_height, display->priv->input_texture,
- display->priv->use_fbo_stuff);
-
- glViewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
- viewport_dim[3]);
+ if (USING_GLES2 (display)) {
+ gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
+ viewport_dim[3]);
+ }
+#endif
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
+ gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
}
-#endif
/* Called in a gl thread
* Need full shader support */
-#if GST_GL_HAVE_OPENGL
void
-_use_fbo_v2_opengl (GstGLDisplay * display)
+_use_fbo_v2 (GstGLDisplay * display)
{
+ GstGLFuncs *gl = display->gl_vtable;
GLint viewport_dim[4];
GST_TRACE ("Binding v2 FBO %u dimensions:%ux%u with texture:%u ",
display->priv->use_fbo, display->priv->use_fbo_width,
display->priv->use_fbo_height, display->priv->use_fbo_texture);
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->priv->use_fbo);
+ gl->BindFramebuffer (GL_FRAMEBUFFER, display->priv->use_fbo);
/* setup a texture to render to */
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->priv->use_fbo_texture);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, display->priv->use_fbo_texture);
/* attach the 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, display->priv->use_fbo_texture, 0);
- glGetIntegerv (GL_VIEWPORT, viewport_dim);
+ gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
- glViewport (0, 0, display->priv->use_fbo_width,
+ gl->Viewport (0, 0, display->priv->use_fbo_width,
display->priv->use_fbo_height);
- 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);
/* the opengl scene */
display->priv->use_fbo_scene_cb_v2 (display->priv->use_fbo_stuff);
- glDrawBuffer (GL_NONE);
+ gl->DrawBuffer (GL_NONE);
- glViewport (viewport_dim[0], viewport_dim[1],
+ gl->Viewport (viewport_dim[0], viewport_dim[1],
viewport_dim[2], viewport_dim[3]);
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
+ gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
}
-#endif
-
-#if GST_GL_HAVE_GLES2
-void
-_use_fbo_v2_gles2 (GstGLDisplay * display)
-{
- GLint viewport_dim[4];
-
- GST_TRACE ("Binding v2 FBO %u dimensions:%ux%u with texture:%u ",
- display->priv->use_fbo, display->priv->use_fbo_width,
- display->priv->use_fbo_height, display->priv->use_fbo_texture);
-
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->priv->use_fbo);
-
- /* setup a texture to render to */
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->priv->use_fbo_texture);
-
- /* attach the texture to the FBO to renderer to */
- glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_RECTANGLE_ARB, display->priv->use_fbo_texture, 0);
-
- glGetIntegerv (GL_VIEWPORT, viewport_dim);
-
- glViewport (0, 0, display->priv->use_fbo_width,
- display->priv->use_fbo_height);
-
- glClearColor (0.0, 0.0, 0.0, 0.0);
- glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- //the opengl scene
- display->priv->use_fbo_scene_cb_v2 (display->priv->use_fbo_stuff);
-
- glViewport (viewport_dim[0], viewport_dim[1],
- viewport_dim[2], viewport_dim[3]);
-
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
-}
-#endif
/* Called in the gl thread */
-#if GST_GL_HAVE_OPENGL
void
-_del_fbo_opengl (GstGLDisplay * display)
+_del_fbo (GstGLDisplay * display)
{
- GST_TRACE ("Deleting FBO %u", display->priv->del_fbo);
-
- if (display->priv->del_fbo) {
- glDeleteFramebuffersEXT (1, &display->priv->del_fbo);
- display->priv->del_fbo = 0;
- }
- if (display->priv->del_depth_buffer) {
- glDeleteRenderbuffersEXT (1, &display->priv->del_depth_buffer);
- display->priv->del_depth_buffer = 0;
- }
-}
-#endif
+ GstGLFuncs *gl = display->gl_vtable;
-#if GST_GL_HAVE_GLES2
-void
-_del_fbo_gles2 (GstGLDisplay * display)
-{
GST_TRACE ("Deleting FBO %u", display->priv->del_fbo);
if (display->priv->del_fbo) {
- glDeleteFramebuffersEXT (1, &display->priv->del_fbo);
+ gl->DeleteFramebuffers (1, &display->priv->del_fbo);
display->priv->del_fbo = 0;
}
if (display->priv->del_depth_buffer) {
- glDeleteRenderbuffersEXT (1, &display->priv->del_depth_buffer);
+ gl->DeleteRenderbuffers (1, &display->priv->del_depth_buffer);
display->priv->del_depth_buffer = 0;
}
}
-#endif
-#if GST_GL_HAVE_OPENGL
/* Called in the gl thread */
void
-_gen_shader_opengl (GstGLDisplay * display)
+_gen_shader (GstGLDisplay * display)
{
- GST_TRACE ("Generating shader %" GST_PTR_FORMAT, display->priv->gen_shader);
-
- if (GLEW_ARB_fragment_shader) {
- if (display->priv->gen_shader_vertex_source ||
- display->priv->gen_shader_fragment_source) {
- GError *error = NULL;
-
- display->priv->gen_shader = gst_gl_shader_new (display);
-
- if (display->priv->gen_shader_vertex_source)
- gst_gl_shader_set_vertex_source (display->priv->gen_shader,
- display->priv->gen_shader_vertex_source);
-
- if (display->priv->gen_shader_fragment_source)
- gst_gl_shader_set_fragment_source (display->priv->gen_shader,
- display->priv->gen_shader_fragment_source);
+ GstGLFuncs *gl = display->gl_vtable;
- gst_gl_shader_compile (display->priv->gen_shader, &error);
- if (error) {
- gst_gl_display_set_error (display, "%s", error->message);
- g_error_free (error);
- error = NULL;
- gst_gl_shader_use (NULL);
- g_object_unref (G_OBJECT (display->priv->gen_shader));
- display->priv->gen_shader = NULL;
- }
- }
- } else {
- gst_gl_display_set_error (display,
- "One of the filter required ARB_fragment_shader");
- display->priv->gen_shader = NULL;
- }
-}
-#endif
-
-#if GST_GL_HAVE_GLES2
-void
-_gen_shader_gles2 (GstGLDisplay * display)
-{
GST_TRACE ("Generating shader %" GST_PTR_FORMAT, display->priv->gen_shader);
- if (GLEW_ARB_fragment_shader) {
+ if (gl->CreateProgramObject || gl->CreateProgram) {
if (display->priv->gen_shader_vertex_source ||
display->priv->gen_shader_fragment_source) {
GError *error = NULL;
gst_gl_display_set_error (display, "%s", error->message);
g_error_free (error);
error = NULL;
- gst_gl_shader_use (NULL);
+ gst_gl_display_clear_shader (display);
g_object_unref (G_OBJECT (display->priv->gen_shader));
display->priv->gen_shader = NULL;
}
display->priv->gen_shader = NULL;
}
}
-#endif
/* Called in the gl thread */
-#if GST_GL_HAVE_OPENGL
void
-_del_shader_opengl (GstGLDisplay * display)
+_del_shader (GstGLDisplay * display)
{
GST_TRACE ("Deleting shader %" GST_PTR_FORMAT, display->priv->del_shader);
display->priv->del_shader = NULL;
}
}
-#endif
-
-#if GST_GL_HAVE_GLES2
-void
-_del_shader_gles2 (GstGLDisplay * display)
-{
- GST_TRACE ("Deleting shader %" GST_PTR_FORMAT, display->priv->del_shader);
-
- if (display->priv->del_shader) {
- g_object_unref (G_OBJECT (display->priv->del_shader));
- display->priv->del_shader = NULL;
- }
-}
-#endif
//------------------------------------------------------------
//------------------ BEGIN GL THREAD ACTIONS -----------------
void
gst_gl_display_on_resize (GstGLDisplay * display, gint width, gint height)
{
+ GstGLFuncs *gl = display->gl_vtable;
+
GST_TRACE ("GL Window resized to %ux%u", width, height);
//check if a client reshape callback is registered
dst.h = height;
gst_video_sink_center_rect (src, dst, &result, TRUE);
- glViewport (result.x, result.y, result.w, result.h);
+ gl->Viewport (result.x, result.y, result.w, result.h);
} else {
- glViewport (0, 0, width, height);
+ gl->Viewport (0, 0, width, height);
}
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (display)) {
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
+ gl->MatrixMode (GL_PROJECTION);
+ gl->LoadIdentity ();
gluOrtho2D (0, width, 0, height);
- glMatrixMode (GL_MODELVIEW);
+ gl->MatrixMode (GL_MODELVIEW);
}
#endif
}
void
gst_gl_display_on_draw (GstGLDisplay * display)
{
+ GstGLFuncs *gl = display->gl_vtable;
+
/* check if texture is ready for being drawn */
if (!display->priv->redisplay_texture)
return;
-
/* opengl scene */
- GST_TRACE ("on draw");
+ GST_TRACE ("drawing texture:%u", display->priv->redisplay_texture);
/* make sure that the environnement is clean */
- if (display->colorspace_conversion == GST_GL_DISPLAY_CONVERSION_GLSL)
- glUseProgramObjectARB (0);
+ gst_gl_display_clear_shader (display);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (display))
- glDisable (GL_TEXTURE_RECTANGLE_ARB);
+ gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
#endif
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
/* check if a client draw callback is registered */
if (display->priv->clientDrawCallback) {
else {
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (display)) {
- glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gfloat verts[8] = { 1.0f, 1.0f,
+ -1.0f, 1.0f,
+ -1.0f, -1.0f,
+ 1.0f, -1.0f
+ };
+ gint texcoords[8] = { display->priv->redisplay_texture_width, 0,
+ 0, 0,
+ 0, display->priv->redisplay_texture_height,
+ display->priv->redisplay_texture_width,
+ display->priv->redisplay_texture_height
+ };
+ gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
+ gl->MatrixMode (GL_PROJECTION);
+ gl->LoadIdentity ();
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB,
+ gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB,
display->priv->redisplay_texture);
- glEnable (GL_TEXTURE_RECTANGLE_ARB);
-
- glBegin (GL_QUADS);
- /* gst images are top-down while opengl plane is bottom-up */
- glTexCoord2i (display->priv->redisplay_texture_width, 0);
- glVertex2f (1.0f, 1.0f);
- glTexCoord2i (0, 0);
- glVertex2f (-1.0f, 1.0f);
- glTexCoord2i (0, display->priv->redisplay_texture_height);
- glVertex2f (-1.0f, -1.0f);
- glTexCoord2i (display->priv->redisplay_texture_width,
- display->priv->redisplay_texture_height);
- glVertex2f (1.0f, -1.0f);
- /*glTexCoord2i (display->priv->redisplay_texture_width, 0);
- glVertex2i (1, -1);
- glTexCoord2i (0, 0);
- glVertex2f (-1.0f, -1.0f);
- glTexCoord2i (0, display->priv->redisplay_texture_height);
- glVertex2f (-1.0f, 1.0f);
- glTexCoord2i (display->priv->redisplay_texture_width,
- display->priv->redisplay_texture_height);
- glVertex2f (1.0f, 1.0f); */
- glEnd ();
-
- glDisable (GL_TEXTURE_RECTANGLE_ARB);
+
+ 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);
+
+ gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
}
#endif
#if GST_GL_HAVE_GLES2
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
- glClear (GL_COLOR_BUFFER_BIT);
+ gl->Clear (GL_COLOR_BUFFER_BIT);
gst_gl_shader_use (display->priv->redisplay_shader);
/* Load the vertex position */
- glVertexAttribPointer (display->priv->redisplay_attr_position_loc, 3,
+ gl->VertexAttribPointer (display->priv->redisplay_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
/* Load the texture coordinate */
- glVertexAttribPointer (display->priv->redisplay_attr_texture_loc, 2,
+ gl->VertexAttribPointer (display->priv->redisplay_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
- glEnableVertexAttribArray (display->priv->redisplay_attr_position_loc);
- glEnableVertexAttribArray (display->priv->redisplay_attr_texture_loc);
+ gl->EnableVertexAttribArray (display->priv->redisplay_attr_position_loc);
+ gl->EnableVertexAttribArray (display->priv->redisplay_attr_texture_loc);
- glActiveTexture (GL_TEXTURE0);
- glBindTexture (GL_TEXTURE_2D, display->priv->redisplay_texture);
+ gl->ActiveTexture (GL_TEXTURE0);
+ gl->BindTexture (GL_TEXTURE_2D, display->priv->redisplay_texture);
gst_gl_shader_set_uniform_1i (display->priv->redisplay_shader,
"s_texture", 0);
- glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
+ gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
}
#endif
} /* end default opengl scene */
}
-
void
gst_gl_display_on_close (GstGLDisplay * display)
{
gst_gl_display_gen_texture_thread (GstGLDisplay * display, GLuint * pTexture,
GstVideoFormat v_format, GLint width, GLint height)
{
+ GstGLFuncs *gl = display->gl_vtable;
+
GST_TRACE ("Generating texture format:%u dimensions:%ux%u", v_format,
width, height);
- glGenTextures (1, pTexture);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, *pTexture);
+ gl->GenTextures (1, pTexture);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, *pTexture);
switch (v_format) {
case GST_VIDEO_FORMAT_RGB:
case GST_VIDEO_FORMAT_BGRA:
case GST_VIDEO_FORMAT_ARGB:
case GST_VIDEO_FORMAT_ABGR:
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
break;
case GST_VIDEO_FORMAT_YUY2:
switch (display->colorspace_conversion) {
case GST_GL_DISPLAY_CONVERSION_GLSL:
case GST_GL_DISPLAY_CONVERSION_MATRIX:
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
break;
#if 0
case GST_GL_DISPLAY_CONVERSION_MESA:
if (display->upload_width != display->upload_data_width ||
display->upload_height != display->upload_data_height)
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
else
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width,
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width,
height, 0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, NULL);
break;
#endif
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12:
case GST_VIDEO_FORMAT_AYUV:
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
break;
default:
break;
}
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+ gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ GL_LINEAR);
+ gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR);
+ gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+ gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
GST_LOG ("generated texture id:%d", *pTexture);
}
/* called in the gl thread */
-void
-gst_gl_display_check_framebuffer_status (void)
+gboolean
+gst_gl_display_check_framebuffer_status (GstGLDisplay * display)
{
- GLenum status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
+ GLenum status = 0;
+ status = display->gl_vtable->CheckFramebufferStatus (GL_FRAMEBUFFER);
switch (status) {
- case GL_FRAMEBUFFER_COMPLETE_EXT:
+ case GL_FRAMEBUFFER_COMPLETE:
+ return TRUE;
break;
- case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
+ case GL_FRAMEBUFFER_UNSUPPORTED:
GST_ERROR ("GL_FRAMEBUFFER_UNSUPPORTED");
break;
- case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
+ case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
break;
- case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
+ case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
break;
- case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
+ case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
break;
#if GST_GL_HAVE_OPENGL
default:
GST_ERROR ("General FBO error");
}
+
+ return FALSE;
}
/* Called by the first gl element of a video/x-raw-gl flow */
if (display->isAlive) {
display->priv->gen_fbo_width = width;
display->priv->gen_fbo_height = height;
- gst_gl_window_send_message (display->gl_window,
- GST_GL_WINDOW_CB (display->priv->vtable.gen_fbo), display);
+ gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (_gen_fbo),
+ display);
*fbo = display->priv->generated_fbo;
*depthbuffer = display->priv->generated_depth_buffer;
}
display->priv->input_texture_width = input_texture_width;
display->priv->input_texture_height = input_texture_height;
display->priv->input_texture = input_texture;
- gst_gl_window_send_message (display->gl_window,
- display->priv->vtable.use_fbo, display);
+ gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (_use_fbo),
+ display);
}
isAlive = display->isAlive;
gst_gl_display_unlock (display);
display->priv->use_fbo_scene_cb_v2 = cb;
display->priv->use_fbo_stuff = stuff;
gst_gl_window_send_message (display->gl_window,
- display->priv->vtable.use_fbo_v2, display);
+ GST_GL_WINDOW_CB (_use_fbo_v2), display);
}
isAlive = display->isAlive;
gst_gl_display_unlock (display);
if (display->isAlive) {
display->priv->del_fbo = fbo;
display->priv->del_depth_buffer = depth_buffer;
- gst_gl_window_send_message (display->gl_window,
- display->priv->vtable.del_fbo, display);
+ gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (_del_fbo),
+ display);
}
gst_gl_display_unlock (display);
}
display->priv->gen_shader_vertex_source = shader_vertex_source;
display->priv->gen_shader_fragment_source = shader_fragment_source;
gst_gl_window_send_message (display->gl_window,
- display->priv->vtable.gen_shader, display);
+ GST_GL_WINDOW_CB (_gen_shader), display);
if (shader)
*shader = display->priv->gen_shader;
display->priv->gen_shader = NULL;
if (display->isAlive) {
display->priv->del_shader = shader;
gst_gl_window_send_message (display->gl_window,
- display->priv->vtable.del_shader, display);
+ GST_GL_WINDOW_CB (_del_shader), display);
}
gst_gl_display_unlock (display);
}
return api;
}
+gpointer
+gst_gl_display_get_gl_vtable (GstGLDisplay * display)
+{
+ gpointer gl;
+
+ gst_gl_display_lock (display);
+ gl = display->gl_vtable;
+ gst_gl_display_unlock (display);
+
+ return gl;
+}
+
//------------------------------------------------------------
//------------------------ END PUBLIC ------------------------
//------------------------------------------------------------
gchar *error_message;
+ GstGLFuncs *gl_vtable;
+
GstGLDisplayPrivate *priv;
};
/* 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__ */
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);
/* color space conversion is needed */
{
- if (!GLEW_EXT_framebuffer_object) {
+ if (!gl->GenFramebuffers) {
/* Frame buffer object is a requirement
* when using GLSL colorspace conversion
*/
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:
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;
}
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) {
/* 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");
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,
#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:
static void
_do_download_draw_rgb_gles2 (GstGLDisplay * display, GstGLDownload * download)
{
+ GstGLFuncs *gl;
GstVideoFormat v_format;
guint out_width, out_height;
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:
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;
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);
+
+ 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);
- glDrawBuffer (GL_NONE);
+ 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]);
}
"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
static void
_do_download_draw_yuv_gles2 (GstGLDisplay * display, GstGLDownload * download)
{
+ GstGLFuncs *gl;
GstVideoFormat v_format;
guint out_width, out_height;
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);
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;
}
- 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]);
}
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
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:
//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
/* 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, \
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
{
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 */
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;
* 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;
{
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
}
#ifndef __COGL_FEATURE_PRIVATE_H
#define __COGL_FEATURE_PRIVATE_H
-#include <glib.h>
+#include <gst/gst.h>
#include "gstgldisplay.h"
_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);
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 */
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;
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;
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;
/* ERRORS */
fbo_error:
{
- glDeleteRenderbuffers (1, &rboId);
- glDeleteFramebuffers (1, &fboId);
+ gl->DeleteRenderbuffers (1, &rboId);
+ gl->DeleteFramebuffers (1, &fboId);
copy_params->tex_id = 0;
}
#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))
#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,
gboolean compiled;
gboolean active;
+
+ GstGLShaderVTable vtable;
};
GST_DEBUG_CATEGORY_STATIC (gst_gl_shader_debug);
{
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);
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" ); */
}
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 */
+}
+
+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;
+ }
- GST_TRACE ("shader initialized %u", priv->program_handle);
+ 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;
}
gst_gl_shader_compile (GstGLShader * shader, GError ** error)
{
GstGLShaderPrivate *priv;
+ GstGLFuncs *gl;
gchar info_buffer[2048];
gint len = 0;
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;
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) {
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);
}
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';
gst_gl_shader_release (GstGLShader * shader)
{
GstGLShaderPrivate *priv;
- /* GLint status; */
- /* GLenum err = 0; */
g_return_if_fail (GST_GL_IS_SHADER (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");
{
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)
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;
}
}
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;
+
+ location = gl->GetUniformLocation (priv->program_handle, name);
- glUniform1fARB (location, value);
+ gl->Uniform1f (location, value);
}
void
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 */
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
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
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);
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;
}
void
_init_upload (GstGLDisplay * display, GstGLUpload * upload)
{
+ GstGLFuncs *gl;
GstVideoFormat v_format;
guint in_width, in_height, out_width, out_height;
+ gl = display->gl_vtable;
+
v_format = GST_VIDEO_INFO_FORMAT (&upload->info);
in_width = upload->in_width;
in_height = upload->in_height;
{
/* check if fragment shader is available, then load them */
/* shouldn't we require ARB_shading_language_100? --Filippo */
- if (GLEW_ARB_fragment_shader) {
+ if (gl->CreateProgramObject || gl->CreateProgram) {
GST_INFO ("Context, ARB_fragment_shader supported: yes");
"Unsupported upload video format %d", v_format);
break;
}
- }
- /* check if YCBCR MESA is available */
- else if (GLEW_MESA_ycbcr_texture) {
+ /* check if YCBCR MESA is available */
+#if 0
+ } else if (GLEW_MESA_ycbcr_texture) {
/* GLSL and Color Matrix are not available on your drivers,
* switch to YCBCR MESA
*/
gst_gl_display_set_error (display,
"Colorspace conversion using Color Matrix is not yet supported");
+#endif
} else {
/* colorspace conversion is not possible */
gst_gl_display_set_error (display,
- "ARB_fragment_shader supported, GLEW_ARB_imaging supported, GLEW_MESA_ycbcr_texture supported, not supported");
+ "ARB_fragment_shader supported, GL_ARB_imaging supported, GL_MESA_ycbcr_texture supported, not supported");
}
}
break;
void
_init_upload_fbo (GstGLDisplay * display, GstGLUpload * upload)
{
+ GstGLFuncs *gl;
guint out_width, out_height;
GLuint fake_texture = 0; /* a FBO must hava texture to init */
+ gl = display->gl_vtable;
+
out_width = GST_VIDEO_INFO_WIDTH (&upload->info);
out_height = GST_VIDEO_INFO_HEIGHT (&upload->info);
- if (!GLEW_EXT_framebuffer_object) {
+ if (!gl->GenFramebuffers) {
/* turn off the pipeline because Frame buffer object is a not present */
gst_gl_display_set_error (display,
"Context, EXT_framebuffer_object supported: no");
GST_INFO ("Context, EXT_framebuffer_object supported: yes");
/* setup FBO */
- glGenFramebuffersEXT (1, &upload->fbo);
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, upload->fbo);
+ gl->GenFramebuffers (1, &upload->fbo);
+ gl->BindFramebuffer (GL_FRAMEBUFFER, upload->fbo);
/* setup the render buffer for depth */
- glGenRenderbuffersEXT (1, &upload->depth_buffer);
- glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, upload->depth_buffer);
-#if GST_GL_HAVE_OPENGL
+ gl->GenRenderbuffers (1, &upload->depth_buffer);
+ gl->BindRenderbuffer (GL_RENDERBUFFER, upload->depth_buffer);
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
/* a fake texture is attached to the upload FBO (cannot init without it) */
- glGenTextures (1, &fake_texture);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, fake_texture);
- glTexImage2D (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_LINEAR);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+ gl->GenTextures (1, &fake_texture);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, fake_texture);
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, out_width, out_height,
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ GL_LINEAR);
+ gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR);
+ gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
- 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 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, fake_texture, 0);
/* attach the depth render buffer to the FBO */
- glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT, upload->depth_buffer);
+ gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
+ GL_RENDERBUFFER, upload->depth_buffer);
-#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (display)) {
- glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT, upload->depth_buffer);
+ gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
+ GL_RENDERBUFFER, upload->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);
- glDeleteTextures (1, &fake_texture);
+ gl->DeleteTextures (1, &fake_texture);
_do_upload_make (display, upload);
}
in_width = upload->in_width;
in_height = upload->in_height;
- GST_TRACE ("uploading texture:%u dimensions: %ux%u", upload->out_texture,
- out_width, out_height);
+ GST_TRACE ("uploading to texture:%u dimensions:%ux%u, "
+ "from textures:%u,%u,%u dimensions:%ux%u", upload->out_texture,
+ out_width, out_height, upload->in_texture[0], upload->in_texture[1],
+ upload->in_texture[2], in_width, in_height);
_do_upload_fill (display, upload);
void
_do_upload_make (GstGLDisplay * display, GstGLUpload * upload)
{
+ GstGLFuncs *gl;
GstVideoFormat v_format;
guint in_width, in_height;
+ gl = display->gl_vtable;
+
in_width = upload->in_width;
in_height = upload->in_height;
v_format = GST_VIDEO_INFO_FORMAT (&upload->info);
- glGenTextures (1, &upload->in_texture[0]);
+ gl->GenTextures (1, &upload->in_texture[0]);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
switch (v_format) {
case GST_VIDEO_FORMAT_RGBx:
case GST_VIDEO_FORMAT_BGRx:
case GST_VIDEO_FORMAT_BGRA:
case GST_VIDEO_FORMAT_ARGB:
case GST_VIDEO_FORMAT_ABGR:
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
in_width, in_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
break;
case GST_VIDEO_FORMAT_RGB:
case GST_VIDEO_FORMAT_BGR:
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
in_width, in_height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
break;
case GST_VIDEO_FORMAT_AYUV:
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
in_width, in_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, NULL);
break;
case GST_VIDEO_FORMAT_YUY2:
switch (display->colorspace_conversion) {
case GST_GL_DISPLAY_CONVERSION_GLSL:
case GST_GL_DISPLAY_CONVERSION_MATRIX:
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE_ALPHA,
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE_ALPHA,
in_width, in_height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,
NULL);
- glGenTextures (1, &upload->in_texture[1]);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+ gl->GenTextures (1, &upload->in_texture[1]);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
in_width, in_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
NULL);
break;
case GST_GL_DISPLAY_CONVERSION_MESA:
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, in_width,
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, in_width,
in_height, 0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, NULL);
break;
default:
break;
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12:
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
in_width, in_height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
- glGenTextures (1, &upload->in_texture[1]);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
+ gl->GenTextures (1, &upload->in_texture[1]);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
GST_ROUND_UP_2 (in_width) / 2,
GST_ROUND_UP_2 (in_height) / 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
NULL);
- glGenTextures (1, &upload->in_texture[2]);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
+ gl->GenTextures (1, &upload->in_texture[2]);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
+ gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
GST_ROUND_UP_2 (in_width) / 2,
GST_ROUND_UP_2 (in_height) / 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
NULL);
void
_do_upload_fill (GstGLDisplay * display, GstGLUpload * upload)
{
+ GstGLFuncs *gl;
GstVideoFormat v_format;
guint in_width, in_height, out_width, out_height;
+ gl = display->gl_vtable;
+
in_width = upload->in_width;
in_height = upload->in_height;
out_width = GST_VIDEO_INFO_WIDTH (&upload->info);
case GST_VIDEO_FORMAT_ABGR:
/* color space conversion is not needed */
if (in_width != out_width || in_height != out_height)
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
else
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->out_texture);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->out_texture);
break;
case GST_VIDEO_FORMAT_YUY2:
case GST_VIDEO_FORMAT_UYVY:
switch (display->colorspace_conversion) {
case GST_GL_DISPLAY_CONVERSION_GLSL:
case GST_GL_DISPLAY_CONVERSION_MATRIX:
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
break;
case GST_GL_DISPLAY_CONVERSION_MESA:
if (in_width != out_width || in_height != out_height)
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
else
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->out_texture);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->out_texture);
break;
default:
gst_gl_display_set_error (display, "Unknown colorspace conversion %d",
switch (v_format) {
case GST_VIDEO_FORMAT_RGB:
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
GL_RGB, GL_UNSIGNED_BYTE, upload->data[0]);
break;
case GST_VIDEO_FORMAT_BGR:
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
GL_BGR, GL_UNSIGNED_BYTE, upload->data[0]);
break;
case GST_VIDEO_FORMAT_RGBx:
case GST_VIDEO_FORMAT_RGBA:
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
GL_RGBA, GL_UNSIGNED_BYTE, upload->data[0]);
break;
case GST_VIDEO_FORMAT_BGRx:
case GST_VIDEO_FORMAT_BGRA:
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
GL_BGRA, GL_UNSIGNED_BYTE, upload->data[0]);
break;
case GST_VIDEO_FORMAT_AYUV:
case GST_VIDEO_FORMAT_xRGB:
case GST_VIDEO_FORMAT_ARGB:
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, upload->data[0]);
break;
case GST_VIDEO_FORMAT_xBGR:
case GST_VIDEO_FORMAT_ABGR:
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, upload->data[0]);
break;
case GST_VIDEO_FORMAT_YUY2:
switch (display->colorspace_conversion) {
case GST_GL_DISPLAY_CONVERSION_GLSL:
case GST_GL_DISPLAY_CONVERSION_MATRIX:
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width,
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width,
in_height, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, upload->data[0]);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, in_height,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, upload->data[0]);
break;
case GST_GL_DISPLAY_CONVERSION_MESA:
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width,
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width,
in_height, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA,
upload->data[0]);
break;
switch (display->colorspace_conversion) {
case GST_GL_DISPLAY_CONVERSION_GLSL:
case GST_GL_DISPLAY_CONVERSION_MATRIX:
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width,
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width,
in_height, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, upload->data[0]);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, in_height,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, upload->data[0]);
break;
case GST_GL_DISPLAY_CONVERSION_MESA:
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width,
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width,
in_height, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA,
upload->data[0]);
break;
break;
case GST_VIDEO_FORMAT_I420:
{
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[0]);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, GST_ROUND_UP_2 (in_height) / 2,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[1]);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, GST_ROUND_UP_2 (in_height) / 2,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[2]);
}
break;
case GST_VIDEO_FORMAT_YV12: /* same as I420 except plane 1+2 swapped */
{
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, in_width, in_height,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[0]);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, GST_ROUND_UP_2 (in_height) / 2,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[1]);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
- glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
+ gl->TexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
GST_ROUND_UP_2 (in_width) / 2, GST_ROUND_UP_2 (in_height) / 2,
GL_LUMINANCE, GL_UNSIGNED_BYTE, upload->data[2]);
}
static void
_do_upload_draw_opengl (GstGLDisplay * display, GstGLUpload * upload)
{
+ GstGLFuncs *gl;
GstVideoFormat v_format;
guint out_width, out_height;
- guint in_width, in_height;
+ guint in_width = upload->in_width;
+ guint in_height = upload->in_height;
+
+ gfloat verts[8] = { 1.0f, -1.0f,
+ -1.0f, -1.0f,
+ -1.0f, 1.0f,
+ 1.0f, 1.0f
+ };
+ gint texcoords[8] = { in_width, 0,
+ 0, 0,
+ 0, in_height,
+ in_width, in_height
+ };
+
+ gl = display->gl_vtable;
out_width = GST_VIDEO_INFO_WIDTH (&upload->info);
out_height = GST_VIDEO_INFO_HEIGHT (&upload->info);
v_format = GST_VIDEO_INFO_FORMAT (&upload->info);
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, upload->fbo);
+ gl->BindFramebuffer (GL_FRAMEBUFFER, upload->fbo);
/* setup a texture to render to */
- in_width = upload->in_width;
- in_height = upload->in_height;
- glEnable (GL_TEXTURE_RECTANGLE_ARB);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->out_texture);
+ gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->out_texture);
/* attach the 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, upload->out_texture, 0);
- if (GLEW_ARB_fragment_shader)
- gst_gl_shader_use (NULL);
+ gst_gl_display_clear_shader (display);
- 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);
- 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);
switch (v_format) {
case GST_VIDEO_FORMAT_RGBx:
case GST_VIDEO_FORMAT_RGB:
case GST_VIDEO_FORMAT_BGR:
{
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
+ gl->MatrixMode (GL_PROJECTION);
+ gl->LoadIdentity ();
- glEnable (GL_TEXTURE_RECTANGLE_ARB);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ 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);
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ gl->TexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
break;
{
gst_gl_shader_use (upload->shader);
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
+ gl->MatrixMode (GL_PROJECTION);
+ gl->LoadIdentity ();
- glActiveTextureARB (GL_TEXTURE1_ARB);
+ gl->ActiveTexture (GL_TEXTURE1);
gst_gl_shader_set_uniform_1i (upload->shader, "UVtex", 1);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
+ 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);
- glActiveTextureARB (GL_TEXTURE0_ARB);
+ gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (upload->shader, "Ytex", 0);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ 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);
}
break;
case GST_GL_DISPLAY_CONVERSION_MESA:
{
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
- glEnable (GL_TEXTURE_RECTANGLE_ARB);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->MatrixMode (GL_PROJECTION);
+ gl->LoadIdentity ();
+ gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ 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);
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ gl->TexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
break;
default:
{
gst_gl_shader_use (upload->shader);
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
+ gl->MatrixMode (GL_PROJECTION);
+ gl->LoadIdentity ();
- glActiveTextureARB (GL_TEXTURE1_ARB);
+ gl->ActiveTexture (GL_TEXTURE1);
gst_gl_shader_set_uniform_1i (upload->shader, "Utex", 1);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
+ 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);
- glActiveTextureARB (GL_TEXTURE2_ARB);
+ gl->ActiveTexture (GL_TEXTURE2);
gst_gl_shader_set_uniform_1i (upload->shader, "Vtex", 2);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
+ 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);
- glActiveTextureARB (GL_TEXTURE0_ARB);
+ gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (upload->shader, "Ytex", 0);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ 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);
}
break;
{
gst_gl_shader_use (upload->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 (upload->shader, "tex", 0);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ 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);
}
break;
v_format);
g_assert_not_reached ();
break;
-
} /* end switch display->currentVideo_format */
- glBegin (GL_QUADS);
- glTexCoord2i (in_width, 0);
- glVertex2f (1.0f, -1.0f);
- glTexCoord2i (0, 0);
- glVertex2f (-1.0f, -1.0f);
- glTexCoord2i (0, in_height);
- glVertex2f (-1.0f, 1.0f);
- glTexCoord2i (in_width, in_height);
- glVertex2f (1.0f, 1.0f);
- 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);
- glDrawBuffer (GL_NONE);
+ gl->DrawArrays (GL_TRIANGLE_FAN, 0, 4);
+
+ gl->DisableClientState (GL_VERTEX_ARRAY);
+ gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
+
+ gl->DrawBuffer (GL_NONE);
/* we are done with the shader */
- if (display->colorspace_conversion == GST_GL_DISPLAY_CONVERSION_GLSL)
- glUseProgramObjectARB (0);
+ gst_gl_display_clear_shader (display);
- glDisable (GL_TEXTURE_RECTANGLE_ARB);
+ gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
- glMatrixMode (GL_PROJECTION);
- glPopMatrix ();
- glMatrixMode (GL_MODELVIEW);
- glPopMatrix ();
- glPopAttrib ();
+ 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, 0);
+ gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
}
#endif
static void
_do_upload_draw_gles2 (GstGLDisplay * display, GstGLUpload * upload)
{
+ GstGLFuncs *gl;
GstVideoFormat v_format;
guint out_width, out_height;
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
+ gl = display->gl_vtable;
+
out_width = GST_VIDEO_INFO_WIDTH (&upload->info);
out_height = GST_VIDEO_INFO_HEIGHT (&upload->info);
v_format = GST_VIDEO_INFO_FORMAT (&upload->info);
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, upload->fbo);
+ gl->BindFramebuffer (GL_FRAMEBUFFER, upload->fbo);
/* setup a texture to render to */
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->out_texture);
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->out_texture);
/* attach the 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, upload->out_texture, 0);
- if (GLEW_ARB_fragment_shader)
- gst_gl_shader_use (NULL);
+ gst_gl_display_clear_shader (display);
- 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);
- 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);
switch (v_format) {
case GST_VIDEO_FORMAT_RGBx:
case GST_VIDEO_FORMAT_RGB:
case GST_VIDEO_FORMAT_BGR:
{
- glVertexAttribPointer (upload->shader_attr_position_loc, 3,
+ gl->VertexAttribPointer (upload->shader_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
- glVertexAttribPointer (upload->shader_attr_texture_loc, 2,
+ gl->VertexAttribPointer (upload->shader_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
- glEnableVertexAttribArray (upload->shader_attr_position_loc);
- glEnableVertexAttribArray (upload->shader_attr_texture_loc);
+ gl->EnableVertexAttribArray (upload->shader_attr_position_loc);
+ gl->EnableVertexAttribArray (upload->shader_attr_texture_loc);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ 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);
}
break;
{
gst_gl_shader_use (upload->shader);
- glVertexAttribPointer (upload->shader_attr_position_loc, 3,
+ gl->VertexAttribPointer (upload->shader_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
- glVertexAttribPointer (upload->shader_attr_texture_loc, 2,
+ gl->VertexAttribPointer (upload->shader_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
- glEnableVertexAttribArray (upload->shader_attr_position_loc);
- glEnableVertexAttribArray (upload->shader_attr_texture_loc);
+ gl->EnableVertexAttribArray (upload->shader_attr_position_loc);
+ gl->EnableVertexAttribArray (upload->shader_attr_texture_loc);
- glActiveTextureARB (GL_TEXTURE1_ARB);
+ gl->ActiveTexture (GL_TEXTURE1);
gst_gl_shader_set_uniform_1i (upload->shader, "UVtex", 1);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
+ 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);
- glActiveTextureARB (GL_TEXTURE0_ARB);
+ gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (upload->shader, "Ytex", 0);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ 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);
}
break;
case GST_GL_DISPLAY_CONVERSION_MESA:
{
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ 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);
}
break;
{
gst_gl_shader_use (upload->shader);
- glVertexAttribPointer (upload->shader_attr_position_loc, 3,
+ gl->VertexAttribPointer (upload->shader_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
- glVertexAttribPointer (upload->shader_attr_texture_loc, 2,
+ gl->VertexAttribPointer (upload->shader_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
- glEnableVertexAttribArray (upload->shader_attr_position_loc);
- glEnableVertexAttribArray (upload->shader_attr_texture_loc);
+ gl->EnableVertexAttribArray (upload->shader_attr_position_loc);
+ gl->EnableVertexAttribArray (upload->shader_attr_texture_loc);
- glActiveTextureARB (GL_TEXTURE1_ARB);
+ gl->ActiveTexture (GL_TEXTURE1);
gst_gl_shader_set_uniform_1i (upload->shader, "Utex", 1);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[1]);
+ 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);
- glActiveTextureARB (GL_TEXTURE2_ARB);
+ gl->ActiveTexture (GL_TEXTURE2);
gst_gl_shader_set_uniform_1i (upload->shader, "Vtex", 2);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[2]);
+ 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);
- glActiveTextureARB (GL_TEXTURE0_ARB);
+ gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (upload->shader, "Ytex", 0);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ 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);
}
break;
{
gst_gl_shader_use (upload->shader);
- glVertexAttribPointer (upload->shader_attr_position_loc, 3,
+ gl->VertexAttribPointer (upload->shader_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
- glVertexAttribPointer (upload->shader_attr_texture_loc, 2,
+ gl->VertexAttribPointer (upload->shader_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
- glEnableVertexAttribArray (upload->shader_attr_position_loc);
- glEnableVertexAttribArray (upload->shader_attr_texture_loc);
+ gl->EnableVertexAttribArray (upload->shader_attr_position_loc);
+ gl->EnableVertexAttribArray (upload->shader_attr_texture_loc);
- glActiveTextureARB (GL_TEXTURE0_ARB);
+ gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (upload->shader, "tex", 0);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+ gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->in_texture[0]);
+ 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);
}
break;
} /* end switch display->currentVideo_format */
- glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
+ gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
/* we are done with the shader */
- if (display->colorspace_conversion == GST_GL_DISPLAY_CONVERSION_GLSL)
- 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, 0);
+ gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
}
#endif