mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 19:20:35 +00:00
[471/906] glshader: add dynamic fragment shader filter
Also add fragment shader parser Fix bug #600195
This commit is contained in:
parent
f008fa71ab
commit
500210b354
8 changed files with 1911 additions and 1 deletions
|
@ -24,6 +24,7 @@ add_library (gstgl STATIC
|
|||
gstglbuffer.c
|
||||
gstglfilter.c
|
||||
gstglmixer.c
|
||||
gstglshadervariables.c
|
||||
gstglshader.c)
|
||||
|
||||
target_link_libraries(gstgl
|
||||
|
@ -47,6 +48,7 @@ else (WIN32)
|
|||
gstglbuffer.c
|
||||
gstglfilter.c
|
||||
gstglmixer.c
|
||||
gstglshadervariables.c
|
||||
gstglshader.c)
|
||||
|
||||
target_link_libraries(gstgl
|
||||
|
@ -70,6 +72,7 @@ else (WIN32)
|
|||
gstglbuffer.c
|
||||
gstglfilter.c
|
||||
gstglmixer.c
|
||||
gstglshadervariables.c
|
||||
gstglshader.c)
|
||||
|
||||
target_link_libraries(gstgl
|
||||
|
|
|
@ -7,6 +7,7 @@ gstlibsgstgl_C_FILES = \
|
|||
gstglbuffer.c \
|
||||
gstglfilter.c \
|
||||
gstglmixer.c \
|
||||
gstglshadervariables.c \
|
||||
gstglshader.c
|
||||
|
||||
gstlibsgstgl_OBJC_FILES = gstglwindow_cocoa.m
|
||||
|
|
|
@ -13,7 +13,8 @@ libgstgl_@GST_MAJORMINOR@_la_SOURCES = \
|
|||
gstglbuffer.c \
|
||||
gstglfilter.c \
|
||||
gstglmixer.c \
|
||||
gstglshader.c
|
||||
gstglshader.c \
|
||||
gstglshadervariables.c
|
||||
|
||||
if GL_BACKEND_WIN32
|
||||
libgstgl_@GST_MAJORMINOR@_la_SOURCES += gstglwindow_win32.c
|
||||
|
@ -37,6 +38,7 @@ libgstgl_@GST_MAJORMINOR@include_HEADERS = \
|
|||
gstglfilter.h \
|
||||
gstglmixer.h \
|
||||
gstglmixerpad.h \
|
||||
gstglshadervariables.h \
|
||||
gstglshader.h
|
||||
|
||||
libgstgl_@GST_MAJORMINOR@_la_LIBADD = \
|
||||
|
|
|
@ -94,7 +94,28 @@ G_BEGIN_DECLS
|
|||
#define glUniform1fARB glUniform1f
|
||||
#define glUniform1fvARB glUniform1fv
|
||||
#define glUniform1iARB glUniform1i
|
||||
#define glUniform1ivARB glUniform1iv
|
||||
#define glUniform2fARB glUniform2f
|
||||
#define glUniform2fvARB glUniform2fv
|
||||
#define glUniform2iARB glUniform2i
|
||||
#define glUniform2ivARB glUniform2iv
|
||||
#define glUniform3fARB glUniform3f
|
||||
#define glUniform3fvARB glUniform3fv
|
||||
#define glUniform3iARB glUniform3i
|
||||
#define glUniform3ivARB glUniform3iv
|
||||
#define glUniform4fARB glUniform4f
|
||||
#define glUniform4fvARB glUniform4fv
|
||||
#define glUniform4iARB glUniform4i
|
||||
#define glUniform4ivARB glUniform4iv
|
||||
#define glUniformMatrix2fvARB glUniformMatrix2fv
|
||||
#define glUniformMatrix3fvARB glUniformMatrix3fv
|
||||
#define glUniformMatrix4fvARB glUniformMatrix4fv
|
||||
#define glUniformMatrix2x3fvARB glUniformMatrix2x3fv
|
||||
#define glUniformMatrix2x4fvARB glUniformMatrix2x4fv
|
||||
#define glUniformMatrix3x2fvARB glUniformMatrix3x2fv
|
||||
#define glUniformMatrix3x3fvARB glUniformMatrix3x4fv
|
||||
#define glUniformMatrix4x2fvARB glUniformMatrix4x2fv
|
||||
#define glUniformMatrix4x3fvARB glUniformMatrix4x3fv
|
||||
#define glGetUniformLocationARB glGetUniformLocation
|
||||
#define glGetAttribLocationARB glGetAttribLocation
|
||||
#define glBindAttribLocationARB glBindAttribLocation
|
||||
|
|
|
@ -518,6 +518,314 @@ gst_gl_shader_set_uniform_1i (GstGLShader * shader, const gchar * name,
|
|||
glUniform1iARB (location, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_1iv (GstGLShader * shader, const gchar * name,
|
||||
guint count, gint * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform1ivARB (location, count, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_2f (GstGLShader * shader, const gchar * name,
|
||||
gfloat value0, gfloat value1)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform2fARB (location, value0, value1);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_2fv (GstGLShader * shader, const gchar * name,
|
||||
guint count, gfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform2fvARB (location, count, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_2i (GstGLShader * shader, const gchar * name,
|
||||
gint v0, gint v1)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform2iARB (location, v0, v1);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_2iv (GstGLShader * shader, const gchar * name,
|
||||
guint count, gint * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform2ivARB (location, count, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_3f (GstGLShader * shader, const gchar * name,
|
||||
gfloat v0, gfloat v1, gfloat v2)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform3fARB (location, v0, v1, v2);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_3fv (GstGLShader * shader, const gchar * name,
|
||||
guint count, gfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform3fvARB (location, count, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_3i (GstGLShader * shader, const gchar * name,
|
||||
gint v0, gint v1, gint v2)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform3iARB (location, v0, v1, v2);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_3iv (GstGLShader * shader, const gchar * name,
|
||||
guint count, gint * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform3ivARB (location, count, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_4f (GstGLShader * shader, const gchar * name,
|
||||
gfloat v0, gfloat v1, gfloat v2, gfloat v3)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform4fARB (location, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_4fv (GstGLShader * shader, const gchar * name,
|
||||
guint count, gfloat * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform4fvARB (location, count, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_4i (GstGLShader * shader, const gchar * name,
|
||||
gint v0, gint v1, gint v2, gint v3)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform4iARB (location, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_4iv (GstGLShader * shader, const gchar * name,
|
||||
guint count, gint * value)
|
||||
{
|
||||
GstGLShaderPrivate *priv;
|
||||
GLint location = -1;
|
||||
|
||||
priv = shader->priv;
|
||||
|
||||
g_return_if_fail (priv->program_handle != 0);
|
||||
|
||||
location = glGetUniformLocationARB (priv->program_handle, name);
|
||||
|
||||
glUniform4ivARB (location, count, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_2fv (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);
|
||||
|
||||
glUniformMatrix2fvARB (location, count, transpose, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_2x3fv (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);
|
||||
|
||||
glUniformMatrix2x3fv (location, count, transpose, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_2x4fv (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);
|
||||
|
||||
glUniformMatrix2x4fv (location, count, transpose, value);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_3x2fv (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);
|
||||
|
||||
glUniformMatrix3x2fv (location, count, transpose, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_3x4fv (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);
|
||||
|
||||
glUniformMatrix3x4fv (location, count, transpose, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_4fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat * value)
|
||||
|
@ -534,6 +842,40 @@ gst_gl_shader_set_uniform_matrix_4fv (GstGLShader * shader, const gchar * name,
|
|||
glUniformMatrix4fvARB (location, count, transpose, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_4x2fv (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);
|
||||
|
||||
glUniformMatrix4x2fv (location, count, transpose, value);
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_shader_set_uniform_matrix_4x3fv (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);
|
||||
|
||||
glUniformMatrix4x3fv (location, count, transpose, value);
|
||||
}
|
||||
|
||||
GLint
|
||||
gst_gl_shader_get_attribute_location (GstGLShader * shader, const gchar * name)
|
||||
{
|
||||
|
|
|
@ -93,10 +93,39 @@ void gst_gl_shader_release (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);
|
||||
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);
|
||||
void gst_gl_shader_set_uniform_matrix_3fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
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);
|
||||
void gst_gl_shader_set_uniform_matrix_4fv (GstGLShader * shader, const gchar * name,
|
||||
GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
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);
|
||||
|
||||
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);
|
||||
|
|
1473
gst-libs/gst/gl/gstglshadervariables.c
Normal file
1473
gst-libs/gst/gl/gstglshadervariables.c
Normal file
File diff suppressed because it is too large
Load diff
39
gst-libs/gst/gl/gstglshadervariables.h
Normal file
39
gst-libs/gst/gl/gstglshadervariables.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2009 Luc Deschenaux <luc.deschenaux@freesurf.ch>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef GST_GLSHADER_VARIABLES
|
||||
#define GST_GLSHADER_VARIABLES
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gstglshader.h>
|
||||
|
||||
#define VALID_VARNAME_CHARS "abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"
|
||||
|
||||
struct gst_gl_shadervariable_desc;
|
||||
|
||||
int gst_gl_shadervariables_parse (GstGLShader * shader, char *variables,
|
||||
int (*_setvariable) (GstGLShader * shader,
|
||||
struct gst_gl_shadervariable_desc * v));
|
||||
int gst_gl_shadervariable_set (GstGLShader * shader,
|
||||
struct gst_gl_shadervariable_desc *ret);
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue