2013-06-11 15:04:55 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 2013 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.
|
|
|
|
*/
|
2013-07-10 09:24:34 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2013-06-11 15:04:55 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2013-07-10 15:03:04 +00:00
|
|
|
#include "gl.h"
|
2013-06-11 15:04:55 +00:00
|
|
|
#include "gstglutils.h"
|
|
|
|
|
|
|
|
#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)
|
|
|
|
#define USING_OPENGL3(display) (display->gl_api & GST_GL_API_OPENGL3)
|
|
|
|
#define USING_GLES(display) (display->gl_api & GST_GL_API_GLES)
|
|
|
|
#define USING_GLES2(display) (display->gl_api & GST_GL_API_GLES2)
|
|
|
|
#define USING_GLES3(display) (display->gl_api & GST_GL_API_GLES3)
|
|
|
|
|
|
|
|
static GLuint gen_texture;
|
|
|
|
static GLuint gen_texture_width;
|
|
|
|
static GLuint gen_texture_height;
|
|
|
|
static GstVideoFormat gen_texture_video_format;
|
|
|
|
|
2013-06-13 04:36:41 +00:00
|
|
|
static GLuint *del_texture;
|
|
|
|
|
2013-06-13 06:55:37 +00:00
|
|
|
static gchar *error_message;
|
|
|
|
|
2013-06-11 15:04:55 +00:00
|
|
|
static void
|
|
|
|
gst_gl_display_gen_texture_window_cb (GstGLDisplay * display)
|
|
|
|
{
|
|
|
|
gst_gl_display_gen_texture_thread (display, &gen_texture,
|
|
|
|
gen_texture_video_format, gen_texture_width, gen_texture_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate a texture if no one is available in the pool
|
|
|
|
* Called in the gl thread */
|
|
|
|
void
|
|
|
|
gst_gl_display_gen_texture_thread (GstGLDisplay * display, GLuint * pTexture,
|
|
|
|
GstVideoFormat v_format, GLint width, GLint height)
|
|
|
|
{
|
|
|
|
const GstGLFuncs *gl = display->gl_vtable;
|
|
|
|
|
|
|
|
GST_TRACE ("Generating texture format:%u dimensions:%ux%u", v_format,
|
|
|
|
width, height);
|
|
|
|
|
|
|
|
gl->GenTextures (1, pTexture);
|
|
|
|
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, *pTexture);
|
2013-07-04 00:01:52 +00:00
|
|
|
gl->TexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, width, height, 0,
|
|
|
|
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
2013-06-11 15:04:55 +00:00
|
|
|
|
|
|
|
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
|
|
|
|
GL_LINEAR);
|
|
|
|
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
|
|
|
|
GL_LINEAR);
|
|
|
|
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
|
|
|
|
GL_CLAMP_TO_EDGE);
|
|
|
|
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
|
|
|
|
GL_CLAMP_TO_EDGE);
|
|
|
|
|
|
|
|
GST_LOG ("generated texture id:%d", *pTexture);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-06-13 04:36:41 +00:00
|
|
|
gst_gl_display_del_texture_window_cb (GstGLDisplay * display)
|
2013-06-11 15:04:55 +00:00
|
|
|
{
|
2013-09-26 13:46:16 +00:00
|
|
|
const GstGLFuncs *gl = display->gl_vtable;
|
|
|
|
gl->DeleteTextures (1, del_texture);
|
2013-06-11 15:04:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* called in the gl thread */
|
|
|
|
gboolean
|
|
|
|
gst_gl_display_check_framebuffer_status (GstGLDisplay * display)
|
|
|
|
{
|
|
|
|
GLenum status = 0;
|
|
|
|
status = display->gl_vtable->CheckFramebufferStatus (GL_FRAMEBUFFER);
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
case GL_FRAMEBUFFER_COMPLETE:
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GL_FRAMEBUFFER_UNSUPPORTED:
|
|
|
|
GST_ERROR ("GL_FRAMEBUFFER_UNSUPPORTED");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
|
|
|
GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
|
|
|
GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
|
|
|
|
break;
|
|
|
|
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
|
|
|
|
GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
|
|
|
|
break;
|
|
|
|
#if GST_GL_HAVE_OPENGL
|
|
|
|
case GL_FRAMEBUFFER_UNDEFINED:
|
|
|
|
GST_ERROR ("GL_FRAMEBUFFER_UNDEFINED");
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
GST_ERROR ("General FBO error");
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-06-13 06:31:38 +00:00
|
|
|
void
|
|
|
|
gst_gl_display_activate_gl_context (GstGLDisplay * display, gboolean activate)
|
|
|
|
{
|
2013-08-14 00:44:19 +00:00
|
|
|
GstGLContext *context;
|
2013-06-13 06:31:38 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_GL_DISPLAY (display));
|
|
|
|
|
|
|
|
if (!activate)
|
|
|
|
gst_gl_display_lock (display);
|
|
|
|
|
2013-08-14 00:44:19 +00:00
|
|
|
context = gst_gl_display_get_context_unlocked (display);
|
2013-06-13 06:31:38 +00:00
|
|
|
|
2013-08-14 00:44:19 +00:00
|
|
|
gst_gl_context_activate (context, activate);
|
2013-06-13 06:31:38 +00:00
|
|
|
|
|
|
|
if (activate)
|
|
|
|
gst_gl_display_unlock (display);
|
|
|
|
|
2013-08-14 00:44:19 +00:00
|
|
|
gst_object_unref (context);
|
2013-06-13 06:31:38 +00:00
|
|
|
}
|
|
|
|
|
2013-06-11 15:04:55 +00:00
|
|
|
void
|
|
|
|
gst_gl_display_gen_texture (GstGLDisplay * display, GLuint * pTexture,
|
|
|
|
GstVideoFormat v_format, GLint width, GLint height)
|
|
|
|
{
|
2013-08-14 00:44:19 +00:00
|
|
|
GstGLContext *context;
|
2013-06-12 13:17:30 +00:00
|
|
|
GstGLWindow *window;
|
|
|
|
|
2013-06-11 15:04:55 +00:00
|
|
|
gst_gl_display_lock (display);
|
|
|
|
|
2013-08-14 00:44:19 +00:00
|
|
|
context = gst_gl_display_get_context_unlocked (display);
|
|
|
|
window = gst_gl_context_get_window (context);
|
2013-06-12 13:17:30 +00:00
|
|
|
|
|
|
|
if (gst_gl_window_is_running (window)) {
|
2013-06-11 15:04:55 +00:00
|
|
|
gen_texture_width = width;
|
|
|
|
gen_texture_height = height;
|
|
|
|
gen_texture_video_format = v_format;
|
2013-06-12 13:17:30 +00:00
|
|
|
gst_gl_window_send_message (window,
|
2013-06-11 15:04:55 +00:00
|
|
|
GST_GL_WINDOW_CB (gst_gl_display_gen_texture_window_cb), display);
|
|
|
|
*pTexture = gen_texture;
|
|
|
|
} else
|
|
|
|
*pTexture = 0;
|
|
|
|
|
2013-08-14 00:44:19 +00:00
|
|
|
gst_object_unref (context);
|
2013-06-12 13:17:30 +00:00
|
|
|
gst_object_unref (window);
|
|
|
|
|
2013-06-11 15:04:55 +00:00
|
|
|
gst_gl_display_unlock (display);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_gl_display_del_texture (GstGLDisplay * display, GLuint * pTexture)
|
|
|
|
{
|
2013-08-14 00:44:19 +00:00
|
|
|
GstGLContext *context;
|
2013-06-13 04:36:41 +00:00
|
|
|
GstGLWindow *window;
|
|
|
|
|
2013-06-11 15:04:55 +00:00
|
|
|
gst_gl_display_lock (display);
|
2013-06-13 04:36:41 +00:00
|
|
|
|
2013-08-14 00:44:19 +00:00
|
|
|
context = gst_gl_display_get_context_unlocked (display);
|
|
|
|
window = gst_gl_context_get_window (context);
|
2013-06-13 04:36:41 +00:00
|
|
|
if (gst_gl_window_is_running (window) && *pTexture) {
|
|
|
|
del_texture = pTexture;
|
|
|
|
gst_gl_window_send_message (window,
|
|
|
|
GST_GL_WINDOW_CB (gst_gl_display_del_texture_window_cb), display);
|
2013-06-11 15:04:55 +00:00
|
|
|
}
|
2013-06-13 04:36:41 +00:00
|
|
|
|
2013-08-14 00:44:19 +00:00
|
|
|
gst_object_unref (context);
|
2013-06-13 04:36:41 +00:00
|
|
|
gst_object_unref (window);
|
|
|
|
|
2013-06-11 15:04:55 +00:00
|
|
|
gst_gl_display_unlock (display);
|
|
|
|
}
|
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
typedef struct _GenFBO
|
|
|
|
{
|
|
|
|
GstGLFramebuffer *frame;
|
|
|
|
gint width, height;
|
|
|
|
GLuint *fbo, *depth;
|
|
|
|
} GenFBO;
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gen_fbo (GstGLDisplay * display, GenFBO * data)
|
|
|
|
{
|
|
|
|
gst_gl_framebuffer_generate (data->frame, data->width, data->height,
|
|
|
|
data->fbo, data->depth);
|
|
|
|
}
|
|
|
|
|
2013-06-11 15:04:55 +00:00
|
|
|
gboolean
|
|
|
|
gst_gl_display_gen_fbo (GstGLDisplay * display, gint width, gint height,
|
|
|
|
GLuint * fbo, GLuint * depthbuffer)
|
|
|
|
{
|
2013-06-16 10:44:47 +00:00
|
|
|
GstGLFramebuffer *frame = gst_gl_framebuffer_new (display);
|
2013-06-11 15:04:55 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
GenFBO data = { frame, width, height, fbo, depthbuffer };
|
2013-06-12 13:17:30 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
gst_gl_display_thread_add (display, (GstGLDisplayThreadFunc) _gen_fbo, &data);
|
2013-06-12 13:17:30 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
gst_object_unref (frame);
|
2013-06-12 13:17:30 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
return TRUE;
|
2013-06-11 15:04:55 +00:00
|
|
|
}
|
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
typedef struct _UseFBO
|
|
|
|
{
|
|
|
|
GstGLFramebuffer *frame;
|
|
|
|
gint texture_fbo_width;
|
|
|
|
gint texture_fbo_height;
|
|
|
|
GLuint fbo;
|
|
|
|
GLuint depth_buffer;
|
|
|
|
GLuint texture_fbo;
|
|
|
|
GLCB cb;
|
|
|
|
gint input_tex_width;
|
|
|
|
gint input_tex_height;
|
|
|
|
GLuint input_tex;
|
|
|
|
gdouble proj_param1;
|
|
|
|
gdouble proj_param2;
|
|
|
|
gdouble proj_param3;
|
|
|
|
gdouble proj_param4;
|
|
|
|
GstGLDisplayProjection projection;
|
|
|
|
gpointer stuff;
|
|
|
|
} UseFBO;
|
|
|
|
|
|
|
|
static void
|
|
|
|
_use_fbo (GstGLDisplay * display, UseFBO * data)
|
|
|
|
{
|
|
|
|
gst_gl_framebuffer_use (data->frame, data->texture_fbo_width,
|
|
|
|
data->texture_fbo_height, data->fbo, data->depth_buffer,
|
|
|
|
data->texture_fbo, data->cb, data->input_tex_width,
|
|
|
|
data->input_tex_height, data->input_tex, data->proj_param1,
|
|
|
|
data->proj_param2, data->proj_param3, data->proj_param4, data->projection,
|
|
|
|
data->stuff);
|
|
|
|
}
|
2013-06-11 15:04:55 +00:00
|
|
|
|
|
|
|
/* Called by glfilter */
|
|
|
|
/* this function really has to be simplified... do we really need to
|
|
|
|
set projection this way? Wouldn't be better a set_projection
|
|
|
|
separate call? or just make glut functions available out of
|
|
|
|
gst-libs and call it if needed on drawcallback? -- Filippo */
|
|
|
|
/* GLCB too.. I think that only needed parameters should be
|
|
|
|
* GstGLDisplay *display and gpointer data, or just gpointer data */
|
|
|
|
/* ..everything here has to be simplified! */
|
|
|
|
gboolean
|
|
|
|
gst_gl_display_use_fbo (GstGLDisplay * display, gint texture_fbo_width,
|
|
|
|
gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
|
|
|
|
GLuint texture_fbo, GLCB cb, gint input_tex_width,
|
|
|
|
gint input_tex_height, GLuint input_tex, gdouble proj_param1,
|
|
|
|
gdouble proj_param2, gdouble proj_param3, gdouble proj_param4,
|
2013-06-16 10:44:47 +00:00
|
|
|
GstGLDisplayProjection projection, gpointer stuff)
|
2013-06-11 15:04:55 +00:00
|
|
|
{
|
2013-06-16 10:44:47 +00:00
|
|
|
GstGLFramebuffer *frame = gst_gl_framebuffer_new (display);
|
2013-06-11 15:04:55 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
UseFBO data =
|
|
|
|
{ frame, texture_fbo_width, texture_fbo_height, fbo, depth_buffer,
|
|
|
|
texture_fbo, cb, input_tex_width, input_tex_height, input_tex,
|
|
|
|
proj_param1, proj_param2, proj_param3, proj_param4, projection, stuff
|
|
|
|
};
|
2013-06-12 13:17:30 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
gst_gl_display_thread_add (display, (GstGLDisplayThreadFunc) _use_fbo, &data);
|
2013-06-12 13:17:30 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
gst_object_unref (frame);
|
2013-06-11 15:04:55 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct _UseFBO2
|
|
|
|
{
|
|
|
|
GstGLFramebuffer *frame;
|
|
|
|
gint texture_fbo_width;
|
|
|
|
gint texture_fbo_height;
|
|
|
|
GLuint fbo;
|
|
|
|
GLuint depth_buffer;
|
|
|
|
GLuint texture_fbo;
|
|
|
|
GLCB_V2 cb;
|
|
|
|
gpointer stuff;
|
|
|
|
} UseFBO2;
|
|
|
|
|
|
|
|
static void
|
|
|
|
_use_fbo_v2 (GstGLDisplay * display, UseFBO2 * data)
|
|
|
|
{
|
|
|
|
gst_gl_framebuffer_use_v2 (data->frame, data->texture_fbo_width,
|
|
|
|
data->texture_fbo_height, data->fbo, data->depth_buffer,
|
|
|
|
data->texture_fbo, data->cb, data->stuff);
|
2013-06-11 15:04:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_gl_display_use_fbo_v2 (GstGLDisplay * display, gint texture_fbo_width,
|
|
|
|
gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
|
2013-06-16 10:44:47 +00:00
|
|
|
GLuint texture_fbo, GLCB_V2 cb, gpointer stuff)
|
2013-06-11 15:04:55 +00:00
|
|
|
{
|
2013-06-16 10:44:47 +00:00
|
|
|
GstGLFramebuffer *frame = gst_gl_framebuffer_new (display);
|
2013-06-11 15:04:55 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
UseFBO2 data =
|
|
|
|
{ frame, texture_fbo_width, texture_fbo_height, fbo, depth_buffer,
|
|
|
|
texture_fbo, cb, stuff
|
|
|
|
};
|
2013-06-12 13:17:30 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
gst_gl_display_thread_add (display, (GstGLDisplayThreadFunc) _use_fbo_v2,
|
|
|
|
&data);
|
2013-06-12 13:17:30 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
gst_object_unref (frame);
|
2013-06-11 15:04:55 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct _DelFBO
|
|
|
|
{
|
|
|
|
GstGLFramebuffer *frame;
|
|
|
|
GLuint fbo;
|
|
|
|
GLuint depth;
|
|
|
|
} DelFBO;
|
|
|
|
|
|
|
|
/* Called in the gl thread */
|
|
|
|
static void
|
|
|
|
_del_fbo (GstGLDisplay * display, DelFBO * data)
|
|
|
|
{
|
|
|
|
gst_gl_framebuffer_delete (data->frame, data->fbo, data->depth);
|
2013-06-11 15:04:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Called by gltestsrc and glfilter */
|
|
|
|
void
|
|
|
|
gst_gl_display_del_fbo (GstGLDisplay * display, GLuint fbo, GLuint depth_buffer)
|
|
|
|
{
|
2013-06-16 10:44:47 +00:00
|
|
|
GstGLFramebuffer *frame = gst_gl_framebuffer_new (display);
|
2013-06-12 13:17:30 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
DelFBO data = { frame, fbo, depth_buffer };
|
2013-06-12 13:17:30 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
gst_gl_display_thread_add (display, (GstGLDisplayThreadFunc) _del_fbo, &data);
|
2013-06-12 13:17:30 +00:00
|
|
|
|
2013-06-16 10:44:47 +00:00
|
|
|
gst_object_unref (frame);
|
2013-06-11 15:04:55 +00:00
|
|
|
}
|
|
|
|
|
2013-06-27 14:34:48 +00:00
|
|
|
static void
|
|
|
|
_compile_shader (GstGLDisplay * display, GstGLShader ** shader)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
gst_gl_shader_compile (*shader, &error);
|
|
|
|
if (error) {
|
|
|
|
gst_gl_display_set_error (display, "%s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
error = NULL;
|
|
|
|
gst_gl_display_clear_shader (display);
|
|
|
|
gst_object_unref (*shader);
|
|
|
|
*shader = NULL;
|
|
|
|
}
|
|
|
|
}
|
2013-06-11 15:04:55 +00:00
|
|
|
|
|
|
|
/* Called by glfilter */
|
|
|
|
gboolean
|
2013-06-27 14:34:48 +00:00
|
|
|
gst_gl_display_gen_shader (GstGLDisplay * display, const gchar * vert_src,
|
|
|
|
const gchar * frag_src, GstGLShader ** shader)
|
2013-06-11 15:04:55 +00:00
|
|
|
{
|
2013-06-27 14:34:48 +00:00
|
|
|
g_return_val_if_fail (frag_src != NULL || vert_src != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (shader != NULL, FALSE);
|
2013-06-11 15:04:55 +00:00
|
|
|
|
2013-06-27 14:34:48 +00:00
|
|
|
*shader = gst_gl_shader_new (display);
|
2013-06-12 13:17:30 +00:00
|
|
|
|
2013-06-27 14:34:48 +00:00
|
|
|
if (frag_src)
|
|
|
|
gst_gl_shader_set_fragment_source (*shader, frag_src);
|
|
|
|
if (vert_src)
|
|
|
|
gst_gl_shader_set_vertex_source (*shader, vert_src);
|
2013-06-12 13:17:30 +00:00
|
|
|
|
2013-06-27 14:34:48 +00:00
|
|
|
gst_gl_display_thread_add (display, (GstGLDisplayThreadFunc) _compile_shader,
|
|
|
|
shader);
|
2013-06-11 15:04:55 +00:00
|
|
|
|
2013-06-27 14:34:48 +00:00
|
|
|
return *shader != NULL;
|
2013-06-11 15:04:55 +00:00
|
|
|
}
|
|
|
|
|
2013-06-13 06:55:37 +00:00
|
|
|
void
|
|
|
|
gst_gl_display_set_error (GstGLDisplay * display, const char *format, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
if (error_message)
|
|
|
|
g_free (error_message);
|
|
|
|
|
|
|
|
va_start (args, format);
|
|
|
|
error_message = g_strdup_vprintf (format, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
GST_WARNING ("%s", error_message);
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
gst_gl_display_get_error (void)
|
|
|
|
{
|
|
|
|
return error_message;
|
|
|
|
}
|
2013-06-11 15:04:55 +00:00
|
|
|
|
|
|
|
/* Called by glfilter */
|
|
|
|
void
|
|
|
|
gst_gl_display_del_shader (GstGLDisplay * display, GstGLShader * shader)
|
|
|
|
{
|
2013-06-27 14:34:48 +00:00
|
|
|
gst_object_unref (shader);
|
2013-06-11 15:04:55 +00:00
|
|
|
}
|