[625/906] add vtable for opengl functions

The vtable provides the ability for one to compile (but not link)
against both OpenGL and GL|ES and starts the move away from GLEW
This commit is contained in:
Matthew Waters 2012-12-07 00:16:04 +11:00
parent cc8e54541b
commit df8c489ada
15 changed files with 1705 additions and 0 deletions

View file

@ -0,0 +1,54 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/* Original files and function definitions courtesy of cogl
*
* Changes:
* - Namespace COGL -> GST_GL
* - remove gl from each function (i.e. glTexImage2D -> TexImage2D)
**/
/* The files in this folder are included multiple times with different
* definitions for these macros. The macros are given the following arguments:
*
* GST_GL_EXT_BEGIN:
*
* @name: a unique symbol name for this feature
*
* @min_gl_major: the major part of the minimum GL version where these
* functions are available in core, or 255 if it isn't available in
* any version.
* @min_gl_minor: the minor part of the minimum GL version where these
* functions are available in core, or 255 if it isn't available in
* any version.
*
* @gles_availability: flags to specify which versions of GLES the
* functions are available in. Should be a combination of
* GST_GL_API_GLES and GST_GL_API_GLES2.
*
* @extension_suffixes: A zero-separated list of suffixes in a
* string. These are appended to the extension name to get a complete
* extension name to try. The suffix is also appended to all of the
* function names. The suffix can optionally include a ':' to specify
* an alternate suffix for the function names.
*
* @extension_names: A list of extension names to try. If any of these
* extensions match then it will be used.
*/

View file

@ -0,0 +1,27 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "glprototypes/opengl.h"
#include "glprototypes/gles1.h"
#include "glprototypes/gles1gles2.h"
#include "glprototypes/gles1opengl.h"
#include "glprototypes/gles1gles2opengl.h"
#include "glprototypes/gles2.h"
#include "glprototypes/gles2opengl.h"

View file

@ -0,0 +1,47 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2009, 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
GST_GL_EXT_BEGIN (only_in_gles1,
255, 255,
GST_GL_API_GLES,
"\0",
"\0")
COGL_EXT_FUNCTION (void, ClipPlanef, (GLenum plane, const GLfloat *equation))
COGL_EXT_END ()

View file

@ -0,0 +1,24 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "glprototypes/gles1.h"
#include "glprototypes/gles1gles2.h"
#include "glprototypes/gles1opengl.h"
#include "glprototypes/gles1gles2opengl.h"

View file

@ -0,0 +1,63 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2009, 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
GST_GL_EXT_BEGIN (only_in_both_gles,
255, 255,
GST_GL_API_GLES |
GST_GL_API_GLES2,
"\0",
"\0")
GST_GL_EXT_FUNCTION (void, DepthRangef,
(GLfloat near_val, GLfloat far_val))
GST_GL_EXT_FUNCTION (void, ClearDepthf,
(GLclampf depth))
GST_GL_EXT_END ()
GST_GL_EXT_BEGIN (EGL_image, 255, 255,
0, /* not in either GLES */
"OES\0",
"EGL_image\0")
GST_GL_EXT_FUNCTION (void, EGLImageTargetTexture2D,
(GLenum target,
GLeglImageOES image))
GST_GL_EXT_FUNCTION (void, EGLImageTargetRenderbufferStorage,
(GLenum target,
GLeglImageOES image))
GST_GL_EXT_END ()

View file

@ -0,0 +1,272 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2009, 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/* These are the core GL functions which we assume will always be
available */
GST_GL_EXT_BEGIN (core,
0, 0,
GST_GL_API_GLES | GST_GL_API_GLES2,
"\0",
"\0")
GST_GL_EXT_FUNCTION (void, BindTexture,
(GLenum target, GLuint texture))
GST_GL_EXT_FUNCTION (void, BlendFunc,
(GLenum sfactor, GLenum dfactor))
GST_GL_EXT_FUNCTION (void, Clear,
(GLbitfield mask))
GST_GL_EXT_FUNCTION (void, ClearColor,
(GLclampf red,
GLclampf green,
GLclampf blue,
GLclampf alpha))
GST_GL_EXT_FUNCTION (void, ClearStencil,
(GLint s))
GST_GL_EXT_FUNCTION (void, ColorMask,
(GLboolean red,
GLboolean green,
GLboolean blue,
GLboolean alpha))
GST_GL_EXT_FUNCTION (void, CopyTexSubImage2D,
(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height))
GST_GL_EXT_FUNCTION (void, DeleteTextures,
(GLsizei n, const GLuint* textures))
GST_GL_EXT_FUNCTION (void, DepthFunc,
(GLenum func))
GST_GL_EXT_FUNCTION (void, DepthMask,
(GLboolean flag))
GST_GL_EXT_FUNCTION (void, Disable,
(GLenum cap))
GST_GL_EXT_FUNCTION (void, DrawArrays,
(GLenum mode, GLint first, GLsizei count))
GST_GL_EXT_FUNCTION (void, DrawElements,
(GLenum mode,
GLsizei count,
GLenum type,
const GLvoid* indices))
GST_GL_EXT_FUNCTION (void, Enable,
(GLenum cap))
GST_GL_EXT_FUNCTION (void, Finish,
(void))
GST_GL_EXT_FUNCTION (void, Flush,
(void))
GST_GL_EXT_FUNCTION (void, FrontFace,
(GLenum mode))
GST_GL_EXT_FUNCTION (void, CullFace,
(GLenum mode))
GST_GL_EXT_FUNCTION (void, GenTextures,
(GLsizei n, GLuint* textures))
GST_GL_EXT_FUNCTION (GLenum, glGetError,
(void))
GST_GL_EXT_FUNCTION (void, GetIntegerv,
(GLenum pname, GLint* params))
GST_GL_EXT_FUNCTION (void, GetBooleanv,
(GLenum pname, GLboolean* params))
GST_GL_EXT_FUNCTION (void, GetFloatv,
(GLenum pname, GLfloat* params))
GST_GL_EXT_FUNCTION (const GLubyte*, GetString,
(GLenum name))
GST_GL_EXT_FUNCTION (void, Hint,
(GLenum target, GLenum mode))
GST_GL_EXT_FUNCTION (GLboolean, glIsTexture,
(GLuint texture))
GST_GL_EXT_FUNCTION (void, PixelStorei,
(GLenum pname, GLint param))
GST_GL_EXT_FUNCTION (void, ReadPixels,
(GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
GLvoid* pixels))
GST_GL_EXT_FUNCTION (void, Scissor,
(GLint x, GLint y, GLsizei width, GLsizei height))
GST_GL_EXT_FUNCTION (void, StencilFunc,
(GLenum func, GLint ref, GLuint mask))
GST_GL_EXT_FUNCTION (void, StencilMask,
(GLuint mask))
GST_GL_EXT_FUNCTION (void, StencilOp,
(GLenum fail, GLenum zfail, GLenum zpass))
GST_GL_EXT_FUNCTION (void, TexImage2D,
(GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLsizei height,
GLint border,
GLenum format,
GLenum type,
const GLvoid* pixels))
GST_GL_EXT_FUNCTION (void, TexParameterfv,
(GLenum target, GLenum pname, const GLfloat* params))
GST_GL_EXT_FUNCTION (void, TexParameteri,
(GLenum target, GLenum pname, GLint param))
GST_GL_EXT_FUNCTION (void, TexParameteriv,
(GLenum target, GLenum pname, const GLint* params))
GST_GL_EXT_FUNCTION (void, GetTexParameterfv,
(GLenum target, GLenum pname, GLfloat* params))
GST_GL_EXT_FUNCTION (void, GetTexParameteriv,
(GLenum target, GLenum pname, GLint* params))
GST_GL_EXT_FUNCTION (void, TexSubImage2D,
(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
const GLvoid* pixels))
GST_GL_EXT_FUNCTION (void, CopyTexImage2D,
(GLenum target,
GLint level,
GLenum internalformat,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLint border))
GST_GL_EXT_FUNCTION (void, Viewport,
(GLint x, GLint y, GLsizei width, GLsizei height))
GST_GL_EXT_FUNCTION (GLboolean, glIsEnabled, (GLenum cap))
GST_GL_EXT_FUNCTION (void, LineWidth, (GLfloat width))
GST_GL_EXT_FUNCTION (void, PolygonOffset, (GLfloat factor, GLfloat units))
GST_GL_EXT_END ()
GST_GL_EXT_BEGIN (only_in_both_gles_and_gl_1_3,
1, 3,
GST_GL_API_GLES |
GST_GL_API_GLES2,
"\0",
"\0")
GST_GL_EXT_FUNCTION (void, CompressedTexImage2D,
(GLenum target,
GLint level,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLint border,
GLsizei imageSize,
const GLvoid* data))
GST_GL_EXT_FUNCTION (void, CompressedTexSubImage2D,
(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLenum format,
GLsizei imageSize,
const GLvoid* data))
GST_GL_EXT_FUNCTION (void, SampleCoverage,
(GLclampf value, GLboolean invert))
GST_GL_EXT_END ()
GST_GL_EXT_BEGIN (only_in_both_gles_and_gl_1_5,
1, 5,
GST_GL_API_GLES |
GST_GL_API_GLES2,
"\0",
"\0")
GST_GL_EXT_FUNCTION (void, GetBufferParameteriv,
(GLenum target, GLenum pname, GLint* params))
GST_GL_EXT_END ()
GST_GL_EXT_BEGIN (vbos, 1, 5,
GST_GL_API_GLES |
GST_GL_API_GLES2,
"ARB\0",
"vertex_buffer_object\0")
GST_GL_EXT_FUNCTION (void, GenBuffers,
(GLuint n,
GLuint *buffers))
GST_GL_EXT_FUNCTION (void, BindBuffer,
(GLenum target,
GLuint buffer))
GST_GL_EXT_FUNCTION (void, BufferData,
(GLenum target,
GLsizeiptr size,
const GLvoid *data,
GLenum usage))
GST_GL_EXT_FUNCTION (void, BufferSubData,
(GLenum target,
GLintptr offset,
GLsizeiptr size,
const GLvoid *data))
GST_GL_EXT_FUNCTION (void, DeleteBuffers,
(GLsizei n,
const GLuint *buffers))
GST_GL_EXT_FUNCTION (GLboolean, IsBuffer,
(GLuint buffer))
GST_GL_EXT_END ()
/* Available in GL 1.3, the multitexture extension or GLES. These are
required */
GST_GL_EXT_BEGIN (multitexture_part0, 1, 3,
GST_GL_API_GLES |
GST_GL_API_GLES2,
"ARB\0",
"multitexture\0")
GST_GL_EXT_FUNCTION (void, ActiveTexture,
(GLenum texture))
GST_GL_EXT_END ()
/* GLES doesn't support mapping buffers in core so this has to be a
separate check */
GST_GL_EXT_BEGIN (map_vbos, 1, 5,
0, /* not in GLES core */
"ARB\0OES\0",
"vertex_buffer_object\0mapbuffer\0")
GST_GL_EXT_FUNCTION (void *, MapBuffer,
(GLenum target,
GLenum access))
GST_GL_EXT_FUNCTION (GLboolean, UnmapBuffer,
(GLenum target))
GST_GL_EXT_END ()

View file

@ -0,0 +1,101 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2009, 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
GST_GL_EXT_BEGIN (multitexture_part1, 1, 3,
GST_GL_API_GLES,
"ARB\0",
"multitexture\0")
GST_GL_EXT_FUNCTION (void, ClientActiveTexture,
(GLenum texture))
GST_GL_EXT_END ()
/* These are the core GL functions which are available when the API
supports fixed-function (ie, GL and GLES1.1) */
GST_GL_EXT_BEGIN (fixed_function_core,
0, 0,
GST_GL_API_GLES,
"\0",
"\0")
GST_GL_EXT_FUNCTION (void, AlphaFunc,
(GLenum func, GLclampf ref))
GST_GL_EXT_FUNCTION (void, Fogf,
(GLenum pname, GLfloat param))
GST_GL_EXT_FUNCTION (void, Fogfv,
(GLenum pname, const GLfloat *params))
GST_GL_EXT_FUNCTION (void, LoadMatrixf,
(const GLfloat *m))
GST_GL_EXT_FUNCTION (void, Materialfv,
(GLenum face, GLenum pname, const GLfloat *params))
GST_GL_EXT_FUNCTION (void, PointSize,
(GLfloat size))
GST_GL_EXT_FUNCTION (void, TexEnvfv,
(GLenum target, GLenum pname, const GLfloat *params))
GST_GL_EXT_FUNCTION (void, Color4ub,
(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
GST_GL_EXT_FUNCTION (void, ColorPointer,
(GLint size,
GLenum type,
GLsizei stride,
const GLvoid *pointer))
GST_GL_EXT_FUNCTION (void, DisableClientState,
(GLenum array))
GST_GL_EXT_FUNCTION (void, EnableClientState,
(GLenum array))
GST_GL_EXT_FUNCTION (void, LoadIdentity,
(void))
GST_GL_EXT_FUNCTION (void, MatrixMode,
(GLenum mode))
GST_GL_EXT_FUNCTION (void, NormalPointer,
(GLenum type, GLsizei stride, const GLvoid *pointer))
GST_GL_EXT_FUNCTION (void, TexCoordPointer,
(GLint size,
GLenum type,
GLsizei stride,
const GLvoid *pointer))
GST_GL_EXT_FUNCTION (void, TexEnvi,
(GLenum target,
GLenum pname,
GLint param))
GST_GL_EXT_FUNCTION (void, VertexPointer,
(GLint size,
GLenum type,
GLsizei stride,
const GLvoid *pointer))
GST_GL_EXT_END ()

View file

@ -0,0 +1,77 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2009, 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
GST_GL_EXT_BEGIN (gles2_only_api,
255, 255,
GST_GL_API_GLES2,
"\0",
"\0")
GST_GL_EXT_FUNCTION (void, ReleaseShaderCompiler, (void))
GST_GL_EXT_FUNCTION (void, GetShaderPrecisionFormat,
(GLenum shadertype,
GLenum precisiontype,
GLint* range,
GLint* precision))
GST_GL_EXT_FUNCTION (void, ShaderBinary,
(GLsizei n,
const GLuint* shaders,
GLenum binaryformat,
const GLvoid* binary,
GLsizei length))
GST_GL_EXT_END ()
GST_GL_EXT_BEGIN (IMG_multisampled_render_to_texture, 255, 255,
0, /* not in either GLES */
"\0",
"IMG_multisampled_render_to_texture\0")
GST_GL_EXT_FUNCTION (void, RenderbufferStorageMultisampleIMG,
(GLenum target,
GLsizei samples,
GLenum internal_format,
GLsizei width,
GLsizei height))
GST_GL_EXT_FUNCTION (void, FramebufferTexture2DMultisampleIMG,
(GLenum target,
GLenum attachment,
GLenum textarget,
GLuint texture,
GLint level,
GLsizei samples))
GST_GL_EXT_END ()

View file

@ -0,0 +1,24 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "glprototypes/gles1gles2.h"
#include "glprototypes/gles1gles2opengl.h"
#include "glprototypes/gles2.h"
#include "glprototypes/gles2opengl.h"

View file

@ -0,0 +1,416 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2009, 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
GST_GL_EXT_BEGIN (offscreen,
255, 255,
GST_GL_API_GLES2,
/* for some reason the ARB version of this
extension doesn't have an ARB suffix for the
functions */
"ARB:\0EXT\0OES\0",
"framebuffer_object\0")
GST_GL_EXT_FUNCTION (void, GenRenderbuffers,
(GLsizei n,
GLuint *renderbuffers))
GST_GL_EXT_FUNCTION (void, DeleteRenderbuffers,
(GLsizei n,
const GLuint *renderbuffers))
GST_GL_EXT_FUNCTION (void, BindRenderbuffer,
(GLenum target,
GLuint renderbuffer))
GST_GL_EXT_FUNCTION (void, RenderbufferStorage,
(GLenum target,
GLenum internalformat,
GLsizei width,
GLsizei height))
GST_GL_EXT_FUNCTION (void, GenFramebuffers,
(GLsizei n,
GLuint *framebuffers))
GST_GL_EXT_FUNCTION (void, BindFramebuffer,
(GLenum target,
GLuint framebuffer))
GST_GL_EXT_FUNCTION (void, FramebufferTexture2D,
(GLenum target,
GLenum attachment,
GLenum textarget,
GLuint texture,
GLint level))
GST_GL_EXT_FUNCTION (void, FramebufferRenderbuffer,
(GLenum target,
GLenum attachment,
GLenum renderbuffertarget,
GLuint renderbuffer))
GST_GL_EXT_FUNCTION (GLboolean, IsRenderbuffer,
(GLuint renderbuffer))
GST_GL_EXT_FUNCTION (GLenum, CheckFramebufferStatus,
(GLenum target))
GST_GL_EXT_FUNCTION (void, DeleteFramebuffers,
(GLsizei n,
const GLuint *framebuffers))
GST_GL_EXT_FUNCTION (void, GenerateMipmap,
(GLenum target))
GST_GL_EXT_FUNCTION (void, GetFramebufferAttachmentParameteriv,
(GLenum target,
GLenum attachment,
GLenum pname,
GLint *params))
GST_GL_EXT_FUNCTION (void, GetRenderbufferParameteriv,
(GLenum target,
GLenum pname,
GLint *params))
GST_GL_EXT_FUNCTION (GLboolean, IsFramebuffer,
(GLuint framebuffer))
GST_GL_EXT_END ()
GST_GL_EXT_BEGIN (blending, 1, 2,
GST_GL_API_GLES2,
"\0",
"\0")
GST_GL_EXT_FUNCTION (void, BlendEquation,
(GLenum mode))
GST_GL_EXT_FUNCTION (void, BlendColor,
(GLclampf red,
GLclampf green,
GLclampf blue,
GLclampf alpha))
GST_GL_EXT_END ()
/* Optional, declared in 1.4 or GLES 1.2 */
GST_GL_EXT_BEGIN (blend_func_separate, 1, 4,
GST_GL_API_GLES2,
"EXT\0",
"blend_func_separate\0")
GST_GL_EXT_FUNCTION (void, BlendFuncSeparate,
(GLenum srcRGB,
GLenum dstRGB,
GLenum srcAlpha,
GLenum dstAlpha))
GST_GL_EXT_END ()
/* Optional, declared in 2.0 */
GST_GL_EXT_BEGIN (blend_equation_separate, 2, 0,
GST_GL_API_GLES2,
"EXT\0",
"blend_equation_separate\0")
GST_GL_EXT_FUNCTION (void, BlendEquationSeparate,
(GLenum modeRGB,
GLenum modeAlpha))
GST_GL_EXT_END ()
/* GL and GLES 2.0 apis */
GST_GL_EXT_BEGIN (two_point_zero_api,
2, 0,
GST_GL_API_GLES2,
"\0",
"\0")
GST_GL_EXT_FUNCTION (void, StencilFuncSeparate,
(GLenum face, GLenum func, GLint ref, GLuint mask))
GST_GL_EXT_FUNCTION (void, StencilMaskSeparate,
(GLenum face, GLuint mask))
GST_GL_EXT_FUNCTION (void, StencilOpSeparate,
(GLenum face, GLenum fail, GLenum zfail, GLenum zpass))
GST_GL_EXT_END ()
/* This lists functions that are unique to GL 2.0 or GLES 2.0 and are
* not in the old GLSL extensions */
GST_GL_EXT_BEGIN (shaders_glsl_2_only, 2, 0,
GST_GL_API_GLES2,
"\0",
"\0")
GST_GL_EXT_FUNCTION (GLuint, CreateProgram,
(void))
GST_GL_EXT_FUNCTION (GLuint, CreateShader,
(GLenum shaderType))
GST_GL_EXT_FUNCTION (void, DeleteShader,
(GLuint shader))
GST_GL_EXT_FUNCTION (void, AttachShader,
(GLuint program,
GLuint shader))
GST_GL_EXT_FUNCTION (void, UseProgram,
(GLuint program))
GST_GL_EXT_FUNCTION (void, DeleteProgram,
(GLuint program))
GST_GL_EXT_FUNCTION (void, GetShaderInfoLog,
(GLuint shader,
GLsizei maxLength,
GLsizei *length,
char *infoLog))
GST_GL_EXT_FUNCTION (void, GetProgramInfoLog,
(GLuint program,
GLsizei bufSize,
GLsizei *length,
char *infoLog))
GST_GL_EXT_FUNCTION (void, GetShaderiv,
(GLuint shader,
GLenum pname,
GLint *params))
GST_GL_EXT_FUNCTION (void, GetProgramiv,
(GLuint program,
GLenum pname,
GLint *params))
GST_GL_EXT_FUNCTION (void, DetachShader,
(GLuint program, GLuint shader))
GST_GL_EXT_FUNCTION (void, GetAttachedShaders,
(GLuint program,
GLsizei maxcount,
GLsizei* count,
GLuint* shaders))
GST_GL_EXT_FUNCTION (GLboolean, glIsShader,
(GLuint shader))
GST_GL_EXT_FUNCTION (GLboolean, glIsProgram,
(GLuint program))
GST_GL_EXT_END ()
/* These functions are provided by GL_ARB_shader_objects or are in GL
* 2.0 core */
GST_GL_EXT_BEGIN (shader_objects_or_gl2, 2, 0,
GST_GL_API_GLES2,
"ARB\0",
"shader_objects\0")
GST_GL_EXT_FUNCTION (void, ShaderSource,
(GLuint shader,
GLsizei count,
const char **string,
const GLint *length))
GST_GL_EXT_FUNCTION (void, CompileShader,
(GLuint shader))
GST_GL_EXT_FUNCTION (void, LinkProgram,
(GLuint program))
GST_GL_EXT_FUNCTION (GLint, GetUniformLocation,
(GLuint program,
const char *name))
GST_GL_EXT_FUNCTION (void, Uniform1f,
(GLint location,
GLfloat v0))
GST_GL_EXT_FUNCTION (void, Uniform2f,
(GLint location,
GLfloat v0,
GLfloat v1))
GST_GL_EXT_FUNCTION (void, Uniform3f,
(GLint location,
GLfloat v0,
GLfloat v1,
GLfloat v2))
GST_GL_EXT_FUNCTION (void, Uniform4f,
(GLint location,
GLfloat v0,
GLfloat v1,
GLfloat v2,
GLfloat v3))
GST_GL_EXT_FUNCTION (void, Uniform1fv,
(GLint location,
GLsizei count,
const GLfloat * value))
GST_GL_EXT_FUNCTION (void, Uniform2fv,
(GLint location,
GLsizei count,
const GLfloat * value))
GST_GL_EXT_FUNCTION (void, Uniform3fv,
(GLint location,
GLsizei count,
const GLfloat * value))
GST_GL_EXT_FUNCTION (void, Uniform4fv,
(GLint location,
GLsizei count,
const GLfloat * value))
GST_GL_EXT_FUNCTION (void, Uniform1i,
(GLint location,
GLint v0))
GST_GL_EXT_FUNCTION (void, Uniform2i,
(GLint location,
GLint v0,
GLint v1))
GST_GL_EXT_FUNCTION (void, Uniform3i,
(GLint location,
GLint v0,
GLint v1,
GLint v2))
GST_GL_EXT_FUNCTION (void, Uniform4i,
(GLint location,
GLint v0,
GLint v1,
GLint v2,
GLint v3))
GST_GL_EXT_FUNCTION (void, Uniform1iv,
(GLint location,
GLsizei count,
const GLint * value))
GST_GL_EXT_FUNCTION (void, Uniform2iv,
(GLint location,
GLsizei count,
const GLint * value))
GST_GL_EXT_FUNCTION (void, Uniform3iv,
(GLint location,
GLsizei count,
const GLint * value))
GST_GL_EXT_FUNCTION (void, Uniform4iv,
(GLint location,
GLsizei count,
const GLint * value))
GST_GL_EXT_FUNCTION (void, UniformMatrix2fv,
(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value))
GST_GL_EXT_FUNCTION (void, UniformMatrix3fv,
(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value))
GST_GL_EXT_FUNCTION (void, UniformMatrix4fv,
(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value))
GST_GL_EXT_FUNCTION (void, GetUniformfv,
(GLuint program,
GLint location,
GLfloat *params))
GST_GL_EXT_FUNCTION (void, GetUniformiv,
(GLuint program,
GLint location,
GLint *params))
GST_GL_EXT_FUNCTION (void, GetActiveUniform,
(GLuint program,
GLuint index,
GLsizei bufsize,
GLsizei* length,
GLint* size,
GLenum* type,
GLchar* name))
GST_GL_EXT_FUNCTION (void, GetShaderSource,
(GLuint shader,
GLsizei bufsize,
GLsizei* length,
GLchar* source))
GST_GL_EXT_FUNCTION (void, glValidateProgram, (GLuint program))
GST_GL_EXT_END ()
/* These functions are provided by GL_ARB_vertex_shader or are in GL
* 2.0 core */
GST_GL_EXT_BEGIN (vertex_shaders, 2, 0,
GST_GL_API_GLES2,
"ARB\0",
"vertex_shader\0")
GST_GL_EXT_FUNCTION (void, VertexAttribPointer,
(GLuint index,
GLint size,
GLenum type,
GLboolean normalized,
GLsizei stride,
const GLvoid *pointer))
GST_GL_EXT_FUNCTION (void, EnableVertexAttribArray,
(GLuint index))
GST_GL_EXT_FUNCTION (void, DisableVertexAttribArray,
(GLuint index))
GST_GL_EXT_FUNCTION (void, VertexAttrib1f, (GLuint indx, GLfloat x))
GST_GL_EXT_FUNCTION (void, VertexAttrib1fv,
(GLuint indx, const GLfloat* values))
GST_GL_EXT_FUNCTION (void, VertexAttrib2f, (GLuint indx, GLfloat x, GLfloat y))
GST_GL_EXT_FUNCTION (void, VertexAttrib2fv,
(GLuint indx, const GLfloat* values))
GST_GL_EXT_FUNCTION (void, VertexAttrib3f,
(GLuint indx, GLfloat x, GLfloat y, GLfloat z))
GST_GL_EXT_FUNCTION (void, VertexAttrib3fv,
(GLuint indx, const GLfloat* values))
GST_GL_EXT_FUNCTION (void, VertexAttrib4f,
(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w))
GST_GL_EXT_FUNCTION (void, VertexAttrib4fv,
(GLuint indx, const GLfloat* values))
GST_GL_EXT_FUNCTION (void, GetVertexAttribfv,
(GLuint index, GLenum pname, GLfloat* params))
GST_GL_EXT_FUNCTION (void, GetVertexAttribiv,
(GLuint index, GLenum pname, GLint* params))
GST_GL_EXT_FUNCTION (void, GetVertexAttribPointerv,
(GLuint index, GLenum pname, GLvoid** pointer))
GST_GL_EXT_FUNCTION (GLint, glGetAttribLocation,
(GLuint program, const char *name))
GST_GL_EXT_FUNCTION (void, BindAttribLocation,
(GLuint program,
GLuint index,
const GLchar* name))
GST_GL_EXT_FUNCTION (void, GetActiveAttrib,
(GLuint program,
GLuint index,
GLsizei bufsize,
GLsizei* length,
GLint* size,
GLenum* type,
GLchar* name))
GST_GL_EXT_END ()
GST_GL_EXT_BEGIN (texture_3d, 1, 2,
0, /* not in either GLES */
"OES\0",
"texture_3D\0")
GST_GL_EXT_FUNCTION (void, TexImage3D,
(GLenum target, GLint level,
GLint internalFormat,
GLsizei width, GLsizei height,
GLsizei depth, GLint border,
GLenum format, GLenum type,
const GLvoid *pixels))
GST_GL_EXT_FUNCTION (void, TexSubImage3D,
(GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLint zoffset, GLsizei width,
GLsizei height, GLsizei depth,
GLenum format,
GLenum type, const GLvoid *pixels))
GST_GL_EXT_END ()
GST_GL_EXT_BEGIN (offscreen_blit, 255, 255,
0, /* not in either GLES */
"EXT\0ANGLE\0",
"framebuffer_blit\0")
GST_GL_EXT_FUNCTION (void, BlitFramebuffer,
(GLint srcX0,
GLint srcY0,
GLint srcX1,
GLint srcY1,
GLint dstX0,
GLint dstY0,
GLint dstX1,
GLint dstY1,
GLbitfield mask,
GLenum filter))
GST_GL_EXT_END ()

View file

@ -0,0 +1,133 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2009, 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/* These are the core GL functions which are only available in big
GL */
GST_GL_EXT_BEGIN (only_in_big_gl,
0, 0,
0, /* not in GLES */
"\0",
"\0")
GST_GL_EXT_FUNCTION (void, GetTexLevelParameteriv,
(GLenum target, GLint level,
GLenum pname, GLint *params))
GST_GL_EXT_FUNCTION (void, GetTexImage,
(GLenum target, GLint level,
GLenum format, GLenum type,
GLvoid *pixels))
GST_GL_EXT_FUNCTION (void, ClipPlane,
(GLenum plane, const double *equation))
GST_GL_EXT_FUNCTION (void, DepthRange,
(double near_val, double far_val))
GST_GL_EXT_FUNCTION (void, DrawBuffer,
(GLenum mode))
GST_GL_EXT_END ()
GST_GL_EXT_BEGIN (framebuffer_discard, 255, 255,
0, /* not in either GLES */
"EXT\0",
"framebuffer_discard\0")
GST_GL_EXT_FUNCTION (void, DiscardFramebuffer,
(GLenum target,
GLsizei numAttachments,
const GLenum *attachments))
GST_GL_EXT_END ()
/* These only list functions that come from the old GLSL extensions.
* Functions that are common to the extensions and GLSL 2.0 should
* instead be listed in cogl-glsl-functions.h */
GST_GL_EXT_BEGIN (shader_objects, 255, 255,
0, /* not in either GLES */
"ARB\0",
"shader_objects\0")
GST_GL_EXT_FUNCTION (GLuint, CreateProgramObject,
(void))
GST_GL_EXT_FUNCTION (GLuint, CreateShaderObject,
(GLenum shaderType))
GST_GL_EXT_FUNCTION (void, DeleteObject,
(GLuint obj))
GST_GL_EXT_FUNCTION (void, AttachObject,
(GLuint container, GLuint obj))
GST_GL_EXT_FUNCTION (void, UseProgramObject,
(GLuint programObj))
GST_GL_EXT_FUNCTION (void, GetInfoLog,
(GLuint obj,
GLsizei maxLength,
GLsizei *length,
char *infoLog))
GST_GL_EXT_FUNCTION (void, GetObjectParameteriv,
(GLuint obj,
GLenum pname,
GLint *params))
GST_GL_EXT_FUNCTION (void, DetachObject,
(GLuint container, GLuint obj))
GST_GL_EXT_FUNCTION (void, GetAttachedObjects,
(GLuint program,
GLsizei maxcount,
GLsizei* count,
GLuint* shaders))
GST_GL_EXT_END ()
/* ARB_fragment_program */
GST_GL_EXT_BEGIN (arbfp, 255, 255,
0, /* not in either GLES */
"ARB\0",
"fragment_program\0")
GST_GL_EXT_FUNCTION (void, GenPrograms,
(GLsizei n,
GLuint *programs))
GST_GL_EXT_FUNCTION (void, DeletePrograms,
(GLsizei n,
GLuint *programs))
GST_GL_EXT_FUNCTION (void, BindProgram,
(GLenum target,
GLuint program))
GST_GL_EXT_FUNCTION (void, ProgramString,
(GLenum target,
GLenum format,
GLsizei len,
const void *program))
GST_GL_EXT_FUNCTION (void, ProgramLocalParameter4fv,
(GLenum target,
GLuint index,
GLfloat *params))
GST_GL_EXT_END ()

View file

@ -0,0 +1,24 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "gl-prototypes/cogl-opengl.h"
#include "gl-prototypes/cogl-gles1-opengl.h"
#include "gl-prototypes/cogl-gles1-gles2-opengl.h"
#include "gl-prototypes/cogl-gles2-opengl.h"

View file

@ -84,6 +84,47 @@ typedef enum
GST_GL_PLATFORM_ANY = G_MAXUINT32
} GstGLPlatform;
#define GST_GL_EXT_BEGIN(name, min_gl, maj_gl, in_gles, ext_suf, ext_name)
#define GST_GL_EXT_FUNCTION(ret, name, args) \
ret (*name) args;
#define GST_GL_EXT_END()
#if HAVE_OPENGL
typedef struct _GstGLFuncs
{
#include "glprototypes/opengl.h"
gpointer padding1[GST_PADDING_LARGE];
#include "glprototypes/gles1opengl.h"
gpointer padding2[GST_PADDING_LARGE];
#include "glprototypes/gles2opengl.h"
gpointer padding3[GST_PADDING_LARGE*2];
#include "glprototypes/gles1gles2opengl.h"
gpointer padding4[GST_PADDING_LARGE*4];
} GstGLFuncs;
const GstGLFuncs *gst_gl_get_opengl_vtable (void);
#endif
#if GST_GL_GLES2
typedef struct _GstGLES2Funcs
{
#include "glprototypes/gles1gles2.h"
gpointer padding1[GST_PADDING_LARGE];
#include "glprototypes/gles1gles2opengl.h"
gpointer padding3[GST_PADDING_LARGE];
#include "glprototypes/gles2.h"
gpointer padding2[GST_PADDING_LARGE*2];
#include "glprototypes/gles2opengl.h"
gpointer padding4[GST_PADDING_LARGE*4];
} GstGLES2Funcs;
const GstGLES2Funcs *gst_gl_get_gles2_vtable (void);
#endif
#undef GST_GL_EXT_BEGIN
#undef GST_GL_EXT_FUNCTION
#undef GST_GL_EXT_END
G_END_DECLS
#endif /* __GST_GL_API_H__ */

View file

@ -0,0 +1,311 @@
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include "gstglfeature.h"
#include "gstglapi.h"
gboolean
gst_gl_check_extension (const char *name, const gchar * ext)
{
char *end;
int name_len, n;
if (name == NULL || ext == NULL)
return FALSE;
end = (char *) (ext + strlen (ext));
name_len = strlen (name);
while (ext < end) {
n = strcspn (ext, " ");
if ((name_len == n) && (!strncmp (name, ext, n)))
return TRUE;
ext += (n + 1);
}
return FALSE;
}
/* Define a set of arrays containing the functions required from GL
for each feature */
#if HAVE_OPENGL
#define GST_GL_EXT_BEGIN(name, \
min_gl_major, min_gl_minor, \
gles_availability, \
namespaces, extension_names) \
static const GstGLFeatureFunction cogl_ext_ ## name ## _funcs_opengl[] = {
#define GST_GL_EXT_FUNCTION(ret, name, args) \
{ G_STRINGIFY (name), G_STRUCT_OFFSET (GstGLFuncs, name) },
#define GST_GL_EXT_END() \
{ NULL, 0 }, \
};
#include "glprototypes/opengl_functions.h"
#undef GST_GL_EXT_BEGIN
#define GST_GL_EXT_BEGIN(name, \
min_gl_major, min_gl_minor, \
gles_availability, \
namespaces, extension_names) \
{ min_gl_major, min_gl_minor, gles_availability, namespaces, \
extension_names, 0, \
cogl_ext_ ## name ## _funcs_opengl },
#undef GST_GL_EXT_FUNCTION
#define GST_GL_EXT_FUNCTION(ret, name, args)
#undef GST_GL_EXT_END
#define GST_GL_EXT_END()
static const GstGLFeatureData cogl_feature_ext_functions_data_opengl[] = {
#include "gl-prototypes/opengl_functions.h"
};
#endif /* HAVE_OPENGL */
#undef GST_GL_EXT_BEGIN
#undef GST_GL_EXT_FUNCTION
#undef GST_GL_EXT_END
#if HAVE_GLES2
#define GST_GL_EXT_BEGIN(name, \
min_gl_major, min_gl_minor, \
gles_availability, \
namespaces, extension_names) \
static const GstGLFeatureFunction cogl_ext_ ## name ## _funcs_gles2[] = {
#define GST_GL_EXT_FUNCTION(ret, name, args) \
{ G_STRINGIFY (name), G_STRUCT_OFFSET (GstGLES2Funcs, name) },
#define GST_GL_EXT_END() \
{ NULL, 0 }, \
};
#include "glprototypes/gles2_functions.h"
#undef GST_GL_EXT_BEGIN
#define GST_GL_EXT_BEGIN(name, \
min_gl_major, min_gl_minor, \
gles_availability, \
namespaces, extension_names) \
{ min_gl_major, min_gl_minor, gles_availability, namespaces, \
extension_names, 0, \
cogl_ext_ ## name ## _funcs_gles2 },
#undef GST_GL_EXT_FUNCTION
#define GST_GL_EXT_FUNCTION(ret, name, args)
#undef GST_GL_EXT_END
#define GST_GL_EXT_END()
static const GstGLFeatureData cogl_feature_ext_functions_data_gles2[] = {
#include "glprototypes/gles2_functions.h"
};
#endif /* HAVE_GLES2 */
#undef GST_GL_EXT_BEGIN
#undef GST_GL_EXT_FUNCTION
#undef GST_GL_EXT_END
#define GST_GL_EXT_BEGIN(name, min_gl_major, min_gl_minor, gles_availability, \
namespaces, extension_names)
#define GST_GL_EXT_FUNCTION(ret, name, args) \
NULL,
#define GST_GL_EXT_END()
#if HAVE_OPENGL
static GstGLFuncs gst_gl = {
#include "glprototypes/opengl.h"
{NULL,},
#include "glprototypes/gles1opengl.h"
{NULL,},
#include "glprototypes/gles2opengl.h"
{NULL,},
#include "glprototypes/gles1gles2opengl.h"
{NULL,},
};
const GstGLFuncs *
gst_gl_get_opengl_vtable (void)
{
return &gst_gl;
}
#endif
#if HAVE_GLES2
static GstGLES2Funcs gst_gles2 = {
#include "glprototypes/gles1gles2.h"
{NULL,},
#include "glprototypes/gles1gles2opengl.h"
{NULL,},
#include "glprototypes/gles2.h"
{NULL,},
#include "glprototypes/gles2opengl.h"
{NULL,},
};
const GstGLES2Funcs *
gst_gl_get_gles2_vtable (void)
{
return &gst_gles2;
}
#endif
gboolean
_gst_gl_feature_check (GstGLDisplay * display,
const char *driver_prefix,
const CoglFeatureData * data,
int gl_major, int gl_minor, const char *extensions_string)
{
const char *suffix = NULL;
int func_num;
/* First check whether the functions should be directly provided by
GL */
if (((display->gl_api & GST_GL_API_OPENGL) &&
GST_GL_CHECK_GL_VERSION (gl_major, gl_minor,
data->min_gl_major, data->min_gl_minor)) ||
((display->gl_api & GST_GL_API_GLES2) &&
(data->gles_availability & COGL_EXT_IN_GLES2))) {
suffix = "";
} else {
/* Otherwise try all of the extensions */
const char *namespace, *namespace_suffix;
unsigned int namespace_len;
for (namespace = data->namespaces; *namespace;
namespace += strlen (namespace) + 1) {
const char *extension;
GString *full_extension_name = g_string_new ("");
/* If the namespace part contains a ':' then the suffix for
the function names is different from the name space */
if ((namespace_suffix = strchr (namespace, ':'))) {
namespace_len = namespace_suffix - namespace;
namespace_suffix++;
} else {
namespace_len = strlen (namespace);
namespace_suffix = namespace;
}
for (extension = data->extension_names; *extension;
extension += strlen (extension) + 1) {
g_string_assign (full_extension_name, driver_prefix);
g_string_append_c (full_extension_name, '_');
g_string_append_len (full_extension_name, namespace, namespace_len);
g_string_append_c (full_extension_name, '_');
g_string_append (full_extension_name, extension);
if (gst_gl_check_extension (full_extension_name->str,
extensions_string))
break;
}
g_string_free (full_extension_name, TRUE);
/* If we found an extension with this namespace then use it
as the suffix */
if (*extension) {
suffix = namespace_suffix;
break;
}
}
}
/* If we couldn't find anything that provides the functions then
give up */
if (suffix == NULL)
goto error;
/* Try to get all of the entry points */
for (func_num = 0; data->functions[func_num].name; func_num++) {
void *func;
char *full_function_name;
full_function_name = g_strconcat ("gl", data->functions[func_num].name,
suffix, NULL);
func =
gst_gl_window_get_proc_address (display->gl_window, full_function_name);
g_free (full_function_name);
if (func == NULL)
goto error;
/* Set the function pointer in the context */
#if HAVE_OPENGL
if (display->gl_api & GST_GL_API_OPENGL) {
*(void **) ((guint8 *) & gst_gl +
data->functions[func_num].pointer_offset) = func;
}
#endif
#if HAVE_GLES2
if (display->gl_api & GST_GL_API_GLES2) {
*(void **) ((guint8 *) & gst_gles2 +
data->functions[func_num].pointer_offset) = func;
}
#endif
}
return TRUE;
/* If the extension isn't found or one of the functions wasn't found
* then set all of the functions pointers to NULL so we can safely
* do feature testing by just looking at the function pointers */
error:
for (func_num = 0; data->functions[func_num].name; func_num++) {
#if HAVE_OPENGL
if (display->gl_api & GST_GL_API_OPENGL) {
*(void **) ((guint8 *) & gst_gl +
data->functions[func_num].pointer_offset) = NULL;
}
#endif
#if HAVE_GLES2
if (display->gl_api & GST_GL_API_GLES2) {
*(void **) ((guint8 *) & gst_gles2 +
data->functions[func_num].pointer_offset) = NULL;
}
#endif
}
return FALSE;
}
void
_gst_gl_feature_check_ext_functions (GstGLDisplay * display,
int gl_major, int gl_minor, const char *gl_extensions)
{
int i;
#if HAVE_OPENGL
if (display->gl_api & GST_GL_API_OPENGL) {
for (i = 0; i < G_N_ELEMENTS (cogl_feature_ext_functions_data_opengl); i++)
_cogl_feature_check (display, "GL",
cogl_feature_ext_functions_data_opengl + i, gl_major, gl_minor,
gl_extensions);
}
#endif
#if HAVE_GLES2
if (display->gl_api & GST_GL_API_GLES2) {
for (i = 0; i < G_N_ELEMENTS (cogl_feature_ext_functions_data_gles2); i++)
_cogl_feature_check (display, "GL",
cogl_feature_ext_functions_data_gles2 + i, gl_major, gl_minor,
gl_extensions);
}
#endif
}

View file

@ -0,0 +1,91 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
#ifndef __COGL_FEATURE_PRIVATE_H
#define __COGL_FEATURE_PRIVATE_H
#include <glib.h>
#include "gstgldisplay.h"
#define GST_GL_CHECK_GL_VERSION(driver_major, driver_minor, \
target_major, target_minor) \
((driver_major) > (target_major) || \
((driver_major) == (target_major) && (driver_minor) >= (target_minor)))
typedef struct _GstGLFeatureFunction GstGLFeatureFunction;
struct _GstGLFeatureFunction
{
/* The name of the function without the "EXT" or "ARB" suffix */
const char *name;
/* The offset in the context of where to store the function pointer */
unsigned int pointer_offset;
};
typedef struct _GstGLFeatureData GstGLFeatureData;
struct _GstGLFeatureData
{
/* A minimum GL version which the functions should be defined in
without needing an extension. Set to 255,255 if it's only
provided in an extension */
int min_gl_major, min_gl_minor;
/* Flags specifying which versions of GLES the feature is available
in core in */
GstGLApi gl_availability;
/* \0 separated list of namespaces to try. Eg "EXT\0ARB\0" */
const char *namespaces;
/* \0 separated list of required extension names without the GL_EXT
or GL_ARB prefix. Any of the extensions must be available for the
feature to be considered available. If the suffix for an
extension is different from the namespace, you can specify it
with a ':' after the namespace */
const char *extension_names;
/* A set of feature flags to enable if the extension is available */
GstGLFeatureFlags feature_flags;
/* A set of private feature flags to enable if the extension is
* available */
int feature_flags_private;
/* An optional corresponding winsys feature. */
// CoglWinsysFeature winsys_feature;
/* A list of functions required for this feature. Terminated with a
NULL name */
const GstGLFeatureFunction *functions;
};
gboolean
_gst_gl_feature_check (GstGLDisplay *display,
const char *driver_prefix,
const GstGLFeatureData *data,
int gl_major,
int gl_minor,
const char *extensions_string);
void
_gst_gl_feature_check_ext_functions (GstGLDisplay *display,
int gl_major,
int gl_minor,
const char *gl_extensions);
#endif /* __COGL_FEATURE_PRIVATE_H */