mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 09:08:14 +00:00
[624/906] OPENGL_ES2 => HAVE_GLES2 and add HAVE_OPENGL
use GstGLAPI to determine which code paths to execute. perform some cleanups
This commit is contained in:
parent
bbd3b4dbd9
commit
cc8e54541b
38 changed files with 2283 additions and 1486 deletions
|
@ -55,7 +55,8 @@ libgstgl_@GST_API_VERSION@include_HEADERS = \
|
|||
gstglshadervariables.h \
|
||||
gstglshader.h \
|
||||
gstgldownload.h \
|
||||
gstglupload.h
|
||||
gstglupload.h \
|
||||
gstglapi.h
|
||||
|
||||
libgstgl_@GST_API_VERSION@_la_CFLAGS = \
|
||||
$(GL_CFLAGS) \
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -25,8 +25,11 @@
|
|||
|
||||
#include <gst/video/video.h>
|
||||
|
||||
typedef struct _GstGLUpload GstGLUpload;
|
||||
typedef struct _GstGLDownload GstGLDownload;
|
||||
typedef struct _GstGLShader GstGLShader;
|
||||
|
||||
#include "gstglwindow.h"
|
||||
#include "gstglrenderer.h"
|
||||
#include "gstglshader.h"
|
||||
#include "gstglupload.h"
|
||||
#include "gstgldownload.h"
|
||||
|
@ -34,18 +37,19 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
GType gst_gl_display_get_type (void);
|
||||
#define GST_TYPE_GL_DISPLAY (gst_gl_display_get_type())
|
||||
#define GST_GL_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_DISPLAY,GstGLDisplay))
|
||||
#define GST_GL_TYPE_DISPLAY (gst_gl_display_get_type())
|
||||
#define GST_GL_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_GL_TYPE_DISPLAY,GstGLDisplay))
|
||||
#define GST_GL_DISPLAY_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_DISPLAY,GstGLDisplayClass))
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_GL_TYPE_DISPLAY,GstGLDisplayClass))
|
||||
#define GST_IS_GL_DISPLAY(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_DISPLAY))
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_GL_TYPE_DISPLAY))
|
||||
#define GST_IS_GL_DISPLAY_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_DISPLAY))
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_GL_TYPE_DISPLAY))
|
||||
#define GST_GL_DISPLAY_CAST(obj) ((GstGLDisplay*)(obj))
|
||||
|
||||
typedef struct _GstGLDisplay GstGLDisplay;
|
||||
typedef struct _GstGLDisplayClass GstGLDisplayClass;
|
||||
typedef struct _GstGLDisplayPrivate GstGLDisplayPrivate;
|
||||
|
||||
/**
|
||||
* GstGLDisplayConversion:
|
||||
|
@ -139,6 +143,9 @@ struct _GstGLDisplay
|
|||
GstGLWindow *gl_window;
|
||||
gboolean isAlive;
|
||||
|
||||
/* gl API we are using */
|
||||
GstGLAPI gl_api;
|
||||
|
||||
/* conditions */
|
||||
GCond *cond_create_context;
|
||||
GCond *cond_destroy_context;
|
||||
|
@ -152,10 +159,10 @@ struct _GstGLDisplay
|
|||
GLuint redisplay_texture_width;
|
||||
GLuint redisplay_texture_height;
|
||||
gboolean keep_aspect_ratio;
|
||||
#ifdef OPENGL_ES2
|
||||
#if HAVE_GLES2
|
||||
GstGLShader *redisplay_shader;
|
||||
gchar *redisplay_vertex_shader_str;
|
||||
gchar *redisplay_fragment_shader_str;
|
||||
gchar *redisplay_vertex_shader_str_gles2;
|
||||
gchar *redisplay_fragment_shader_str_gles2;
|
||||
GLint redisplay_attr_position_loc;
|
||||
GLint redisplay_attr_texture_loc;
|
||||
#endif
|
||||
|
@ -214,6 +221,8 @@ struct _GstGLDisplay
|
|||
GstGLShader *del_shader;
|
||||
|
||||
gchar *error_message;
|
||||
|
||||
GstGLDisplayPrivate *priv;
|
||||
};
|
||||
|
||||
|
||||
|
@ -277,6 +286,8 @@ void gst_gl_display_check_framebuffer_status (void);
|
|||
|
||||
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);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -24,8 +24,8 @@
|
|||
#include <gst/video/video.h>
|
||||
#include <gst/gstmemory.h>
|
||||
|
||||
#include "gstglshader.h"
|
||||
#include "gstgldisplay.h"
|
||||
#include "gstglshader.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -43,6 +43,7 @@ GType gst_gl_download_get_type (void);
|
|||
|
||||
typedef struct _GstGLDownload GstGLDownload;
|
||||
typedef struct _GstGLDownloadClass GstGLDownloadClass;
|
||||
typedef struct _GstGLDownloadPrivate GstGLDownloadPrivate;
|
||||
|
||||
/**
|
||||
* GstGLDownload
|
||||
|
@ -74,10 +75,10 @@ struct _GstGLDownload
|
|||
GLuint in_texture;
|
||||
GLuint out_texture[GST_VIDEO_MAX_PLANES];
|
||||
GstGLShader *shader;
|
||||
#ifdef OPENGL_ES2
|
||||
GLint shader_attr_position_loc;
|
||||
GLint shader_attr_texture_loc;
|
||||
#endif
|
||||
|
||||
GstGLDownloadPrivate *priv;
|
||||
|
||||
gpointer _reserved[GST_PADDING];
|
||||
};
|
||||
|
@ -97,12 +98,12 @@ struct _GstGLDownloadClass
|
|||
*
|
||||
* The currently supported formats that can be downloaded
|
||||
*/
|
||||
#ifndef OPENGL_ES2
|
||||
#if !HAVE_GLES2
|
||||
# define GST_GL_DOWNLOAD_FORMATS "{ RGB, RGBx, RGBA, BGR, BGRx, BGRA, xRGB, " \
|
||||
"xBGR, ARGB, ABGR, I420, YV12, YUY2, UYVY, AYUV }"
|
||||
#else /* OPENGL_ES2 */
|
||||
#else /* HAVE_GLES2 */
|
||||
# define GST_GL_DOWNLOAD_FORMATS "{ RGB, RGBx, RGBA, I420, YV12, YUY2, UYVY, AYUV }"
|
||||
#endif /* !OPENGL_ES2 */
|
||||
#endif /* !HAVE_GLES2 */
|
||||
|
||||
/**
|
||||
* GST_GL_DOWNLOAD_VIDEO_CAPS:
|
||||
|
|
|
@ -1075,7 +1075,7 @@ gst_gl_filter_render_to_target (GstGLFilter * filter, gboolean resize,
|
|||
in_width, 0, in_height, GST_GL_DISPLAY_PROJECTION_ORTHO2D, data);
|
||||
}
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
#if HAVE_OPENGL
|
||||
static void
|
||||
_draw_with_shader_cb (gint width, gint height, guint texture, gpointer stuff)
|
||||
{
|
||||
|
@ -1116,6 +1116,9 @@ void
|
|||
gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter,
|
||||
gboolean resize, GLuint input, GLuint target, GstGLShader * shader)
|
||||
{
|
||||
g_return_if_fail (gst_gl_display_get_gl_api (filter->display) &
|
||||
GST_GL_API_OPENGL);
|
||||
|
||||
filter->default_shader = shader;
|
||||
gst_gl_filter_render_to_target (filter, resize, input, target,
|
||||
_draw_with_shader_cb, filter);
|
||||
|
@ -1153,4 +1156,4 @@ gst_gl_filter_draw_texture (GstGLFilter * filter, GLuint texture,
|
|||
|
||||
glEnd ();
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_OPENGL */
|
||||
|
|
|
@ -124,12 +124,12 @@ gboolean gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
|
|||
void gst_gl_filter_render_to_target (GstGLFilter *filter, gboolean resize, GLuint input,
|
||||
GLuint target, GLCB func, gpointer data);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
#if HAVE_OPENGL
|
||||
void gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter, gboolean resize,
|
||||
GLuint input, GLuint target, GstGLShader *shader);
|
||||
|
||||
void gst_gl_filter_draw_texture (GstGLFilter *filter, GLuint texture, guint width, guint height);
|
||||
#endif /* !OPENGL_ES2 */
|
||||
#endif /* HAVE_OPENGL */
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -40,6 +40,12 @@
|
|||
* Data is uploaded or downloaded from the GPU as is necessary.
|
||||
*/
|
||||
|
||||
#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)
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_MEMORY);
|
||||
#define GST_CAT_DEFUALT GST_CAT_GL_MEMORY
|
||||
|
||||
|
@ -220,22 +226,29 @@ _gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
|
|||
glGenRenderbuffersEXT (1, &rboId);
|
||||
glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, rboId);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width,
|
||||
height);
|
||||
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT,
|
||||
width, height);
|
||||
#else
|
||||
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
|
||||
width, height);
|
||||
#if HAVE_OPENGL
|
||||
if (USING_OPENGL (display)) {
|
||||
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width,
|
||||
height);
|
||||
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT,
|
||||
width, height);
|
||||
}
|
||||
#endif
|
||||
#if HAVE_GLES2
|
||||
if (USING_GLES2 (display)) {
|
||||
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, 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);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT,
|
||||
GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboId);
|
||||
#if HAVE_OPENGL
|
||||
if (USING_OPENGL (display)) {
|
||||
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT,
|
||||
GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboId);
|
||||
}
|
||||
#endif
|
||||
|
||||
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
|
@ -264,7 +277,7 @@ _gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
|
|||
GST_CAT_ERROR (GST_CAT_GL_MEMORY,
|
||||
"GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
|
||||
break;
|
||||
#ifndef OPENGL_ES2
|
||||
#if HAVE_OPENGL
|
||||
case GL_FRAMEBUFFER_UNDEFINED:
|
||||
GST_CAT_ERROR (GST_CAT_GL_MEMORY, "GL_FRAMEBUFFER_UNDEFINED");
|
||||
break;
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
#define GST_GL_SHADER_GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE((o), GST_GL_TYPE_SHADER, GstGLShaderPrivate))
|
||||
|
||||
#define USING_OPENGL(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_OPENGL)
|
||||
#define USING_OPENGL3(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_OPENGL3)
|
||||
#define USING_GLES(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_GLES)
|
||||
#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)
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
@ -251,9 +257,13 @@ gst_gl_shader_init (GstGLShader * self)
|
|||
}
|
||||
|
||||
GstGLShader *
|
||||
gst_gl_shader_new (void)
|
||||
gst_gl_shader_new (GstGLDisplay * display)
|
||||
{
|
||||
return g_object_new (GST_GL_TYPE_SHADER, NULL);
|
||||
GstGLShader *shader = g_object_new (GST_GL_TYPE_SHADER, NULL);
|
||||
|
||||
shader->display = display;
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -270,7 +280,7 @@ gst_gl_shader_compile (GstGLShader * shader, GError ** error)
|
|||
GstGLShaderPrivate *priv;
|
||||
|
||||
gchar info_buffer[2048];
|
||||
GLsizei len = 0;
|
||||
gint len = 0;
|
||||
GLint status = GL_FALSE;
|
||||
|
||||
g_return_val_if_fail (GST_GL_IS_SHADER (shader), FALSE);
|
||||
|
@ -293,12 +303,15 @@ gst_gl_shader_compile (GstGLShader * shader, GError ** error)
|
|||
glGetObjectParameterivARB (priv->vertex_handle,
|
||||
GL_OBJECT_COMPILE_STATUS_ARB, &status);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
glGetInfoLogARB (priv->vertex_handle,
|
||||
sizeof (info_buffer) - 1, &len, info_buffer);
|
||||
#else
|
||||
glGetShaderInfoLog (priv->vertex_handle,
|
||||
sizeof (info_buffer) - 1, &len, info_buffer);
|
||||
#if HAVE_OPENGL
|
||||
if (USING_OPENGL (shader->display))
|
||||
glGetInfoLogARB (priv->vertex_handle,
|
||||
sizeof (info_buffer) - 1, &len, info_buffer);
|
||||
#endif
|
||||
#if HAVE_GLES2
|
||||
if (USING_GLES2 (shader->display))
|
||||
glGetShaderInfoLog (priv->vertex_handle,
|
||||
sizeof (info_buffer) - 1, &len, info_buffer);
|
||||
#endif
|
||||
info_buffer[len] = '\0';
|
||||
|
||||
|
@ -329,12 +342,15 @@ gst_gl_shader_compile (GstGLShader * shader, GError ** error)
|
|||
glGetObjectParameterivARB (priv->fragment_handle,
|
||||
GL_OBJECT_COMPILE_STATUS_ARB, &status);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
glGetInfoLogARB (priv->fragment_handle,
|
||||
sizeof (info_buffer) - 1, &len, info_buffer);
|
||||
#else
|
||||
glGetShaderInfoLog (priv->fragment_handle,
|
||||
sizeof (info_buffer) - 1, &len, info_buffer);
|
||||
#if HAVE_OPENGL
|
||||
if (USING_OPENGL (shader->display))
|
||||
glGetInfoLogARB (priv->fragment_handle,
|
||||
sizeof (info_buffer) - 1, &len, info_buffer);
|
||||
#endif
|
||||
#if HAVE_GLES2
|
||||
if (USING_GLES2 (shader->display))
|
||||
glGetShaderInfoLog (priv->fragment_handle,
|
||||
sizeof (info_buffer) - 1, &len, info_buffer);
|
||||
#endif
|
||||
info_buffer[len] = '\0';
|
||||
if (status != GL_TRUE) {
|
||||
|
@ -356,10 +372,13 @@ gst_gl_shader_compile (GstGLShader * shader, GError ** error)
|
|||
/* if nothing failed link shaders */
|
||||
glLinkProgramARB (priv->program_handle);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
glGetObjectParameterivARB (priv->program_handle, GL_LINK_STATUS, &status);
|
||||
#else
|
||||
glGetProgramiv (priv->program_handle, GL_LINK_STATUS, &status);
|
||||
#if HAVE_OPENGL
|
||||
if (USING_OPENGL (shader->display))
|
||||
glGetObjectParameterivARB (priv->program_handle, GL_LINK_STATUS, &status);
|
||||
#endif
|
||||
#if HAVE_GLES2
|
||||
if (USING_GLES2 (shader->display))
|
||||
glGetProgramiv (priv->program_handle, GL_LINK_STATUS, &status);
|
||||
#endif
|
||||
|
||||
glGetInfoLogARB (priv->program_handle,
|
||||
|
@ -400,10 +419,13 @@ gst_gl_shader_release (GstGLShader * shader)
|
|||
if (priv->vertex_handle) { /* not needed but nvidia doesn't care to respect the spec */
|
||||
GST_TRACE ("finalizing vertex shader %u", priv->vertex_handle);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
glDeleteObjectARB (priv->vertex_handle);
|
||||
#else
|
||||
glDeleteShader (priv->vertex_handle);
|
||||
#if HAVE_OPENGL
|
||||
if (USING_OPENGL (shader->display))
|
||||
glDeleteObjectARB (priv->vertex_handle);
|
||||
#endif
|
||||
#if HAVE_GLES2
|
||||
if (USING_GLES2 (shader->display))
|
||||
glDeleteShader (priv->vertex_handle);
|
||||
#endif
|
||||
|
||||
/* err = glGetError (); */
|
||||
|
@ -415,10 +437,14 @@ gst_gl_shader_release (GstGLShader * shader)
|
|||
if (priv->fragment_handle) {
|
||||
GST_TRACE ("finalizing fragment shader %u", priv->fragment_handle);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
glDeleteObjectARB (priv->fragment_handle);
|
||||
#else
|
||||
glDeleteShader (priv->fragment_handle);
|
||||
|
||||
#if HAVE_OPENGL
|
||||
if (USING_OPENGL (shader->display))
|
||||
glDeleteObjectARB (priv->fragment_handle);
|
||||
#endif
|
||||
#if HAVE_GLES2
|
||||
if (USING_GLES2 (shader->display))
|
||||
glDeleteShader (priv->fragment_handle);
|
||||
#endif
|
||||
|
||||
/* err = glGetError (); */
|
||||
|
@ -748,7 +774,7 @@ gst_gl_shader_set_uniform_4iv (GstGLShader * shader, const gchar * name,
|
|||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_2fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat * value)
|
||||
gint count, gboolean transpose, const gfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
@ -762,11 +788,42 @@ gst_gl_shader_set_uniform_matrix_2fv (GstGLShader * shader, const gchar * name,
|
|||
glUniformMatrix2fvARB (location, count, transpose, value);
|
||||
}
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_3fv (GstGLShader * shader, const gchar * name,
|
||||
gint count, gboolean transpose, const gfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniformMatrix3fvARB (location, count, transpose, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_4fv (GstGLShader * shader, const gchar * name,
|
||||
gint count, gboolean transpose, const gfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniformMatrix4fvARB (location, count, transpose, value);
|
||||
}
|
||||
|
||||
#if HAVE_OPENGL
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_2x3fv (GstGLShader * shader,
|
||||
const gchar * name, GLsizei count, GLboolean transpose,
|
||||
const GLfloat * value)
|
||||
const gchar * name, gint count, gboolean transpose, const gfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
@ -782,8 +839,7 @@ gst_gl_shader_set_uniform_matrix_2x3fv (GstGLShader * shader,
|
|||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_2x4fv (GstGLShader * shader,
|
||||
const gchar * name, GLsizei count, GLboolean transpose,
|
||||
const GLfloat * value)
|
||||
const gchar * name, gint count, gboolean transpose, const gfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
@ -796,29 +852,10 @@ gst_gl_shader_set_uniform_matrix_2x4fv (GstGLShader * shader,
|
|||
|
||||
glUniformMatrix2x4fv (location, count, transpose, value);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_3fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniformMatrix3fvARB (location, count, transpose, value);
|
||||
}
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_3x2fv (GstGLShader * shader,
|
||||
const gchar * name, GLsizei count, GLboolean transpose,
|
||||
const GLfloat * value)
|
||||
const gchar * name, gint count, gboolean transpose, const gfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
@ -834,8 +871,7 @@ gst_gl_shader_set_uniform_matrix_3x2fv (GstGLShader * shader,
|
|||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_3x4fv (GstGLShader * shader,
|
||||
const gchar * name, GLsizei count, GLboolean transpose,
|
||||
const GLfloat * value)
|
||||
const gchar * name, gint count, gboolean transpose, const gfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
@ -848,29 +884,10 @@ gst_gl_shader_set_uniform_matrix_3x4fv (GstGLShader * shader,
|
|||
|
||||
glUniformMatrix3x4fv (location, count, transpose, value);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_4fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniformMatrix4fvARB (location, count, transpose, value);
|
||||
}
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_4x2fv (GstGLShader * shader,
|
||||
const gchar * name, GLsizei count, GLboolean transpose,
|
||||
const GLfloat * value)
|
||||
const gchar * name, gint count, gboolean transpose, const gfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
@ -886,8 +903,7 @@ gst_gl_shader_set_uniform_matrix_4x2fv (GstGLShader * shader,
|
|||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_4x3fv (GstGLShader * shader,
|
||||
const gchar * name, GLsizei count, GLboolean transpose,
|
||||
const GLfloat * value)
|
||||
const gchar * name, gint count, gboolean transpose, const gfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
@ -900,7 +916,7 @@ gst_gl_shader_set_uniform_matrix_4x3fv (GstGLShader * shader,
|
|||
|
||||
glUniformMatrix4x3fv (location, count, transpose, value);
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_OPENGL */
|
||||
|
||||
GLint
|
||||
gst_gl_shader_get_attribute_location (GstGLShader * shader, const gchar * name)
|
||||
|
|
|
@ -21,18 +21,17 @@
|
|||
#ifndef __GST_GL_SHADER_H__
|
||||
#define __GST_GL_SHADER_H__
|
||||
|
||||
/* OpenGL 2.0 for Embedded Systems */
|
||||
#ifdef OPENGL_ES2
|
||||
#include <GLES2/gl2.h>
|
||||
#include "gstgles2.h"
|
||||
/* OpenGL for usual systems */
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gstgldisplay.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstGLDisplay GstGLDisplay;
|
||||
|
||||
#define GST_GL_TYPE_SHADER (gst_gl_shader_get_type())
|
||||
#define GST_GL_SHADER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_GL_TYPE_SHADER, GstGLShader))
|
||||
#define GST_GL_SHADER_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_GL_TYPE_SHADER, GstGLShaderClass))
|
||||
|
@ -60,6 +59,9 @@ typedef struct _GstGLShaderClass GstGLShaderClass;
|
|||
struct _GstGLShader {
|
||||
/*< private >*/
|
||||
GObject parent;
|
||||
|
||||
GstGLDisplay *display;
|
||||
|
||||
GstGLShaderPrivate *priv;
|
||||
};
|
||||
|
||||
|
@ -73,68 +75,51 @@ struct _GstGLShaderClass {
|
|||
GQuark gst_gl_shader_error_quark (void);
|
||||
GType gst_gl_shader_get_type (void);
|
||||
|
||||
GstGLShader * gst_gl_shader_new (void);
|
||||
GstGLShader * gst_gl_shader_new (GstGLDisplay *display);
|
||||
|
||||
void gst_gl_shader_set_vertex_source (GstGLShader *shader,
|
||||
const gchar *src);
|
||||
void gst_gl_shader_set_fragment_source (GstGLShader *shader,
|
||||
const gchar *src);
|
||||
const gchar * gst_gl_shader_get_vertex_source (GstGLShader *shader);
|
||||
void gst_gl_shader_set_vertex_source (GstGLShader *shader, const gchar *src);
|
||||
void gst_gl_shader_set_fragment_source (GstGLShader *shader, const gchar *src);
|
||||
const gchar * gst_gl_shader_get_vertex_source (GstGLShader *shader);
|
||||
const gchar * gst_gl_shader_get_fragment_source (GstGLShader *shader);
|
||||
|
||||
void gst_gl_shader_set_active (GstGLShader *shader,
|
||||
gboolean active);
|
||||
|
||||
gboolean gst_gl_shader_is_compiled (GstGLShader *shader);
|
||||
|
||||
gboolean gst_gl_shader_compile (GstGLShader *shader, GError **error);
|
||||
void gst_gl_shader_set_active (GstGLShader *shader, gboolean active);
|
||||
gboolean gst_gl_shader_is_compiled (GstGLShader *shader);
|
||||
gboolean gst_gl_shader_compile (GstGLShader *shader, GError **error);
|
||||
gboolean gst_gl_shader_compile_and_check (GstGLShader *shader, const gchar *source, GstGLShaderSourceType type);
|
||||
|
||||
void gst_gl_shader_release (GstGLShader *shader);
|
||||
void gst_gl_shader_use (GstGLShader *shader);
|
||||
void gst_gl_shader_use (GstGLShader *shader);
|
||||
|
||||
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);
|
||||
void gst_gl_shader_set_uniform_1f (GstGLShader *shader, const gchar *name, gfloat value);
|
||||
void gst_gl_shader_set_uniform_1fv (GstGLShader *shader, const gchar *name, guint count, gfloat * value);
|
||||
void gst_gl_shader_set_uniform_2i (GstGLShader *shader, const gchar *name, gint v0, gint v1);
|
||||
void gst_gl_shader_set_uniform_2iv (GstGLShader *shader, const gchar *name, guint count, gint * value);
|
||||
void gst_gl_shader_set_uniform_2f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1);
|
||||
void gst_gl_shader_set_uniform_2fv (GstGLShader *shader, const gchar *name, guint count, gfloat * value);
|
||||
void gst_gl_shader_set_uniform_3i (GstGLShader *shader, const gchar *name, gint v0, gint v1, gint v2);
|
||||
void gst_gl_shader_set_uniform_3iv (GstGLShader *shader, const gchar *name, guint count, gint * value);
|
||||
void gst_gl_shader_set_uniform_3f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1, gfloat v2);
|
||||
void gst_gl_shader_set_uniform_3fv (GstGLShader *shader, const gchar *name, guint count, gfloat * value);
|
||||
void gst_gl_shader_set_uniform_4i (GstGLShader *shader, const gchar *name, gint v0, gint v1, gint v2, gint v3);
|
||||
void gst_gl_shader_set_uniform_4iv (GstGLShader *shader, const gchar *name, guint count, gint * value);
|
||||
void gst_gl_shader_set_uniform_4f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1, gfloat v2, gfloat v3);
|
||||
void gst_gl_shader_set_uniform_4fv (GstGLShader *shader, const gchar *name, guint count, gfloat * value);
|
||||
void gst_gl_shader_set_uniform_matrix_2fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
#ifndef OPENGL_ES2
|
||||
void gst_gl_shader_set_uniform_matrix_2x3fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
void gst_gl_shader_set_uniform_matrix_2x4fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
#endif
|
||||
void gst_gl_shader_set_uniform_matrix_3fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
#ifndef OPENGL_ES2
|
||||
void gst_gl_shader_set_uniform_matrix_3x2fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
void gst_gl_shader_set_uniform_matrix_3x4fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
#endif
|
||||
void gst_gl_shader_set_uniform_matrix_4fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
#ifndef OPENGL_ES2
|
||||
void gst_gl_shader_set_uniform_matrix_4x2fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
void gst_gl_shader_set_uniform_matrix_4x3fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
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);
|
||||
void gst_gl_shader_set_uniform_1f (GstGLShader *shader, const gchar *name, gfloat value);
|
||||
void gst_gl_shader_set_uniform_1fv (GstGLShader *shader, const gchar *name, guint count, gfloat *value);
|
||||
void gst_gl_shader_set_uniform_2i (GstGLShader *shader, const gchar *name, gint v0, gint v1);
|
||||
void gst_gl_shader_set_uniform_2iv (GstGLShader *shader, const gchar *name, guint count, gint *value);
|
||||
void gst_gl_shader_set_uniform_2f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1);
|
||||
void gst_gl_shader_set_uniform_2fv (GstGLShader *shader, const gchar *name, guint count, gfloat *value);
|
||||
void gst_gl_shader_set_uniform_3i (GstGLShader *shader, const gchar *name, gint v0, gint v1, gint v2);
|
||||
void gst_gl_shader_set_uniform_3iv (GstGLShader *shader, const gchar *name, guint count, gint * value);
|
||||
void gst_gl_shader_set_uniform_3f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1, gfloat v2);
|
||||
void gst_gl_shader_set_uniform_3fv (GstGLShader *shader, const gchar *name, guint count, gfloat *value);
|
||||
void gst_gl_shader_set_uniform_4i (GstGLShader *shader, const gchar *name, gint v0, gint v1, gint v2, gint v3);
|
||||
void gst_gl_shader_set_uniform_4iv (GstGLShader *shader, const gchar *name, guint count, gint *value);
|
||||
void gst_gl_shader_set_uniform_4f (GstGLShader *shader, const gchar *name, gfloat v0, gfloat v1, gfloat v2, gfloat v3);
|
||||
void gst_gl_shader_set_uniform_4fv (GstGLShader *shader, const gchar *name, guint count, gfloat *value);
|
||||
void gst_gl_shader_set_uniform_matrix_2fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
|
||||
void gst_gl_shader_set_uniform_matrix_3fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
|
||||
void gst_gl_shader_set_uniform_matrix_4fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
|
||||
#if HAVE_OPENGL
|
||||
void gst_gl_shader_set_uniform_matrix_2x3fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
|
||||
void gst_gl_shader_set_uniform_matrix_2x4fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
|
||||
void gst_gl_shader_set_uniform_matrix_3x2fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
|
||||
void gst_gl_shader_set_uniform_matrix_3x4fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
|
||||
void gst_gl_shader_set_uniform_matrix_4x2fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
|
||||
void gst_gl_shader_set_uniform_matrix_4x3fv (GstGLShader *shader, const gchar *name, gint count, gboolean transpose, const gfloat* value);
|
||||
#endif
|
||||
|
||||
GLint gst_gl_shader_get_attribute_location (GstGLShader *shader, const gchar *name);
|
||||
void gst_gl_shader_bind_attribute_location (GstGLShader * shader, GLuint index, const gchar * name);
|
||||
gint gst_gl_shader_get_attribute_location (GstGLShader *shader, const gchar *name);
|
||||
void gst_gl_shader_bind_attribute_location (GstGLShader * shader, guint index, const gchar * name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -554,7 +554,19 @@ gst_gl_shadervariable_set (GstGLShader * shader,
|
|||
(float *) ret->value);
|
||||
break;
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
case _mat3:
|
||||
case _mat3x3:
|
||||
gst_gl_shader_set_uniform_matrix_3fv (shader, ret->name, ret->count, 0,
|
||||
(float *) ret->value);
|
||||
break;
|
||||
|
||||
case _mat4:
|
||||
case _mat4x4:
|
||||
gst_gl_shader_set_uniform_matrix_4fv (shader, ret->name, ret->count, 0,
|
||||
(float *) ret->value);
|
||||
break;
|
||||
|
||||
#if HAVE_OPENGL
|
||||
case _mat2x3:
|
||||
gst_gl_shader_set_uniform_matrix_2x3fv (shader, ret->name, ret->count, 0,
|
||||
(float *) ret->value);
|
||||
|
@ -574,13 +586,7 @@ gst_gl_shadervariable_set (GstGLShader * shader,
|
|||
gst_gl_shader_set_uniform_matrix_4x2fv (shader, ret->name, ret->count, 0,
|
||||
(float *) ret->value);
|
||||
break;
|
||||
#endif
|
||||
case _mat3:
|
||||
case _mat3x3:
|
||||
gst_gl_shader_set_uniform_matrix_3fv (shader, ret->name, ret->count, 0,
|
||||
(float *) ret->value);
|
||||
break;
|
||||
#ifndef OPENGL_ES2
|
||||
|
||||
case _mat3x4:
|
||||
gst_gl_shader_set_uniform_matrix_3x4fv (shader, ret->name, ret->count, 0,
|
||||
(float *) ret->value);
|
||||
|
@ -591,11 +597,6 @@ gst_gl_shadervariable_set (GstGLShader * shader,
|
|||
(float *) ret->value);
|
||||
break;
|
||||
#endif
|
||||
case _mat4:
|
||||
case _mat4x4:
|
||||
gst_gl_shader_set_uniform_matrix_4fv (shader, ret->name, ret->count, 0,
|
||||
(float *) ret->value);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -43,6 +43,7 @@ GType gst_gl_upload_get_type (void);
|
|||
|
||||
typedef struct _GstGLUpload GstGLUpload;
|
||||
typedef struct _GstGLUploadClass GstGLUploadClass;
|
||||
typedef struct _GstGLUploadPrivate GstGLUploadPrivate;
|
||||
|
||||
/**
|
||||
* GstGLUpload
|
||||
|
@ -76,12 +77,12 @@ struct _GstGLUpload
|
|||
guint in_width;
|
||||
guint in_height;
|
||||
GstGLShader *shader;
|
||||
#ifdef OPENGL_ES2
|
||||
GLint shader_attr_position_loc;
|
||||
GLint shader_attr_texture_loc;
|
||||
#endif
|
||||
|
||||
/* <private> */
|
||||
GstGLUploadPrivate *priv;
|
||||
|
||||
gpointer _reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
|
@ -100,12 +101,12 @@ struct _GstGLUploadClass
|
|||
*
|
||||
* The currently supported formats that can be uploaded
|
||||
*/
|
||||
#ifndef OPENGL_ES2
|
||||
# define GST_GL_UPLOAD_FORMATS "{ RGB, RGBx, RGBA, BGR, BGRx, BGRA, xRGB, " \
|
||||
#if !HAVE_GLES2
|
||||
#define GST_GL_UPLOAD_FORMATS "{ RGB, RGBx, RGBA, BGR, BGRx, BGRA, xRGB, " \
|
||||
"xBGR, ARGB, ABGR, I420, YV12, YUY2, UYVY, AYUV }"
|
||||
#else /* OPENGL_ES2 */
|
||||
#else /* HAVE_GLES2 */
|
||||
# define GST_GL_UPLOAD_FORMATS "{ RGB, RGBx, RGBA, I420, YV12, YUY2, UYVY, AYUV }"
|
||||
#endif
|
||||
#endif /* !HAVE_GLES2 */
|
||||
|
||||
/**
|
||||
* GST_GL_UPLOAD_VIDEO_CAPS:
|
||||
|
|
|
@ -5,7 +5,7 @@ AM_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
|
|||
AM_LIBS = $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS)
|
||||
|
||||
# full opengl required
|
||||
if USE_GL
|
||||
if USE_OPENGL
|
||||
OPENGL_SOURCES = \
|
||||
gstglfiltershader.c \
|
||||
gstglfiltershader.h \
|
||||
|
|
|
@ -31,7 +31,7 @@ gst_gl_effects_bulge_callback (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "bulge0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "bulge0", shader);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ gst_gl_effects_fisheye_callback (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "fisheye0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "fisheye0", shader);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ gst_gl_effects_glow_step_one (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "glow0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "glow0", shader);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ gst_gl_effects_glow_step_two (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "glow1");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "glow1", shader);
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ gst_gl_effects_glow_step_three (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "glow2");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "glow2", shader);
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ gst_gl_effects_glow_step_four (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "glow3");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "glow3", shader);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,51 +20,61 @@
|
|||
|
||||
#include <gstgleffects.h>
|
||||
|
||||
#define USING_OPENGL(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_OPENGL)
|
||||
#define USING_OPENGL3(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_OPENGL3)
|
||||
#define USING_GLES(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_GLES)
|
||||
#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)
|
||||
|
||||
static void
|
||||
gst_gl_effects_identity_callback (gint width, gint height, guint texture,
|
||||
gpointer data)
|
||||
{
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLFilter *filter = GST_GL_FILTER (effects);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
#else
|
||||
GstGLShader *shader =
|
||||
g_hash_table_lookup (effects->shaderstable, "identity0");
|
||||
#if HAVE_OPENGL
|
||||
if (USING_OPENGL (filter->display)) {
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
}
|
||||
#endif
|
||||
#if HAVE_GLES2
|
||||
if (USING_GLES2 (filter->display)) {
|
||||
GstGLShader *shader =
|
||||
g_hash_table_lookup (effects->shaderstable, "identity0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
g_hash_table_insert (effects->shaderstable, "identity0", shader);
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (filter->display);
|
||||
g_hash_table_insert (effects->shaderstable, "identity0", shader);
|
||||
|
||||
if (shader) {
|
||||
GError *error = NULL;
|
||||
gst_gl_shader_set_vertex_source (shader, vertex_shader_source);
|
||||
gst_gl_shader_set_fragment_source (shader, identity_fragment_source);
|
||||
|
||||
if (shader) {
|
||||
GError *error = NULL;
|
||||
gst_gl_shader_set_vertex_source (shader, vertex_shader_source);
|
||||
gst_gl_shader_set_fragment_source (shader, identity_fragment_source);
|
||||
|
||||
gst_gl_shader_compile (shader, &error);
|
||||
if (error) {
|
||||
GST_ERROR ("%s", error->message);
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
gst_gl_shader_use (NULL);
|
||||
} else {
|
||||
effects->draw_attr_position_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_position");
|
||||
effects->draw_attr_texture_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_texCoord");
|
||||
gst_gl_shader_compile (shader, &error);
|
||||
if (error) {
|
||||
GST_ERROR ("%s", error->message);
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
gst_gl_shader_use (NULL);
|
||||
} else {
|
||||
effects->draw_attr_position_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_position");
|
||||
effects->draw_attr_texture_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_texCoord");
|
||||
}
|
||||
}
|
||||
}
|
||||
gst_gl_shader_use (shader);
|
||||
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
}
|
||||
|
||||
gst_gl_shader_use (shader);
|
||||
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
||||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
#endif
|
||||
|
||||
gst_gl_effects_draw_texture (effects, texture, width, height);
|
||||
|
|
|
@ -31,7 +31,7 @@ gst_gl_effects_luma_to_curve (GstGLEffects * effects,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "lumamap0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "lumamap0", shader);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,57 +20,69 @@
|
|||
|
||||
#include <gstgleffects.h>
|
||||
|
||||
#define USING_OPENGL(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_OPENGL)
|
||||
#define USING_OPENGL3(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_OPENGL3)
|
||||
#define USING_GLES(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_GLES)
|
||||
#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)
|
||||
|
||||
static void
|
||||
gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
|
||||
gpointer data)
|
||||
{
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
|
||||
GstGLFilter *filter = GST_GL_FILTER (effects);
|
||||
GstGLShader *shader;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "mirror0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (filter->display);
|
||||
g_hash_table_insert (effects->shaderstable, "mirror0", shader);
|
||||
|
||||
#ifdef OPENGL_ES2
|
||||
if (shader) {
|
||||
GError *error = NULL;
|
||||
gst_gl_shader_set_vertex_source (shader, vertex_shader_source);
|
||||
gst_gl_shader_set_fragment_source (shader, mirror_fragment_source);
|
||||
#if HAVE_GLES2
|
||||
if (USING_GLES2 (filter->display)) {
|
||||
if (shader) {
|
||||
GError *error = NULL;
|
||||
gst_gl_shader_set_vertex_source (shader, vertex_shader_source);
|
||||
gst_gl_shader_set_fragment_source (shader,
|
||||
mirror_fragment_source_gles2);
|
||||
|
||||
gst_gl_shader_compile (shader, &error);
|
||||
if (error) {
|
||||
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
|
||||
"Failed to initialize mirror shader, %s", error->message);
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
gst_gl_shader_use (NULL);
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
|
||||
} else {
|
||||
effects->draw_attr_position_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_position");
|
||||
effects->draw_attr_texture_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_texCoord");
|
||||
gst_gl_shader_compile (shader, &error);
|
||||
if (error) {
|
||||
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
|
||||
"Failed to initialize mirror shader, %s", error->message);
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
gst_gl_shader_use (NULL);
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display),
|
||||
(NULL));
|
||||
} else {
|
||||
effects->draw_attr_position_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_position");
|
||||
effects->draw_attr_texture_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_texCoord");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifndef OPENGL_ES2
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
mirror_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
|
||||
"Failed to initialize mirror shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
|
||||
return;
|
||||
}
|
||||
#if HAVE_OPENGL
|
||||
if (USING_OPENGL (filter->display)) {
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
mirror_fragment_source_opengl, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
|
||||
"Failed to initialize mirror shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
gst_gl_shader_use (shader);
|
||||
|
||||
|
@ -80,9 +92,11 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
|
|||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
|
||||
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
|
||||
#if HAVE_OPENGL
|
||||
if (USING_OPENGL (filter->display)) {
|
||||
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
|
||||
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
|
||||
}
|
||||
#endif
|
||||
|
||||
gst_gl_effects_draw_texture (effects, texture, width, height);
|
||||
|
|
|
@ -31,7 +31,7 @@ gst_gl_effects_rgb_to_curve (GstGLEffects * effects,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "rgbmap0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "rgbmap0", shader);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ gst_gl_effects_sin_callback (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "sin0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "sin0", shader);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ gst_gl_effects_square_callback (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "square0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "square0", shader);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,57 +20,69 @@
|
|||
|
||||
#include <gstgleffects.h>
|
||||
|
||||
#define USING_OPENGL(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_OPENGL)
|
||||
#define USING_OPENGL3(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_OPENGL3)
|
||||
#define USING_GLES(display) (gst_gl_display_get_gl_api_unlocked (display) & GST_GL_API_GLES)
|
||||
#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)
|
||||
|
||||
static void
|
||||
gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
|
||||
gpointer data)
|
||||
{
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
|
||||
GstGLFilter *filter = GST_GL_FILTER (effects);
|
||||
GstGLShader *shader;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "squeeze0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (filter->display);
|
||||
g_hash_table_insert (effects->shaderstable, "squeeze0", shader);
|
||||
|
||||
#ifdef OPENGL_ES2
|
||||
if (shader) {
|
||||
GError *error = NULL;
|
||||
gst_gl_shader_set_vertex_source (shader, vertex_shader_source);
|
||||
gst_gl_shader_set_fragment_source (shader, squeeze_fragment_source);
|
||||
#if HAVE_GLES2
|
||||
if (USING_GLES2 (filter->display)) {
|
||||
if (shader) {
|
||||
GError *error = NULL;
|
||||
gst_gl_shader_set_vertex_source (shader, vertex_shader_source);
|
||||
gst_gl_shader_set_fragment_source (shader,
|
||||
squeeze_fragment_source_gles2);
|
||||
|
||||
gst_gl_shader_compile (shader, &error);
|
||||
if (error) {
|
||||
GstGLFilter *filter = GST_GL_FILTER (effects);
|
||||
gst_gl_display_set_error (filter->display,
|
||||
"Failed to initialize squeeze shader, %s", error->message);
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
gst_gl_shader_use (NULL);
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
|
||||
} else {
|
||||
effects->draw_attr_position_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_position");
|
||||
effects->draw_attr_texture_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_texCoord");
|
||||
gst_gl_shader_compile (shader, &error);
|
||||
if (error) {
|
||||
GstGLFilter *filter = GST_GL_FILTER (effects);
|
||||
gst_gl_display_set_error (filter->display,
|
||||
"Failed to initialize squeeze shader, %s", error->message);
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
gst_gl_shader_use (NULL);
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display),
|
||||
(NULL));
|
||||
} else {
|
||||
effects->draw_attr_position_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_position");
|
||||
effects->draw_attr_texture_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_texCoord");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifndef OPENGL_ES2
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
squeeze_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
|
||||
"Failed to initialize squeeze shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
|
||||
return;
|
||||
}
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
#if HAVE_OPENGL
|
||||
if (USING_OPENGL (filter->display)) {
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
squeeze_fragment_source_opengl, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (GST_GL_FILTER (effects)->display,
|
||||
"Failed to initialize squeeze shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
GST_GL_DISPLAY_ERR_MSG (GST_GL_FILTER (effects)->display), (NULL));
|
||||
return;
|
||||
}
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
gst_gl_shader_use (shader);
|
||||
|
||||
|
@ -80,9 +92,11 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
|
|||
|
||||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
|
||||
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
|
||||
#if HAVE_GLES2
|
||||
if (USING_GLES2 (filter->display)) {
|
||||
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
|
||||
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
|
||||
}
|
||||
#endif
|
||||
|
||||
gst_gl_effects_draw_texture (effects, texture, width, height);
|
||||
|
|
|
@ -80,18 +80,12 @@ const gchar *identity_fragment_source =
|
|||
"}";
|
||||
|
||||
/* Mirror effect */
|
||||
const gchar *mirror_fragment_source =
|
||||
#ifndef OPENGL_ES2
|
||||
#if HAVE_OPENGL
|
||||
const gchar *mirror_fragment_source_opengl =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform float width, height;"
|
||||
#else
|
||||
"precision mediump float;"
|
||||
"varying vec2 v_texCoord;"
|
||||
"uniform sampler2D tex;"
|
||||
#endif
|
||||
"void main () {"
|
||||
#ifndef OPENGL_ES2
|
||||
" vec2 tex_size = vec2 (width, height);"
|
||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||
" vec2 normcoord;"
|
||||
|
@ -100,29 +94,29 @@ const gchar *mirror_fragment_source =
|
|||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||
" gl_FragColor = color * gl_Color;"
|
||||
#else
|
||||
"}";
|
||||
#endif
|
||||
#if HAVE_GLES2
|
||||
const gchar *mirror_fragment_source_gles2 =
|
||||
"precision mediump float;"
|
||||
"varying vec2 v_texCoord;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec2 texturecoord = v_texCoord.xy;"
|
||||
" float normcoord = texturecoord.x - 0.5;"
|
||||
" normcoord *= sign (normcoord);"
|
||||
" texturecoord.x = (normcoord + 0.5);"
|
||||
" gl_FragColor = texture2D (tex, texturecoord);"
|
||||
#endif
|
||||
"}";
|
||||
|
||||
#endif
|
||||
|
||||
/* Squeeze effect */
|
||||
const gchar *squeeze_fragment_source =
|
||||
#ifndef OPENGL_ES2
|
||||
#if HAVE_OPENGL
|
||||
const gchar *squeeze_fragment_source_opengl =
|
||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||
"uniform sampler2DRect tex;"
|
||||
"uniform float width, height;"
|
||||
#else
|
||||
"precision mediump float;"
|
||||
"varying vec2 v_texCoord;"
|
||||
"uniform sampler2D tex;"
|
||||
#endif
|
||||
"void main () {"
|
||||
#ifndef OPENGL_ES2
|
||||
" vec2 tex_size = vec2 (width, height);"
|
||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||
" vec2 normcoord;"
|
||||
|
@ -133,7 +127,14 @@ const gchar *squeeze_fragment_source =
|
|||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||
" vec4 color = texture2DRect (tex, texturecoord); "
|
||||
" gl_FragColor = color * gl_Color;"
|
||||
#else
|
||||
"}";
|
||||
#endif
|
||||
#if HAVE_GLES2
|
||||
const gchar *squeeze_fragment_source_gles2 =
|
||||
"precision mediump float;"
|
||||
"varying vec2 v_texCoord;"
|
||||
"uniform sampler2D tex;"
|
||||
"void main () {"
|
||||
" vec2 texturecoord = v_texCoord.xy;"
|
||||
" vec2 normcoord = texturecoord - 0.5;"
|
||||
" float r = length (normcoord);"
|
||||
|
@ -141,9 +142,8 @@ const gchar *squeeze_fragment_source =
|
|||
" normcoord = normcoord / r;"
|
||||
" texturecoord = (normcoord + 0.5);"
|
||||
" gl_FragColor = texture2D (tex, texturecoord);"
|
||||
#endif
|
||||
"}";
|
||||
|
||||
#endif
|
||||
|
||||
/* Stretch Effect */
|
||||
const gchar *stretch_fragment_source =
|
||||
|
|
|
@ -21,10 +21,20 @@
|
|||
#ifndef __GST_GL_EFFECTS_SOURCES_H__
|
||||
#define __GST_GL_EFFECTS_SOURCES_H__
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
extern const gchar *vertex_shader_source;
|
||||
extern const gchar *identity_fragment_source;
|
||||
extern const gchar *mirror_fragment_source;
|
||||
extern const gchar *squeeze_fragment_source;
|
||||
#if HAVE_OPENGL
|
||||
extern const gchar *mirror_fragment_source_opengl;
|
||||
extern const gchar *squeeze_fragment_source_opengl;
|
||||
#endif
|
||||
#if HAVE_GLES2
|
||||
extern const gchar *mirror_fragment_source_gles2;
|
||||
extern const gchar *squeeze_fragment_source_gles2;
|
||||
#endif
|
||||
extern const gchar *stretch_fragment_source;
|
||||
extern const gchar *tunnel_fragment_source;
|
||||
extern const gchar *fisheye_fragment_source;
|
||||
|
|
|
@ -31,7 +31,7 @@ gst_gl_effects_stretch_callback (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "stretch0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "stretch0", shader);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ gst_gl_effects_tunnel_callback (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "tunnel0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "tunnel0", shader);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ gst_gl_effects_twirl_callback (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "twirl0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "twirl0", shader);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ gst_gl_effects_xray_step_two (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "xray1");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "xray1", shader);
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ gst_gl_effects_xray_step_three (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "xray2");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "xray2", shader);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ gst_gl_effects_xray_desaturate (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "xray_desat");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "xray_desat", shader);
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ gst_gl_effects_xray_sobel_hconv (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_hconv");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "xray_sob_hconv", shader);
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ gst_gl_effects_xray_sobel_vconv (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_vconv");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "xray_sob_vconv", shader);
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ gst_gl_effects_xray_sobel_length (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_len");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "xray_sob_len", shader);
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ gst_gl_effects_xray_step_five (gint width, gint height, guint texture,
|
|||
shader = g_hash_table_lookup (effects->shaderstable, "xray4");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new ();
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
g_hash_table_insert (effects->shaderstable, "xray4", shader);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
#include "gltestsrc.h"
|
||||
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
@ -85,135 +83,148 @@ gst_gl_test_src_unicolor (GstGLTestSrc * v, GstBuffer * buffer, int w,
|
|||
void
|
||||
gst_gl_test_src_smpte (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
|
||||
{
|
||||
#if HAVE_OPENGL
|
||||
int i;
|
||||
|
||||
glClearColor (0.0, 0.0, 0.0, 1.0);
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
if (gst_gl_display_get_gl_api_unlocked (v->display) & GST_GL_API_OPENGL) {
|
||||
|
||||
glDisable (GL_CULL_FACE);
|
||||
glDisable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glClearColor (0.0, 0.0, 0.0, 1.0);
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
glDisable (GL_CULL_FACE);
|
||||
glDisable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
|
||||
for (i = 0; i < 7; i++) {
|
||||
glColor4f (vts_colors[i].R * (1 / 255.0f), vts_colors[i].G * (1 / 255.0f),
|
||||
vts_colors[i].B * (1 / 255.0f), 1.0f);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex3f (-1.0f + i * (2.0f / 7.0f), -1.0f + 2.0 * (2.0f / 3.0f), 0);
|
||||
glVertex3f (-1.0f + (i + 1.0f) * (2.0f / 7.0f),
|
||||
-1.0f + 2.0f * (2.0f / 3.0f), 0);
|
||||
glVertex3f (-1.0f + (i + 1.0f) * (2.0f / 7.0f), -1.0f, 0);
|
||||
glVertex3f (-1.0f + i * (2.0f / 7.0f), -1.0f, 0);
|
||||
glEnd ();
|
||||
}
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
|
||||
for (i = 0; i < 7; i++) {
|
||||
int k;
|
||||
|
||||
if (i & 1) {
|
||||
k = 7;
|
||||
} else {
|
||||
k = 6 - i;
|
||||
for (i = 0; i < 7; i++) {
|
||||
glColor4f (vts_colors[i].R * (1 / 255.0f), vts_colors[i].G * (1 / 255.0f),
|
||||
vts_colors[i].B * (1 / 255.0f), 1.0f);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex3f (-1.0f + i * (2.0f / 7.0f), -1.0f + 2.0 * (2.0f / 3.0f), 0);
|
||||
glVertex3f (-1.0f + (i + 1.0f) * (2.0f / 7.0f),
|
||||
-1.0f + 2.0f * (2.0f / 3.0f), 0);
|
||||
glVertex3f (-1.0f + (i + 1.0f) * (2.0f / 7.0f), -1.0f, 0);
|
||||
glVertex3f (-1.0f + i * (2.0f / 7.0f), -1.0f, 0);
|
||||
glEnd ();
|
||||
}
|
||||
|
||||
glColor4f (vts_colors[k].R * (1 / 255.0f), vts_colors[k].G * (1 / 255.0f),
|
||||
vts_colors[k].B * (1 / 255.0f), 1.0f);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex3f (-1.0f + i * (2.0f / 7.0f), -1.0f + 2.0f * (3.0f / 4.0f), 0);
|
||||
glVertex3f (-1.0f + (i + 1) * (2.0f / 7.0f), -1.0f + 2.0f * (3.0f / 4.0f),
|
||||
0);
|
||||
glVertex3f (-1.0f + (i + 1) * (2.0f / 7.0f), -1.0f + 2.0f * (2.0f / 3.0f),
|
||||
0);
|
||||
glVertex3f (-1.0f + i * (2.0f / 7.0f), -1.0f + 2.0f * (2.0f / 3.0f), 0);
|
||||
glEnd ();
|
||||
}
|
||||
for (i = 0; i < 7; i++) {
|
||||
int k;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
int k;
|
||||
if (i & 1) {
|
||||
k = 7;
|
||||
} else {
|
||||
k = 6 - i;
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
k = 8;
|
||||
} else if (i == 1) {
|
||||
k = 0;
|
||||
} else {
|
||||
k = 9;
|
||||
glColor4f (vts_colors[k].R * (1 / 255.0f), vts_colors[k].G * (1 / 255.0f),
|
||||
vts_colors[k].B * (1 / 255.0f), 1.0f);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex3f (-1.0f + i * (2.0f / 7.0f), -1.0f + 2.0f * (3.0f / 4.0f), 0);
|
||||
glVertex3f (-1.0f + (i + 1) * (2.0f / 7.0f), -1.0f + 2.0f * (3.0f / 4.0f),
|
||||
0);
|
||||
glVertex3f (-1.0f + (i + 1) * (2.0f / 7.0f), -1.0f + 2.0f * (2.0f / 3.0f),
|
||||
0);
|
||||
glVertex3f (-1.0f + i * (2.0f / 7.0f), -1.0f + 2.0f * (2.0f / 3.0f), 0);
|
||||
glEnd ();
|
||||
}
|
||||
|
||||
glColor4f (vts_colors[k].R * (1 / 255.0f), vts_colors[k].G * (1 / 255.0f),
|
||||
vts_colors[k].B * (1 / 255.0f), 1.0f);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex3f (-1.0f + i * (2.0f / 6.0f), -1.0f + 2.0f * 1, 0);
|
||||
glVertex3f (-1.0f + (i + 1) * (2.0f / 6.0f), -1.0f + 2.0f * 1, 0);
|
||||
glVertex3f (-1.0f + (i + 1) * (2.0f / 6.0f), -1.0f + 2.0f * (3.0f / 4.0f),
|
||||
0);
|
||||
glVertex3f (-1.0f + i * (2.0f / 6.0f), -1.0f + 2.0f * (3.0f / 4.0f), 0);
|
||||
glEnd ();
|
||||
}
|
||||
for (i = 0; i < 3; i++) {
|
||||
int k;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
int k;
|
||||
if (i == 0) {
|
||||
k = 8;
|
||||
} else if (i == 1) {
|
||||
k = 0;
|
||||
} else {
|
||||
k = 9;
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
k = COLOR_SUPER_BLACK;
|
||||
} else if (i == 1) {
|
||||
k = COLOR_BLACK;
|
||||
} else {
|
||||
k = COLOR_DARK_GREY;
|
||||
glColor4f (vts_colors[k].R * (1 / 255.0f), vts_colors[k].G * (1 / 255.0f),
|
||||
vts_colors[k].B * (1 / 255.0f), 1.0f);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex3f (-1.0f + i * (2.0f / 6.0f), -1.0f + 2.0f * 1, 0);
|
||||
glVertex3f (-1.0f + (i + 1) * (2.0f / 6.0f), -1.0f + 2.0f * 1, 0);
|
||||
glVertex3f (-1.0f + (i + 1) * (2.0f / 6.0f), -1.0f + 2.0f * (3.0f / 4.0f),
|
||||
0);
|
||||
glVertex3f (-1.0f + i * (2.0f / 6.0f), -1.0f + 2.0f * (3.0f / 4.0f), 0);
|
||||
glEnd ();
|
||||
}
|
||||
|
||||
glColor4f (vts_colors[k].R * (1 / 255.0f), vts_colors[k].G * (1 / 255.0f),
|
||||
vts_colors[k].B * (1 / 255.0f), 1.0f);
|
||||
for (i = 0; i < 3; i++) {
|
||||
int k;
|
||||
|
||||
if (i == 0) {
|
||||
k = COLOR_SUPER_BLACK;
|
||||
} else if (i == 1) {
|
||||
k = COLOR_BLACK;
|
||||
} else {
|
||||
k = COLOR_DARK_GREY;
|
||||
}
|
||||
|
||||
glColor4f (vts_colors[k].R * (1 / 255.0f), vts_colors[k].G * (1 / 255.0f),
|
||||
vts_colors[k].B * (1 / 255.0f), 1.0f);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex3f (-1.0f + 2.0f * (0.5f + i * (1.0f / 12.0f)), -1.0 + 2.0f * 1,
|
||||
0);
|
||||
glVertex3f (-1.0f + 2.0f * (0.5f + (i + 1) * (1.0f / 12.0f)),
|
||||
-1.0f + 2.0f * 1, 0);
|
||||
glVertex3f (-1.0f + 2.0f * (0.5f + (i + 1) * (1.0f / 12.0f)),
|
||||
-1.0f + 2.0f * (3.0f / 4.0f), 0);
|
||||
glVertex3f (-1.0f + 2.0f * (0.5f + i * (1.0f / 12.0f)),
|
||||
-1.0f + 2.0f * (3.0f / 4.0f), 0);
|
||||
glEnd ();
|
||||
}
|
||||
|
||||
glColor4f (1.0, 1.0, 1.0, 1.0);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex3f (-1.0f + 2.0f * (0.5f + i * (1.0f / 12.0f)), -1.0 + 2.0f * 1, 0);
|
||||
glVertex3f (-1.0f + 2.0f * (0.5f + (i + 1) * (1.0f / 12.0f)),
|
||||
-1.0f + 2.0f * 1, 0);
|
||||
glVertex3f (-1.0f + 2.0f * (0.5f + (i + 1) * (1.0f / 12.0f)),
|
||||
-1.0f + 2.0f * (3.0f / 4.0f), 0);
|
||||
glVertex3f (-1.0f + 2.0f * (0.5f + i * (1.0f / 12.0f)),
|
||||
-1.0f + 2.0f * (3.0f / 4.0f), 0);
|
||||
glVertex3f (-1.0 + 2.0 * (0.75), -1.0 + 2.0 * 1, 0);
|
||||
glVertex3f (-1.0 + 2.0 * (1.0), -1.0 + 2.0 * 1, 0);
|
||||
glVertex3f (-1.0 + 2.0 * (1.0), -1.0 + 2.0 * (3.0 / 4.0), 0);
|
||||
glVertex3f (-1.0 + 2.0 * (0.75), -1.0 + 2.0 * (3.0 / 4.0), 0);
|
||||
glEnd ();
|
||||
}
|
||||
|
||||
glColor4f (1.0, 1.0, 1.0, 1.0);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex3f (-1.0 + 2.0 * (0.75), -1.0 + 2.0 * 1, 0);
|
||||
glVertex3f (-1.0 + 2.0 * (1.0), -1.0 + 2.0 * 1, 0);
|
||||
glVertex3f (-1.0 + 2.0 * (1.0), -1.0 + 2.0 * (3.0 / 4.0), 0);
|
||||
glVertex3f (-1.0 + 2.0 * (0.75), -1.0 + 2.0 * (3.0 / 4.0), 0);
|
||||
glEnd ();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_test_src_snow (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
|
||||
{
|
||||
glClearColor (0.0, 0.0, 0.0, 1.0);
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
#if HAVE_OPENGL
|
||||
if (gst_gl_display_get_gl_api_unlocked (v->display) & GST_GL_API_OPENGL) {
|
||||
glClearColor (0.0, 0.0, 0.0, 1.0);
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glLoadIdentity ();
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glLoadIdentity ();
|
||||
|
||||
/* FIXME snow requires a fragment shader. Please write. */
|
||||
glColor4f (0.5, 0.5, 0.5, 1.0);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex3f (-1.0 + 2.0 * (0.0), -1.0 + 2.0 * 1, 0);
|
||||
glVertex3f (-1.0 + 2.0 * (1.0), -1.0 + 2.0 * 1, 0);
|
||||
glVertex3f (-1.0 + 2.0 * (1.0), -1.0 + 2.0 * (0.0), 0);
|
||||
glVertex3f (-1.0 + 2.0 * (0.0), -1.0 + 2.0 * (0.0), 0);
|
||||
glEnd ();
|
||||
/* FIXME snow requires a fragment shader. Please write. */
|
||||
glColor4f (0.5, 0.5, 0.5, 1.0);
|
||||
glBegin (GL_QUADS);
|
||||
glVertex3f (-1.0 + 2.0 * (0.0), -1.0 + 2.0 * 1, 0);
|
||||
glVertex3f (-1.0 + 2.0 * (1.0), -1.0 + 2.0 * 1, 0);
|
||||
glVertex3f (-1.0 + 2.0 * (1.0), -1.0 + 2.0 * (0.0), 0);
|
||||
glVertex3f (-1.0 + 2.0 * (0.0), -1.0 + 2.0 * (0.0), 0);
|
||||
glEnd ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_test_src_unicolor (GstGLTestSrc * v, GstBuffer * buffer, int w,
|
||||
int h, const struct vts_color_struct *color)
|
||||
{
|
||||
glClearColor (color->R * (1 / 255.0f), color->G * (1 / 255.0f),
|
||||
color->B * (1 / 255.0f), 1.0f);
|
||||
glClear (GL_COLOR_BUFFER_BIT);
|
||||
#if HAVE_OPENGL
|
||||
if (gst_gl_display_get_gl_api_unlocked (v->display) & GST_GL_API_OPENGL) {
|
||||
glClearColor (color->R * (1 / 255.0f), color->G * (1 / 255.0f),
|
||||
color->B * (1 / 255.0f), 1.0f);
|
||||
glClear (GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -97,7 +97,7 @@ gst_gl_differencematte_init_gl_resources (GstGLFilter * filter)
|
|||
GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
differencematte->shader[i] = gst_gl_shader_new ();
|
||||
differencematte->shader[i] = gst_gl_shader_new (filter->display);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (differencematte->shader[0],
|
||||
|
|
|
@ -97,7 +97,7 @@ gst_gl_effects_effect_get_type (void)
|
|||
{GST_GL_EFFECT_IDENTITY, "Do nothing Effect", "identity"},
|
||||
{GST_GL_EFFECT_MIRROR, "Mirror Effect", "mirror"},
|
||||
{GST_GL_EFFECT_SQUEEZE, "Squeeze Effect", "squeeze"},
|
||||
#ifndef OPENGL_ES2
|
||||
#if HAVE_OPENGL
|
||||
{GST_GL_EFFECT_STRETCH, "Stretch Effect", "stretch"},
|
||||
{GST_GL_EFFECT_FISHEYE, "FishEye Effect", "fisheye"},
|
||||
{GST_GL_EFFECT_TWIRL, "Twirl Effect", "twirl"},
|
||||
|
@ -136,7 +136,7 @@ gst_gl_effects_set_effect (GstGLEffects * effects, gint effect_type)
|
|||
case GST_GL_EFFECT_SQUEEZE:
|
||||
effects->effect = (GstGLEffectProcessFunc) gst_gl_effects_squeeze;
|
||||
break;
|
||||
#ifndef OPENGL_ES2
|
||||
#if HAVE_OPENGL
|
||||
case GST_GL_EFFECT_STRETCH:
|
||||
effects->effect = (GstGLEffectProcessFunc) gst_gl_effects_stretch;
|
||||
break;
|
||||
|
@ -270,83 +270,84 @@ void
|
|||
gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex, guint width,
|
||||
guint height)
|
||||
{
|
||||
#ifndef OPENGL_ES2
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, tex);
|
||||
#if HAVE_OPENGL
|
||||
if (gst_gl_display_get_gl_api_unlocked (GST_GL_FILTER (effects)->display) &
|
||||
GST_GL_API_OPENGL) {
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, tex);
|
||||
|
||||
glBegin (GL_QUADS);
|
||||
glBegin (GL_QUADS);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
glEnd ();
|
||||
#else
|
||||
glEnd ();
|
||||
}
|
||||
#endif
|
||||
#if HAVE_GLES2
|
||||
if (gst_gl_display_get_gl_api_unlocked (GST_GL_FILTER (effects)->display) &
|
||||
GST_GL_API_GLES2)
|
||||
) {
|
||||
const GLfloat vVertices[] = {
|
||||
-1.0f, -1.0f, 0.0f,
|
||||
0.0f, 0.0f,
|
||||
1.0, -1.0f, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
||||
const GLfloat vVertices[] = { -1.0f, -1.0f, 0.0f,
|
||||
0.0f, 0.0f,
|
||||
1.0, -1.0f, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, 1.0f, 0.0f,
|
||||
1.0f, 1.0f,
|
||||
-1.0f, 1.0f, 0.0f,
|
||||
0.0f, 1.0f
|
||||
};
|
||||
GLushort indices[] = {
|
||||
0, 1, 2, 0, 2, 3};
|
||||
|
||||
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
|
||||
/* glClear (GL_COLOR_BUFFER_BIT); */
|
||||
|
||||
//glClear (GL_COLOR_BUFFER_BIT);
|
||||
/* Load the vertex position */
|
||||
glVertexAttribPointer (effects->draw_attr_position_loc, 3, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof (GLfloat), vVertices);
|
||||
|
||||
//Load the vertex position
|
||||
glVertexAttribPointer (effects->draw_attr_position_loc, 3, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof (GLfloat), vVertices);
|
||||
/* Load the texture coordinate */
|
||||
glVertexAttribPointer (effects->draw_attr_texture_loc, 2, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
|
||||
|
||||
//Load the texture coordinate
|
||||
glVertexAttribPointer (effects->draw_attr_texture_loc, 2, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
|
||||
glEnableVertexAttribArray (effects->draw_attr_position_loc);
|
||||
glEnableVertexAttribArray (effects->draw_attr_texture_loc);
|
||||
|
||||
glEnableVertexAttribArray (effects->draw_attr_position_loc);
|
||||
glEnableVertexAttribArray (effects->draw_attr_texture_loc);
|
||||
|
||||
glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
|
||||
glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
|
||||
}
|
||||
#endif
|
||||
|
||||
glUseProgramObjectARB (0);
|
||||
}
|
||||
|
||||
static void
|
||||
set_horizontal_swap (GstGLDisplay * display, gpointer data)
|
||||
static void set_horizontal_swap (GstGLDisplay * display, gpointer data)
|
||||
{
|
||||
// GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
const double mirrormatrix[16] = {
|
||||
#if HAVE_OPENGL
|
||||
if (USING_OPENGL (display)) {
|
||||
const double mirrormatrix[16] = {
|
||||
-1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0
|
||||
};
|
||||
0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0};
|
||||
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glLoadMatrixd (mirrormatrix);
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glLoadMatrixd (mirrormatrix);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_effects_init (GstGLEffects * effects)
|
||||
static void gst_gl_effects_init (GstGLEffects * effects)
|
||||
{
|
||||
effects->effect = gst_gl_effects_identity;
|
||||
effects->horizontal_swap = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_effects_ghash_func_clean (gpointer key, gpointer value, gpointer data)
|
||||
gst_gl_effects_ghash_func_clean (gpointer key, gpointer value,
|
||||
gpointer data)
|
||||
{
|
||||
GstGLShader *shader = (GstGLShader *) value;
|
||||
GstGLFilter *filter = (GstGLFilter *) data;
|
||||
|
@ -357,26 +358,23 @@ gst_gl_effects_ghash_func_clean (gpointer key, gpointer value, gpointer data)
|
|||
value = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_effects_reset_resources (GstGLFilter * filter)
|
||||
static void gst_gl_effects_reset_resources (GstGLFilter * filter)
|
||||
{
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (filter);
|
||||
|
||||
// g_message ("reset resources");
|
||||
|
||||
//release shaders in the gl thread
|
||||
/* release shaders in the gl thread */
|
||||
g_hash_table_foreach (effects->shaderstable, gst_gl_effects_ghash_func_clean,
|
||||
filter);
|
||||
|
||||
//clean the htable without calling values destructors
|
||||
//because shaders have been released in the glthread
|
||||
//through the foreach func
|
||||
/* clean the htable without calling values destructors
|
||||
* because shaders have been released in the glthread
|
||||
* through the foreach func */
|
||||
g_hash_table_unref (effects->shaderstable);
|
||||
effects->shaderstable = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_effects_set_property (GObject * object, guint prop_id,
|
||||
gst_gl_effects_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (object);
|
||||
|
@ -385,17 +383,15 @@ gst_gl_effects_set_property (GObject * object, guint prop_id,
|
|||
case PROP_EFFECT:
|
||||
gst_gl_effects_set_effect (effects, g_value_get_enum (value));
|
||||
break;
|
||||
case PROP_HSWAP:
|
||||
effects->horizontal_swap = g_value_get_boolean (value);
|
||||
case PROP_HSWAP:effects->horizontal_swap = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
default:G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_effects_get_property (GObject * object, guint prop_id,
|
||||
gst_gl_effects_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (object);
|
||||
|
@ -413,15 +409,13 @@ gst_gl_effects_get_property (GObject * object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_effects_init_resources (GstGLFilter * filter)
|
||||
static void gst_gl_effects_init_resources (GstGLFilter * filter)
|
||||
{
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (filter);
|
||||
gint i;
|
||||
// g_message ("init resources");
|
||||
// g_message ("init hashtable");
|
||||
|
||||
effects->shaderstable = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
// g_message ("zero textures and curves");
|
||||
|
||||
for (i = 0; i < NEEDED_TEXTURES; i++) {
|
||||
effects->midtexture[i] = 0;
|
||||
}
|
||||
|
@ -430,16 +424,15 @@ gst_gl_effects_init_resources (GstGLFilter * filter)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_effects_on_init_gl_context (GstGLFilter * filter)
|
||||
static gboolean gst_gl_effects_on_init_gl_context (GstGLFilter * filter)
|
||||
{
|
||||
//check that your hardware supports shader
|
||||
//if not the pipeline correctly shut down
|
||||
/* check that your hardware supports shader
|
||||
* if not the pipeline correctly shut down */
|
||||
return gst_gl_display_gen_shader (filter->display, 0, 0, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_effects_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
gst_gl_effects_filter_texture (GstGLFilter * filter, guint in_tex,
|
||||
guint out_tex)
|
||||
{
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (filter);
|
||||
|
|
|
@ -71,7 +71,7 @@ struct _GstGLEffects
|
|||
|
||||
gboolean horizontal_swap; /* switch left to right */
|
||||
|
||||
#ifdef OPENGL_ES2
|
||||
#if HAVE_GLES2
|
||||
GLint draw_attr_position_loc;
|
||||
GLint draw_attr_texture_loc;
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gst/gl/gstglapi.h>
|
||||
#include "gstglfiltercube.h"
|
||||
|
||||
#define GST_CAT_DEFAULT gst_gl_filter_cube_debug
|
||||
|
@ -74,17 +75,21 @@ static void gst_gl_filter_cube_get_property (GObject * object, guint prop_id,
|
|||
|
||||
static gboolean gst_gl_filter_cube_set_caps (GstGLFilter * filter,
|
||||
GstCaps * incaps, GstCaps * outcaps);
|
||||
#ifdef OPENGL_ES2
|
||||
#if HAVE_GLES2
|
||||
static void gst_gl_filter_cube_reset (GstGLFilter * filter);
|
||||
static gboolean gst_gl_filter_cube_init_shader (GstGLFilter * filter);
|
||||
static void _callback_gles2 (gint width, gint height, guint texture,
|
||||
gpointer stuff);
|
||||
#endif
|
||||
#if HAVE_OPENGL
|
||||
static void _callback_opengl (gint width, gint height, guint texture,
|
||||
gpointer stuff);
|
||||
#endif
|
||||
static gboolean gst_gl_filter_cube_filter_texture (GstGLFilter * filter,
|
||||
guint in_tex, guint out_tex);
|
||||
static void gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
||||
gpointer stuff);
|
||||
|
||||
#ifdef OPENGL_ES2
|
||||
//vertex source
|
||||
#if HAVE_GLES2
|
||||
/* vertex source */
|
||||
static const gchar *cube_v_src =
|
||||
"attribute vec4 a_position; \n"
|
||||
"attribute vec2 a_texCoord; \n"
|
||||
|
@ -116,7 +121,7 @@ static const gchar *cube_v_src =
|
|||
" v_texCoord = a_texCoord; \n"
|
||||
"} \n";
|
||||
|
||||
//fragment source
|
||||
/* fragment source */
|
||||
static const gchar *cube_f_src =
|
||||
"precision mediump float; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
|
@ -139,7 +144,7 @@ gst_gl_filter_cube_class_init (GstGLFilterCubeClass * klass)
|
|||
gobject_class->set_property = gst_gl_filter_cube_set_property;
|
||||
gobject_class->get_property = gst_gl_filter_cube_get_property;
|
||||
|
||||
#ifdef OPENGL_ES2
|
||||
#if HAVE_GLES2
|
||||
GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filter_cube_init_shader;
|
||||
GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_cube_reset;
|
||||
#endif
|
||||
|
@ -186,9 +191,7 @@ gst_gl_filter_cube_class_init (GstGLFilterCubeClass * klass)
|
|||
static void
|
||||
gst_gl_filter_cube_init (GstGLFilterCube * filter)
|
||||
{
|
||||
#ifdef OPENGL_ES
|
||||
filter->shader = NULL;
|
||||
#endif
|
||||
filter->fovy = 45;
|
||||
filter->aspect = 0;
|
||||
filter->znear = 0.1;
|
||||
|
@ -233,8 +236,6 @@ static void
|
|||
gst_gl_filter_cube_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
//GstGLFilterCube* filter = GST_GL_FILTER_CUBE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -255,14 +256,15 @@ gst_gl_filter_cube_set_caps (GstGLFilter * filter, GstCaps * incaps,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef OPENGL_ES2
|
||||
#if HAVE_GLES2
|
||||
static void
|
||||
gst_gl_filter_cube_reset (GstGLFilter * filter)
|
||||
{
|
||||
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
|
||||
|
||||
//blocking call, wait the opengl thread has destroyed the shader
|
||||
gst_gl_display_del_shader (filter->display, cube_filter->shader);
|
||||
/* blocking call, wait the opengl thread has destroyed the shader */
|
||||
if (cube_filter->shader)
|
||||
gst_gl_display_del_shader (filter->display, cube_filter->shader);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -270,9 +272,12 @@ gst_gl_filter_cube_init_shader (GstGLFilter * filter)
|
|||
{
|
||||
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
|
||||
|
||||
//blocking call, wait the opengl thread has compiled the shader
|
||||
return gst_gl_display_gen_shader (filter->display, cube_v_src, cube_f_src,
|
||||
&cube_filter->shader);
|
||||
if (gst_gl_display_get_gl_api (filter->display) & GST_GL_API_GLES2) {
|
||||
/* blocking call, wait the opengl thread has compiled the shader */
|
||||
return gst_gl_display_gen_shader (filter->display, cube_v_src, cube_f_src,
|
||||
&cube_filter->shader);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -281,13 +286,27 @@ gst_gl_filter_cube_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
guint out_tex)
|
||||
{
|
||||
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
|
||||
GLCB cb = NULL;
|
||||
GstGLAPI api;
|
||||
|
||||
//blocking call, use a FBO
|
||||
api =
|
||||
gst_gl_display_get_gl_api_unlocked (GST_GL_FILTER (cube_filter)->display);
|
||||
|
||||
#if HAVE_OPENGL
|
||||
if (api & GST_GL_API_OPENGL)
|
||||
cb = _callback_opengl;
|
||||
#endif
|
||||
#if HAVE_GLES2
|
||||
if (api & GST_GL_API_GLES2)
|
||||
cb = _callback_gles2;
|
||||
#endif
|
||||
|
||||
/* blocking call, use a FBO */
|
||||
gst_gl_display_use_fbo (filter->display,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
filter->fbo, filter->depthbuffer, out_tex,
|
||||
gst_gl_filter_cube_callback,
|
||||
cb,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->in_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->in_info),
|
||||
in_tex, cube_filter->fovy, cube_filter->aspect,
|
||||
|
@ -297,10 +316,10 @@ gst_gl_filter_cube_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
//opengl scene, params: input texture (not the output filter->texture)
|
||||
/* opengl scene, params: input texture (not the output filter->texture) */
|
||||
#if HAVE_OPENGL
|
||||
static void
|
||||
gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
||||
gpointer stuff)
|
||||
_callback_opengl (gint width, gint height, guint texture, gpointer stuff)
|
||||
{
|
||||
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (stuff);
|
||||
|
||||
|
@ -308,7 +327,6 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
static GLfloat yrot = 0;
|
||||
static GLfloat zrot = 0;
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
|
@ -319,9 +337,7 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
#ifndef OPENGL_ES2
|
||||
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
#endif
|
||||
|
||||
glClearColor (cube_filter->red, cube_filter->green, cube_filter->blue, 0.0);
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
@ -336,7 +352,7 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
glRotatef (zrot, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
glBegin (GL_QUADS);
|
||||
// Front Face
|
||||
/* Front Face */
|
||||
glTexCoord2f ((gfloat) width, 0.0f);
|
||||
glVertex3f (-1.0f, -1.0f, 1.0f);
|
||||
glTexCoord2f (0.0f, 0.0f);
|
||||
|
@ -345,7 +361,7 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
glVertex3f (1.0f, 1.0f, 1.0f);
|
||||
glTexCoord2f ((gfloat) width, (gfloat) height);
|
||||
glVertex3f (-1.0f, 1.0f, 1.0f);
|
||||
// Back Face
|
||||
/* Back Face */
|
||||
glTexCoord2f (0.0f, 0.0f);
|
||||
glVertex3f (-1.0f, -1.0f, -1.0f);
|
||||
glTexCoord2f (0.0f, (gfloat) height);
|
||||
|
@ -354,7 +370,7 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
glVertex3f (1.0f, 1.0f, -1.0f);
|
||||
glTexCoord2f ((gfloat) width, 0.0f);
|
||||
glVertex3f (1.0f, -1.0f, -1.0f);
|
||||
// Top Face
|
||||
/* Top Face */
|
||||
glTexCoord2f ((gfloat) width, (gfloat) height);
|
||||
glVertex3f (-1.0f, 1.0f, -1.0f);
|
||||
glTexCoord2f ((gfloat) width, 0.0f);
|
||||
|
@ -363,7 +379,7 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
glVertex3f (1.0f, 1.0f, 1.0f);
|
||||
glTexCoord2f (0.0f, (gfloat) height);
|
||||
glVertex3f (1.0f, 1.0f, -1.0f);
|
||||
// Bottom Face
|
||||
/* Bottom Face */
|
||||
glTexCoord2f ((gfloat) width, 0.0f);
|
||||
glVertex3f (-1.0f, -1.0f, -1.0f);
|
||||
glTexCoord2f (0.0f, 0.0f);
|
||||
|
@ -372,7 +388,7 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
glVertex3f (1.0f, -1.0f, 1.0f);
|
||||
glTexCoord2f ((gfloat) width, (gfloat) height);
|
||||
glVertex3f (-1.0f, -1.0f, 1.0f);
|
||||
// Right face
|
||||
/* Right face */
|
||||
glTexCoord2f (0.0f, 0.0f);
|
||||
glVertex3f (1.0f, -1.0f, -1.0f);
|
||||
glTexCoord2f (0.0f, (gfloat) height);
|
||||
|
@ -381,7 +397,7 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
glVertex3f (1.0f, 1.0f, 1.0f);
|
||||
glTexCoord2f ((gfloat) width, 0.0f);
|
||||
glVertex3f (1.0f, -1.0f, 1.0f);
|
||||
// Left Face
|
||||
/* Left Face */
|
||||
glTexCoord2f ((gfloat) width, 0.0f);
|
||||
glVertex3f (-1.0f, -1.0f, -1.0f);
|
||||
glTexCoord2f (0.0f, 0.0f);
|
||||
|
@ -391,10 +407,28 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
glTexCoord2f ((gfloat) width, (gfloat) height);
|
||||
glVertex3f (-1.0f, 1.0f, -1.0f);
|
||||
glEnd ();
|
||||
#else
|
||||
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
|
||||
xrot += 0.3f;
|
||||
yrot += 0.2f;
|
||||
zrot += 0.4f;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_GLES2
|
||||
static void
|
||||
_callback_gles2 (gint width, gint height, guint texture, gpointer stuff)
|
||||
{
|
||||
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (stuff);
|
||||
|
||||
static GLfloat xrot = 0;
|
||||
static GLfloat yrot = 0;
|
||||
static GLfloat zrot = 0;
|
||||
|
||||
const GLfloat v_vertices[] = {
|
||||
|
||||
//front face
|
||||
/* front face */
|
||||
1.0f, 1.0f, -1.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
|
@ -403,7 +437,7 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
0.0f, 1.0f,
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
0.0f, 0.0f,
|
||||
//back face
|
||||
/* back face */
|
||||
1.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
-1.0f, 1.0f, 1.0f,
|
||||
|
@ -412,7 +446,7 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
0.0f, 1.0f,
|
||||
1.0f, -1.0f, 1.0f,
|
||||
1.0f, 1.0f,
|
||||
//right face
|
||||
/* right face */
|
||||
1.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, -1.0f, 1.0f,
|
||||
|
@ -421,7 +455,7 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
0.0f, 1.0f,
|
||||
1.0f, 1.0f, -1.0f,
|
||||
1.0f, 1.0f,
|
||||
//left face
|
||||
/* left face */
|
||||
-1.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
|
@ -430,7 +464,7 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
0.0f, 1.0f,
|
||||
-1.0f, -1.0f, 1.0f,
|
||||
0.0f, 0.0f,
|
||||
//top face
|
||||
/* top face */
|
||||
1.0f, -1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
-1.0f, -1.0f, 1.0f,
|
||||
|
@ -439,7 +473,7 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
0.0f, 1.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
1.0f, 1.0f,
|
||||
//bottom face
|
||||
/* bottom face */
|
||||
1.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
1.0f, 1.0f, -1.0f,
|
||||
|
@ -487,11 +521,11 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
attr_texture_loc =
|
||||
gst_gl_shader_get_attribute_location (cube_filter->shader, "a_texCoord");
|
||||
|
||||
//Load the vertex position
|
||||
/* Load the vertex position */
|
||||
glVertexAttribPointer (attr_position_loc, 3, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof (GLfloat), v_vertices);
|
||||
|
||||
//Load the texture coordinate
|
||||
/* Load the texture coordinate */
|
||||
glVertexAttribPointer (attr_texture_loc, 2, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof (GLfloat), &v_vertices[3]);
|
||||
|
||||
|
@ -511,7 +545,6 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
|
||||
glDisableVertexAttribArray (attr_position_loc);
|
||||
glDisableVertexAttribArray (attr_texture_loc);
|
||||
#endif
|
||||
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
|
||||
|
@ -519,3 +552,4 @@ gst_gl_filter_cube_callback (gint width, gint height, guint texture,
|
|||
yrot += 0.2f;
|
||||
zrot += 0.4f;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -39,16 +39,14 @@ struct _GstGLFilterCube
|
|||
{
|
||||
GstGLFilter filter;
|
||||
|
||||
#ifdef OPENGL_ES2
|
||||
GstGLShader *shader;
|
||||
#endif
|
||||
|
||||
//background color
|
||||
/* background color */
|
||||
gfloat red;
|
||||
gfloat green;
|
||||
gfloat blue;
|
||||
|
||||
//perspective
|
||||
/* perspective */
|
||||
gdouble fovy;
|
||||
gdouble aspect;
|
||||
gdouble znear;
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
GType gst_gl_filter_cube_get_type (void);
|
||||
GType gst_gl_effects_get_type (void);
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
#if HAVE_OPENGL
|
||||
#include "gstgltestsrc.h"
|
||||
#include "gstglfilterlaplacian.h"
|
||||
#include "gstglfilterglass.h"
|
||||
|
@ -72,21 +72,21 @@ GType gst_gl_filter_laplacian_get_type (void);
|
|||
GType gst_gl_filter_glass_get_type (void);
|
||||
GType gst_gl_mosaic_get_type (void);
|
||||
|
||||
#ifdef HAVE_PNG
|
||||
#if HAVE_PNG
|
||||
#include "gstgldifferencematte.h"
|
||||
#include "gstglbumper.h"
|
||||
|
||||
GType gst_gl_differencematte_get_type (void);
|
||||
GType gst_gl_bumper_get_type (void);
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
#if HAVE_JPEG
|
||||
#include "gstgloverlay.h"
|
||||
|
||||
GType gst_gl_overlay_get_type (void);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif /* HAVE_JPEG */
|
||||
#endif /* HAVE_PNG */
|
||||
#endif /* HAVE_OPENGL */
|
||||
|
||||
#define GST_CAT_DEFAULT gst_gl_gstgl_debug
|
||||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
||||
|
@ -111,7 +111,7 @@ plugin_init (GstPlugin * plugin)
|
|||
GST_RANK_NONE, gst_gl_effects_get_type ())) {
|
||||
return FALSE;
|
||||
}
|
||||
#ifndef OPENGL_ES2
|
||||
#if HAVE_OPENGL
|
||||
if (!gst_element_register (plugin, "gltestsrc",
|
||||
GST_RANK_NONE, GST_TYPE_GL_TEST_SRC)) {
|
||||
return FALSE;
|
||||
|
@ -166,7 +166,7 @@ plugin_init (GstPlugin * plugin)
|
|||
GST_RANK_NONE, GST_TYPE_GL_MOSAIC)) {
|
||||
return FALSE;
|
||||
}
|
||||
#ifdef HAVE_PNG
|
||||
#if HAVE_PNG
|
||||
if (!gst_element_register (plugin, "gldifferencematte",
|
||||
GST_RANK_NONE, gst_gl_differencematte_get_type ())) {
|
||||
return FALSE;
|
||||
|
@ -176,14 +176,14 @@ plugin_init (GstPlugin * plugin)
|
|||
GST_RANK_NONE, gst_gl_bumper_get_type ())) {
|
||||
return FALSE;
|
||||
}
|
||||
#ifdef HAVE_JPEG
|
||||
#if HAVE_JPEG
|
||||
if (!gst_element_register (plugin, "gloverlay",
|
||||
GST_RANK_NONE, gst_gl_overlay_get_type ())) {
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif /* HAVE_JPEG */
|
||||
#endif /* HAVE_PNG */
|
||||
#endif /* HAVE_OPENGL */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ GST_START_TEST (test_gleffects)
|
|||
|
||||
GST_END_TEST
|
||||
#undef N_EFFECTS
|
||||
#ifndef OPENGL_ES2
|
||||
#if HAVE_OPENGL
|
||||
#define N_SRCS 13
|
||||
GST_START_TEST (test_gltestsrc)
|
||||
{
|
||||
|
@ -311,7 +311,7 @@ GST_START_TEST (test_glfilterapp)
|
|||
|
||||
GST_END_TEST
|
||||
#endif /* 0 */
|
||||
#endif /* !OPENGL_ES2 */
|
||||
#endif /* HAVE_OPENGL */
|
||||
#endif /* !GST_DISABLE_PARSE */
|
||||
Suite * simple_launch_lines_suite (void)
|
||||
{
|
||||
|
@ -326,7 +326,7 @@ GST_END_TEST
|
|||
tcase_add_test (tc_chain, test_glimagesink);
|
||||
tcase_add_test (tc_chain, test_glfiltercube);
|
||||
tcase_add_test (tc_chain, test_gleffects);
|
||||
#ifndef OPENGL_ES2
|
||||
#if HAVE_OPENGL
|
||||
tcase_add_test (tc_chain, test_gltestsrc);
|
||||
tcase_add_test (tc_chain, test_glfilterblur);
|
||||
tcase_add_test (tc_chain, test_glfiltersobel);
|
||||
|
@ -345,7 +345,7 @@ GST_END_TEST
|
|||
#endif /* HAVE_JPEG */
|
||||
#endif /* HAVE_PNG */
|
||||
#endif
|
||||
#endif /* !OPENGL_ES2 */
|
||||
#endif /* HAVE_OPENGL */
|
||||
#endif /* !GST_DISABLE_PARSE */
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue