summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-07-06 18:59:20 +0100
committerNeil Roberts <neil@linux.intel.com>2011-07-07 02:05:42 +0100
commitdae02a99a5c8c5f17188a0efb60eb8555e3e471f (patch)
tree616466972815f4891947faebc949c32c70b2a744
parent17a558a386d41444b926f9e8bec46f74d437745a (diff)
downloadcogl-dae02a99a5c8c5f17188a0efb60eb8555e3e471f.tar.gz
Move all of the GL function pointers directly to CoglContext
Instead of storing all of the feature function pointers in the driver specific data of the CoglContext they are now all stored directly in CoglContext. There is a single header containing the description of the functions which gets included by cogl-context.h. There is a single function in cogl-feature-private.c to check for all of these functions. The name of the function pointer variables have been changed from ctx->drv.pf_glWhatever to just ctx->glWhatever. The feature flags that get set when an extension is available are now separated from the table of extensions. This is necessary because different extensions can mean different things on GLES and GL. For example, having access to glMapBuffer implies read and write support on GL but only write support on GLES. The flags are instead set in the driver specific init function by checking whether the function pointers were successfully resolved. _cogl_feature_check has been changed to assume the feature is supported if any of the listed extensions are available instead of requiring all of them. This makes it more convenient to specify alternate names for the extension. Nothing else had previously listed more than one name for an extension so this shouldn't cause any problems.
-rw-r--r--cogl/Makefile.am3
-rw-r--r--cogl/cogl-attribute.c26
-rw-r--r--cogl/cogl-blend-string.c2
-rw-r--r--cogl/cogl-buffer.c16
-rw-r--r--cogl/cogl-context-private.h21
-rw-r--r--cogl/cogl-context.c2
-rw-r--r--cogl/cogl-ext-functions.h438
-rw-r--r--cogl/cogl-feature-private.c69
-rw-r--r--cogl/cogl-feature-private.h25
-rw-r--r--cogl/cogl-framebuffer.c24
-rw-r--r--cogl/cogl-pipeline-fragend-arbfp.c12
-rw-r--r--cogl/cogl-pipeline-fragend-glsl.c12
-rw-r--r--cogl/cogl-pipeline-opengl.c40
-rw-r--r--cogl/cogl-pipeline-progend-glsl.c22
-rw-r--r--cogl/cogl-pipeline-vertend-glsl.c12
-rw-r--r--cogl/cogl-program.c42
-rw-r--r--cogl/cogl-shader.c20
-rw-r--r--cogl/cogl-texture-2d.c2
-rw-r--r--cogl/cogl-texture-3d.c4
-rw-r--r--cogl/driver/gl/cogl-context-driver-gl.h20
-rw-r--r--cogl/driver/gl/cogl-feature-functions-gl.h435
-rw-r--r--cogl/driver/gl/cogl-gl.c80
-rw-r--r--cogl/driver/gl/cogl-texture-driver-gl.c4
-rw-r--r--cogl/driver/gles/cogl-context-driver-gles.h20
-rw-r--r--cogl/driver/gles/cogl-feature-functions-gles.h153
-rw-r--r--cogl/driver/gles/cogl-gles.c78
-rw-r--r--cogl/driver/gles/cogl-texture-driver-gles.c4
-rw-r--r--cogl/winsys/cogl-winsys-egl.c4
-rw-r--r--cogl/winsys/cogl-winsys-glx.c14
-rw-r--r--cogl/winsys/cogl-winsys-wgl.c4
30 files changed, 750 insertions, 858 deletions
diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index a2093b2d..802fc305 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -104,7 +104,6 @@ cogl_driver_sources =
if COGL_DRIVER_GL
cogl_driver_sources += \
- $(srcdir)/driver/gl/cogl-feature-functions-gl.h \
$(srcdir)/driver/gl/cogl-gl.c \
$(srcdir)/driver/gl/cogl-texture-driver-gl.c \
$(srcdir)/driver/gl/cogl-context-driver-gl.h \
@@ -113,7 +112,6 @@ endif
if COGL_DRIVER_GLES
cogl_driver_sources += \
- $(srcdir)/driver/gles/cogl-feature-functions-gles.h \
$(srcdir)/driver/gles/cogl-gles.c \
$(srcdir)/driver/gles/cogl-texture-driver-gles.c \
$(srcdir)/driver/gles/cogl-context-driver-gles.h \
@@ -210,6 +208,7 @@ cogl_sources_c = \
$(srcdir)/cogl-clip-state.c \
$(srcdir)/cogl2-clip-state.h \
$(srcdir)/cogl2-clip-state.c \
+ $(srcdir)/cogl-ext-functions.h \
$(srcdir)/cogl-feature-private.h \
$(srcdir)/cogl-feature-private.c \
$(srcdir)/cogl-fixed.c \
diff --git a/cogl/cogl-attribute.c b/cogl/cogl-attribute.c
index d0bd85c7..0e5e1066 100644
--- a/cogl/cogl-attribute.c
+++ b/cogl/cogl-attribute.c
@@ -49,26 +49,26 @@
#if defined (HAVE_COGL_GL)
-#define glGenBuffers ctx->drv.pf_glGenBuffers
-#define glBindBuffer ctx->drv.pf_glBindBuffer
-#define glBufferData ctx->drv.pf_glBufferData
-#define glBufferSubData ctx->drv.pf_glBufferSubData
-#define glGetBufferSubData ctx->drv.pf_glGetBufferSubData
-#define glDeleteBuffers ctx->drv.pf_glDeleteBuffers
-#define glMapBuffer ctx->drv.pf_glMapBuffer
-#define glUnmapBuffer ctx->drv.pf_glUnmapBuffer
-#define glClientActiveTexture ctx->drv.pf_glClientActiveTexture
+#define glGenBuffers ctx->glGenBuffers
+#define glBindBuffer ctx->glBindBuffer
+#define glBufferData ctx->glBufferData
+#define glBufferSubData ctx->glBufferSubData
+#define glGetBufferSubData ctx->glGetBufferSubData
+#define glDeleteBuffers ctx->glDeleteBuffers
+#define glMapBuffer ctx->glMapBuffer
+#define glUnmapBuffer ctx->glUnmapBuffer
+#define glClientActiveTexture ctx->glClientActiveTexture
#ifndef GL_ARRAY_BUFFER
#define GL_ARRAY_BUFFER GL_ARRAY_BUFFER_ARB
#endif
-#define glVertexAttribPointer ctx->drv.pf_glVertexAttribPointer
-#define glEnableVertexAttribArray ctx->drv.pf_glEnableVertexAttribArray
-#define glDisableVertexAttribArray ctx->drv.pf_glDisableVertexAttribArray
+#define glVertexAttribPointer ctx->glVertexAttribPointer
+#define glEnableVertexAttribArray ctx->glEnableVertexAttribArray
+#define glDisableVertexAttribArray ctx->glDisableVertexAttribArray
#define MAY_HAVE_PROGRAMABLE_GL
#define glDrawRangeElements(mode, start, end, count, type, indices) \
- ctx->drv.pf_glDrawRangeElements (mode, start, end, count, type, indices)
+ ctx->glDrawRangeElements (mode, start, end, count, type, indices)
#else /* GLES 1/2 */
diff --git a/cogl/cogl-blend-string.c b/cogl/cogl-blend-string.c
index 921b8091..aaba5cf5 100644
--- a/cogl/cogl-blend-string.c
+++ b/cogl/cogl-blend-string.c
@@ -222,7 +222,7 @@ validate_blend_statements (CoglBlendStringStatement *statements,
if (n_statements == 2)
{
/* glBlendEquationSeperate is GL 2.0 only */
- if (!ctx->drv.pf_glBlendEquationSeparate &&
+ if (!ctx->glBlendEquationSeparate &&
statements[0].function->type != statements[1].function->type)
{
error_string = "Separate blend functions for the RGB an A "
diff --git a/cogl/cogl-buffer.c b/cogl/cogl-buffer.c
index 2892fd9b..eae7e0c3 100644
--- a/cogl/cogl-buffer.c
+++ b/cogl/cogl-buffer.c
@@ -51,18 +51,18 @@
#if defined (HAVE_COGL_GL)
-#define glGenBuffers ctx->drv.pf_glGenBuffers
-#define glBindBuffer ctx->drv.pf_glBindBuffer
-#define glBufferData ctx->drv.pf_glBufferData
-#define glBufferSubData ctx->drv.pf_glBufferSubData
-#define glGetBufferSubData ctx->drv.pf_glGetBufferSubData
-#define glDeleteBuffers ctx->drv.pf_glDeleteBuffers
+#define glGenBuffers ctx->glGenBuffers
+#define glBindBuffer ctx->glBindBuffer
+#define glBufferData ctx->glBufferData
+#define glBufferSubData ctx->glBufferSubData
+#define glGetBufferSubData ctx->glGetBufferSubData
+#define glDeleteBuffers ctx->glDeleteBuffers
#endif
/* These two are always accessed through an extension, even on GLES */
-#define glMapBuffer ctx->drv.pf_glMapBuffer
-#define glUnmapBuffer ctx->drv.pf_glUnmapBuffer
+#define glMapBuffer ctx->glMapBuffer
+#define glUnmapBuffer ctx->glUnmapBuffer
#ifndef GL_PIXEL_PACK_BUFFER
#define GL_PIXEL_PACK_BUFFER 0x88EB
diff --git a/cogl/cogl-context-private.h b/cogl/cogl-context-private.h
index 2bc65288..386407f7 100644
--- a/cogl/cogl-context-private.h
+++ b/cogl/cogl-context-private.h
@@ -264,6 +264,27 @@ struct _CoglContext
unsigned int winsys_features
[COGL_FLAGS_N_INTS_FOR_SIZE (COGL_WINSYS_FEATURE_N_FEATURES)];
void *winsys;
+
+ /* This defines a list of function pointers that Cogl uses from
+ either GL or GLES. All functions are accessed indirectly through
+ these pointers rather than linking to them directly */
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+
+#define COGL_EXT_BEGIN(name, \
+ min_gl_major, min_gl_minor, \
+ gles_availability, \
+ extension_suffixes, extension_names)
+#define COGL_EXT_FUNCTION(ret, name, args) \
+ ret (APIENTRY * name) args;
+#define COGL_EXT_END()
+
+#include "cogl-ext-functions.h"
+
+#undef COGL_EXT_BEGIN
+#undef COGL_EXT_FUNCTION
+#undef COGL_EXT_END
};
CoglContext *
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index 837b70db..884ec4a7 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -47,7 +47,7 @@
#ifdef HAVE_COGL_GL
#include "cogl-pipeline-fragend-arbfp-private.h"
-#define glActiveTexture _context->drv.pf_glActiveTexture
+#define glActiveTexture _context->glActiveTexture
#endif
/* This isn't defined in the GLES headers */
diff --git a/cogl/cogl-ext-functions.h b/cogl/cogl-ext-functions.h
new file mode 100644
index 00000000..e73e4dce
--- /dev/null
+++ b/cogl/cogl-ext-functions.h
@@ -0,0 +1,438 @@
+/*
+ * 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/>.
+ *
+ *
+ */
+
+/* This is included multiple times with different definitions for
+ * these macros. The macros are given the following arguments:
+ *
+ * COGL_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
+ * COGL_EXT_IN_GLES and COGL_EXT_IN_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.
+ */
+COGL_EXT_BEGIN (offscreen,
+ 255, 255,
+ COGL_EXT_IN_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")
+COGL_EXT_FUNCTION (void, glGenRenderbuffers,
+ (GLsizei n,
+ GLuint *renderbuffers))
+COGL_EXT_FUNCTION (void, glDeleteRenderbuffers,
+ (GLsizei n,
+ const GLuint *renderbuffers))
+COGL_EXT_FUNCTION (void, glBindRenderbuffer,
+ (GLenum target,
+ GLuint renderbuffer))
+COGL_EXT_FUNCTION (void, glRenderbufferStorage,
+ (GLenum target,
+ GLenum internalformat,
+ GLsizei width,
+ GLsizei height))
+COGL_EXT_FUNCTION (void, glGenFramebuffers,
+ (GLsizei n,
+ GLuint *framebuffers))
+COGL_EXT_FUNCTION (void, glBindFramebuffer,
+ (GLenum target,
+ GLuint framebuffer))
+COGL_EXT_FUNCTION (void, glFramebufferTexture2D,
+ (GLenum target,
+ GLenum attachment,
+ GLenum textarget,
+ GLuint texture,
+ GLint level))
+COGL_EXT_FUNCTION (void, glFramebufferRenderbuffer,
+ (GLenum target,
+ GLenum attachment,
+ GLenum renderbuffertarget,
+ GLuint renderbuffer))
+COGL_EXT_FUNCTION (GLenum, glCheckFramebufferStatus,
+ (GLenum target))
+COGL_EXT_FUNCTION (void, glDeleteFramebuffers,
+ (GLsizei n,
+ const GLuint *framebuffers))
+COGL_EXT_FUNCTION (void, glGenerateMipmap,
+ (GLenum target))
+COGL_EXT_FUNCTION (void, glGetFramebufferAttachmentParameteriv,
+ (GLenum target,
+ GLenum attachment,
+ GLenum pname,
+ GLint *params))
+COGL_EXT_END ()
+
+COGL_EXT_BEGIN (offscreen_blit, 255, 255,
+ 0, /* not in either GLES */
+ "EXT\0ANGLE\0",
+ "framebuffer_blit\0")
+COGL_EXT_FUNCTION (void, glBlitFramebuffer,
+ (GLint srcX0,
+ GLint srcY0,
+ GLint srcX1,
+ GLint srcY1,
+ GLint dstX0,
+ GLint dstY0,
+ GLint dstX1,
+ GLint dstY1,
+ GLbitfield mask,
+ GLenum filter))
+COGL_EXT_END ()
+
+COGL_EXT_BEGIN (offscreen_multisample, 255, 255,
+ 0, /* not in either GLES */
+ "EXT\0",
+ "framebuffer_multisample\0")
+COGL_EXT_FUNCTION (void, glRenderbufferStorageMultisample,
+ (GLenum target,
+ GLsizei samples,
+ GLenum internalformat,
+ GLsizei width,
+ GLsizei height))
+COGL_EXT_END ()
+
+/* ARB_fragment_program */
+COGL_EXT_BEGIN (arbfp, 255, 255,
+ 0, /* not in either GLES */
+ "ARB\0",
+ "fragment_program\0")
+COGL_EXT_FUNCTION (void, glGenPrograms,
+ (GLsizei n,
+ GLuint *programs))
+COGL_EXT_FUNCTION (void, glDeletePrograms,
+ (GLsizei n,
+ GLuint *programs))
+COGL_EXT_FUNCTION (void, glBindProgram,
+ (GLenum target,
+ GLuint program))
+COGL_EXT_FUNCTION (void, glProgramString,
+ (GLenum target,
+ GLenum format,
+ GLsizei len,
+ const void *program))
+COGL_EXT_FUNCTION (void, glProgramLocalParameter4fv,
+ (GLenum target,
+ GLuint index,
+ GLfloat *params))
+COGL_EXT_END ()
+
+/* The function names in OpenGL 2.0 are different so we can't easily
+ just check for GL 2.0 */
+COGL_EXT_BEGIN (shaders_glsl, 2, 0,
+ COGL_EXT_IN_GLES2,
+ "\0",
+ "\0")
+COGL_EXT_FUNCTION (GLuint, glCreateProgram,
+ (void))
+COGL_EXT_FUNCTION (GLuint, glCreateShader,
+ (GLenum shaderType))
+COGL_EXT_FUNCTION (void, glShaderSource,
+ (GLuint shader,
+ GLsizei count,
+ const GLchar **string,
+ const GLint *length))
+COGL_EXT_FUNCTION (void, glCompileShader,
+ (GLuint shader))
+COGL_EXT_FUNCTION (void, glDeleteShader,
+ (GLuint shader))
+COGL_EXT_FUNCTION (void, glAttachShader,
+ (GLuint program,
+ GLuint shader))
+COGL_EXT_FUNCTION (void, glLinkProgram,
+ (GLuint program))
+COGL_EXT_FUNCTION (void, glUseProgram,
+ (GLuint program))
+COGL_EXT_FUNCTION (GLint, glGetUniformLocation,
+ (GLuint program,
+ const GLchar *name))
+COGL_EXT_FUNCTION (void, glDeleteProgram,
+ (GLuint program))
+COGL_EXT_FUNCTION (void, glGetShaderInfoLog,
+ (GLuint shader,
+ GLsizei maxLength,
+ GLsizei *length,
+ GLchar *infoLog))
+COGL_EXT_FUNCTION (void, glGetShaderiv,
+ (GLuint shader,
+ GLenum pname,
+ GLint *params))
+
+COGL_EXT_FUNCTION (void, glVertexAttribPointer,
+ (GLuint index,
+ GLint size,
+ GLenum type,
+ GLboolean normalized,
+ GLsizei stride,
+ const GLvoid *pointer))
+COGL_EXT_FUNCTION (void, glEnableVertexAttribArray,
+ (GLuint index))
+COGL_EXT_FUNCTION (void, glDisableVertexAttribArray,
+ (GLuint index))
+
+COGL_EXT_FUNCTION (void, glUniform1f,
+ (GLint location,
+ GLfloat v0))
+COGL_EXT_FUNCTION (void, glUniform2f,
+ (GLint location,
+ GLfloat v0,
+ GLfloat v1))
+COGL_EXT_FUNCTION (void, glUniform3f,
+ (GLint location,
+ GLfloat v0,
+ GLfloat v1,
+ GLfloat v2))
+COGL_EXT_FUNCTION (void, glUniform4f,
+ (GLint location,
+ GLfloat v0,
+ GLfloat v1,
+ GLfloat v2,
+ GLfloat v3))
+COGL_EXT_FUNCTION (void, glUniform1fv,
+ (GLint location,
+ GLsizei count,
+ const GLfloat * value))
+COGL_EXT_FUNCTION (void, glUniform2fv,
+ (GLint location,
+ GLsizei count,
+ const GLfloat * value))
+COGL_EXT_FUNCTION (void, glUniform3fv,
+ (GLint location,
+ GLsizei count,
+ const GLfloat * value))
+COGL_EXT_FUNCTION (void, glUniform4fv,
+ (GLint location,
+ GLsizei count,
+ const GLfloat * value))
+COGL_EXT_FUNCTION (void, glUniform1i,
+ (GLint location,
+ GLint v0))
+COGL_EXT_FUNCTION (void, glUniform2i,
+ (GLint location,
+ GLint v0,
+ GLint v1))
+COGL_EXT_FUNCTION (void, glUniform3i,
+ (GLint location,
+ GLint v0,
+ GLint v1,
+ GLint v2))
+COGL_EXT_FUNCTION (void, glUniform4i,
+ (GLint location,
+ GLint v0,
+ GLint v1,
+ GLint v2,
+ GLint v3))
+COGL_EXT_FUNCTION (void, glUniform1iv,
+ (GLint location,
+ GLsizei count,
+ const GLint * value))
+COGL_EXT_FUNCTION (void, glUniform2iv,
+ (GLint location,
+ GLsizei count,
+ const GLint * value))
+COGL_EXT_FUNCTION (void, glUniform3iv,
+ (GLint location,
+ GLsizei count,
+ const GLint * value))
+COGL_EXT_FUNCTION (void, glUniform4iv,
+ (GLint location,
+ GLsizei count,
+ const GLint * value))
+COGL_EXT_FUNCTION (void, glUniformMatrix2fv,
+ (GLint location,
+ GLsizei count,
+ GLboolean transpose,
+ const GLfloat *value))
+COGL_EXT_FUNCTION (void, glUniformMatrix3fv,
+ (GLint location,
+ GLsizei count,
+ GLboolean transpose,
+ const GLfloat *value))
+COGL_EXT_FUNCTION (void, glUniformMatrix4fv,
+ (GLint location,
+ GLsizei count,
+ GLboolean transpose,
+ const GLfloat *value))
+
+COGL_EXT_FUNCTION (void, glGetProgramiv,
+ (GLuint program,
+ GLenum pname,
+ GLint *params))
+
+COGL_EXT_FUNCTION (void, glGetProgramInfoLog,
+ (GLuint program,
+ GLsizei bufSize,
+ GLsizei *length,
+ GLchar *infoLog))
+
+COGL_EXT_END ()
+
+COGL_EXT_BEGIN (vbos, 1, 5,
+ COGL_EXT_IN_GLES |
+ COGL_EXT_IN_GLES2,
+ "ARB\0",
+ "vertex_buffer_object\0")
+COGL_EXT_FUNCTION (void, glGenBuffers,
+ (GLuint n,
+ GLuint *buffers))
+COGL_EXT_FUNCTION (void, glBindBuffer,
+ (GLenum target,
+ GLuint buffer))
+COGL_EXT_FUNCTION (void, glBufferData,
+ (GLenum target,
+ GLsizeiptr size,
+ const GLvoid *data,
+ GLenum usage))
+COGL_EXT_FUNCTION (void, glBufferSubData,
+ (GLenum target,
+ GLintptr offset,
+ GLsizeiptr size,
+ const GLvoid *data))
+COGL_EXT_FUNCTION (void, glDeleteBuffers,
+ (GLsizei n,
+ const GLuint *buffers))
+COGL_EXT_END ()
+
+/* GLES doesn't support mapping buffers in core so this has to be a
+ separate check */
+COGL_EXT_BEGIN (map_vbos, 1, 5,
+ 0, /* not in GLES core */
+ "ARB\0OES\0",
+ "vertex_buffer_object\0mapbuffer\0")
+COGL_EXT_FUNCTION (void *, glMapBuffer,
+ (GLenum target,
+ GLenum access))
+COGL_EXT_FUNCTION (GLboolean, glUnmapBuffer,
+ (GLenum target))
+COGL_EXT_END ()
+
+COGL_EXT_BEGIN (draw_range_elements, 1, 2,
+ 0, /* not in either GLES */
+ "\0",
+ "\0")
+COGL_EXT_FUNCTION (void, glDrawRangeElements,
+ (GLenum mode,
+ GLuint start,
+ GLuint end,
+ GLsizei count,
+ GLenum type,
+ const GLvoid *indices))
+COGL_EXT_END ()
+
+COGL_EXT_BEGIN (blending, 1, 2,
+ COGL_EXT_IN_GLES2,
+ "\0",
+ "\0")
+COGL_EXT_FUNCTION (void, glBlendEquation,
+ (GLenum mode))
+COGL_EXT_FUNCTION (void, glBlendColor,
+ (GLclampf red,
+ GLclampf green,
+ GLclampf blue,
+ GLclampf alpha))
+COGL_EXT_END ()
+
+COGL_EXT_BEGIN (texture_3d, 1, 2,
+ 0, /* not in either GLES */
+ "OES\0",
+ "texture_3D\0")
+COGL_EXT_FUNCTION (void, glTexImage3D,
+ (GLenum target, GLint level,
+ GLint internalFormat,
+ GLsizei width, GLsizei height,
+ GLsizei depth, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels))
+COGL_EXT_FUNCTION (void, glTexSubImage3D,
+ (GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint zoffset, GLsizei width,
+ GLsizei height, GLsizei depth,
+ GLenum format,
+ GLenum type, const GLvoid *pixels))
+COGL_EXT_END ()
+
+/* Available in GL 1.3, the multitexture extension or GLES. These are
+ required */
+COGL_EXT_BEGIN (multitexture, 1, 3,
+ COGL_EXT_IN_GLES |
+ COGL_EXT_IN_GLES2,
+ "ARB\0",
+ "multitexture\0")
+COGL_EXT_FUNCTION (void, glActiveTexture,
+ (GLenum texture))
+COGL_EXT_FUNCTION (void, glClientActiveTexture,
+ (GLenum texture))
+COGL_EXT_END ()
+
+/* Optional, declared in 1.4 or GLES 1.2 */
+COGL_EXT_BEGIN (blend_func_separate, 1, 4,
+ COGL_EXT_IN_GLES2,
+ "EXT\0",
+ "blend_func_separate\0")
+COGL_EXT_FUNCTION (void, glBlendFuncSeparate,
+ (GLenum srcRGB,
+ GLenum dstRGB,
+ GLenum srcAlpha,
+ GLenum dstAlpha))
+COGL_EXT_END ()
+
+/* Optional, declared in 2.0 */
+COGL_EXT_BEGIN (blend_equation_separate, 2, 0,
+ COGL_EXT_IN_GLES2,
+ "EXT\0",
+ "blend_equation_separate\0")
+COGL_EXT_FUNCTION (void, glBlendEquationSeparate,
+ (GLenum modeRGB,
+ GLenum modeAlpha))
+COGL_EXT_END ()
+
+COGL_EXT_BEGIN (EGL_image, 255, 255,
+ 0, /* not in either GLES */
+ "OES\0",
+ "EGL_image\0")
+COGL_EXT_FUNCTION (void, glEGLImageTargetTexture2D,
+ (GLenum target,
+ GLeglImageOES image))
+COGL_EXT_FUNCTION (void, glEGLImageTargetRenderbufferStorage,
+ (GLenum target,
+ GLeglImageOES image))
+COGL_EXT_END ()
diff --git a/cogl/cogl-feature-private.c b/cogl/cogl-feature-private.c
index 1b60afd7..27c806ca 100644
--- a/cogl/cogl-feature-private.c
+++ b/cogl/cogl-feature-private.c
@@ -36,8 +36,9 @@ gboolean
_cogl_feature_check (const CoglWinsysVtable *winsys,
const char *driver_prefix,
const CoglFeatureData *data,
- unsigned int gl_major,
- unsigned int gl_minor,
+ int gl_major,
+ int gl_minor,
+ CoglExtGlesAvailability gles_version,
const char *extensions_string,
void *function_table)
@@ -48,7 +49,8 @@ _cogl_feature_check (const CoglWinsysVtable *winsys,
/* First check whether the functions should be directly provided by
GL */
if (COGL_CHECK_GL_VERSION (gl_major, gl_minor,
- data->min_gl_major, data->min_gl_minor))
+ data->min_gl_major, data->min_gl_minor) ||
+ (gles_version & data->gles_availability))
suffix = "";
else
{
@@ -86,16 +88,16 @@ _cogl_feature_check (const CoglWinsysVtable *winsys,
namespace, namespace_len);
g_string_append_c (full_extension_name, '_');
g_string_append (full_extension_name, extension);
- if (!_cogl_check_extension (full_extension_name->str,
- extensions_string))
+ if (_cogl_check_extension (full_extension_name->str,
+ extensions_string))
break;
}
g_string_free (full_extension_name, TRUE);
- /* If we found all of the extensions with this namespace
- then use it as the suffix */
- if (*extension == '\0')
+ /* If we found an extension with this namespace then use it
+ as the suffix */
+ if (*extension)
{
suffix = namespace_suffix;
break;
@@ -139,3 +141,54 @@ error:
return FALSE;
}
+
+/* Define a set of arrays containing the functions required from GL
+ for each feature */
+#define COGL_EXT_BEGIN(name, \
+ min_gl_major, min_gl_minor, \
+ gles_availability, \
+ namespaces, extension_names) \
+ static const CoglFeatureFunction cogl_ext_ ## name ## _funcs[] = {
+#define COGL_EXT_FUNCTION(ret, name, args) \
+ { G_STRINGIFY (name), G_STRUCT_OFFSET (CoglContext, name) },
+#define COGL_EXT_END() \
+ { NULL, 0 }, \
+ };
+#include "cogl-ext-functions.h"
+
+/* Define an array of features */
+#undef COGL_EXT_BEGIN
+#define COGL_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, 0, 0, \
+ cogl_ext_ ## name ## _funcs },
+#undef COGL_EXT_FUNCTION
+#define COGL_EXT_FUNCTION(ret, name, args)
+#undef COGL_EXT_END
+#define COGL_EXT_END()
+
+static const CoglFeatureData
+cogl_feature_ext_functions_data[] =
+ {
+#include "cogl-ext-functions.h"
+ };
+
+void
+_cogl_feature_check_ext_functions (CoglContext *context,
+ int gl_major,
+ int gl_minor,
+ const char *gl_extensions,
+ CoglExtGlesAvailability gles_version)
+{
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (cogl_feature_ext_functions_data); i++)
+ _cogl_feature_check (_cogl_context_get_winsys (context),
+ "GL", cogl_feature_ext_functions_data + i,
+ gl_major, gl_minor, gles_version,
+ gl_extensions,
+ context);
+}
diff --git a/cogl/cogl-feature-private.h b/cogl/cogl-feature-private.h
index d81693d4..b90897b9 100644
--- a/cogl/cogl-feature-private.h
+++ b/cogl/cogl-feature-private.h
@@ -33,6 +33,12 @@
((driver_major) > (target_major) || \
((driver_major) == (target_major) && (driver_minor) >= (target_minor)))
+typedef enum
+{
+ COGL_EXT_IN_GLES = (1 << 0),
+ COGL_EXT_IN_GLES2 = (1 << 1)
+} CoglExtGlesAvailability;
+
typedef struct _CoglFeatureFunction CoglFeatureFunction;
struct _CoglFeatureFunction
@@ -50,11 +56,14 @@ struct _CoglFeatureData
/* 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 */
- guint8 min_gl_major, min_gl_minor;
+ int min_gl_major, min_gl_minor;
+ /* Flags specifying which versions of GLES the feature is available
+ in core in */
+ CoglExtGlesAvailability gles_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. All of the extensions must be available for the
+ 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 */
@@ -75,9 +84,17 @@ gboolean
_cogl_feature_check (const CoglWinsysVtable *winsys,
const char *driver_prefix,
const CoglFeatureData *data,
- unsigned int gl_major,
- unsigned int gl_minor,
+ int gl_major,
+ int gl_minor,
+ CoglExtGlesAvailability gles_version,
const char *extensions_string,
void *function_table);
+void
+_cogl_feature_check_ext_functions (CoglContext *context,
+ int gl_major,
+ int gl_minor,
+ const char *gl_extensions,
+ CoglExtGlesAvailability gles_version);
+
#endif /* __COGL_FEATURE_PRIVATE_H */
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index f0705dd1..e96f1f6d 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -42,22 +42,22 @@
#ifndef HAVE_COGL_GLES2
-#define glGenRenderbuffers ctx->drv.pf_glGenRenderbuffers
-#define glDeleteRenderbuffers ctx->drv.pf_glDeleteRenderbuffers
-#define glBindRenderbuffer ctx->drv.pf_glBindRenderbuffer
-#define glRenderbufferStorage ctx->drv.pf_glRenderbufferStorage
-#define glGenFramebuffers ctx->drv.pf_glGenFramebuffers
-#define glBindFramebuffer ctx->drv.pf_glBindFramebuffer
-#define glFramebufferTexture2D ctx->drv.pf_glFramebufferTexture2D
-#define glFramebufferRenderbuffer ctx->drv.pf_glFramebufferRenderbuffer
-#define glCheckFramebufferStatus ctx->drv.pf_glCheckFramebufferStatus
-#define glDeleteFramebuffers ctx->drv.pf_glDeleteFramebuffers
+#define glGenRenderbuffers ctx->glGenRenderbuffers
+#define glDeleteRenderbuffers ctx->glDeleteRenderbuffers
+#define glBindRenderbuffer ctx->glBindRenderbuffer
+#define glRenderbufferStorage ctx->glRenderbufferStorage
+#define glGenFramebuffers ctx->glGenFramebuffers
+#define glBindFramebuffer ctx->glBindFramebuffer
+#define glFramebufferTexture2D ctx->glFramebufferTexture2D
+#define glFramebufferRenderbuffer ctx->glFramebufferRenderbuffer
+#define glCheckFramebufferStatus ctx->glCheckFramebufferStatus
+#define glDeleteFramebuffers ctx->glDeleteFramebuffers
#define glGetFramebufferAttachmentParameteriv \
- ctx->drv.pf_glGetFramebufferAttachmentParameteriv
+ ctx->glGetFramebufferAttachmentParameteriv
#endif
-#define glBlitFramebuffer ctx->drv.pf_glBlitFramebuffer
+#define glBlitFramebuffer ctx->glBlitFramebuffer
#ifndef GL_FRAMEBUFFER
#define GL_FRAMEBUFFER 0x8D40
diff --git a/cogl/cogl-pipeline-fragend-arbfp.c b/cogl/cogl-pipeline-fragend-arbfp.c
index 5878be4c..3f4c4a39 100644
--- a/cogl/cogl-pipeline-fragend-arbfp.c
+++ b/cogl/cogl-pipeline-fragend-arbfp.c
@@ -55,12 +55,12 @@
*/
#ifdef HAVE_COGL_GL
-#define glProgramString ctx->drv.pf_glProgramString
-#define glBindProgram ctx->drv.pf_glBindProgram
-#define glDeletePrograms ctx->drv.pf_glDeletePrograms
-#define glGenPrograms ctx->drv.pf_glGenPrograms
-#define glProgramLocalParameter4fv ctx->drv.pf_glProgramLocalParameter4fv
-#define glUseProgram ctx->drv.pf_glUseProgram
+#define glProgramString ctx->glProgramString
+#define glBindProgram ctx->glBindProgram
+#define glDeletePrograms ctx->glDeletePrograms
+#define glGenPrograms ctx->glGenPrograms
+#define glProgramLocalParameter4fv ctx->glProgramLocalParameter4fv
+#define glUseProgram ctx->glUseProgram
#endif
/* This might not be defined on GLES */
diff --git a/cogl/cogl-pipeline-fragend-glsl.c b/cogl/cogl-pipeline-fragend-glsl.c
index 10ac6cb6..6f6fb3a9 100644
--- a/cogl/cogl-pipeline-fragend-glsl.c
+++ b/cogl/cogl-pipeline-fragend-glsl.c
@@ -47,12 +47,12 @@
#ifndef HAVE_COGL_GLES2
-#define glCreateShader ctx->drv.pf_glCreateShader
-#define glGetShaderiv ctx->drv.pf_glGetShaderiv
-#define glGetShaderInfoLog ctx->drv.pf_glGetShaderInfoLog
-#define glCompileShader ctx->drv.pf_glCompileShader
-#define glShaderSource ctx->drv.pf_glShaderSource
-#define glDeleteShader ctx->drv.pf_glDeleteShader
+#define glCreateShader ctx->glCreateShader
+#define glGetShaderiv ctx->glGetShaderiv
+#define glGetShaderInfoLog ctx->glGetShaderInfoLog
+#define glCompileShader ctx->glCompileShader
+#define glShaderSource ctx->glShaderSource
+#define glDeleteShader ctx->glDeleteShader
#endif /* HAVE_COGL_GLES2 */
diff --git a/cogl/cogl-pipeline-opengl.c b/cogl/cogl-pipeline-opengl.c
index d91c7061..51ac2f64 100644
--- a/cogl/cogl-pipeline-opengl.c
+++ b/cogl/cogl-pipeline-opengl.c
@@ -50,19 +50,17 @@
*/
#ifdef HAVE_COGL_GL
-#define glActiveTexture ctx->drv.pf_glActiveTexture
-#define glClientActiveTexture ctx->drv.pf_glClientActiveTexture
-#define glBlendFuncSeparate ctx->drv.pf_glBlendFuncSeparate
-#define glBlendEquation ctx->drv.pf_glBlendEquation
-#define glBlendColor ctx->drv.pf_glBlendColor
-#define glBlendEquationSeparate ctx->drv.pf_glBlendEquationSeparate
-
-#define glProgramString ctx->drv.pf_glProgramString
-#define glBindProgram ctx->drv.pf_glBindProgram
-#define glDeletePrograms ctx->drv.pf_glDeletePrograms
-#define glGenPrograms ctx->drv.pf_glGenPrograms
-#define glProgramLocalParameter4fv ctx->drv.pf_glProgramLocalParameter4fv
-#define glUseProgram ctx->drv.pf_glUseProgram
+#define glActiveTexture ctx->glActiveTexture
+#define glClientActiveTexture ctx->glClientActiveTexture
+#define glBlendEquation ctx->glBlendEquation
+#define glBlendColor ctx->glBlendColor
+
+#define glProgramString ctx->glProgramString
+#define glBindProgram ctx->glBindProgram
+#define glDeletePrograms ctx->glDeletePrograms
+#define glGenPrograms ctx->glGenPrograms
+#define glProgramLocalParameter4fv ctx->glProgramLocalParameter4fv
+#define glUseProgram ctx->glUseProgram
#endif
/* These aren't defined in the GLES headers */
@@ -519,9 +517,9 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
#elif defined (HAVE_COGL_GL)
gboolean have_blend_equation_seperate = FALSE;
gboolean have_blend_func_separate = FALSE;
- if (ctx->drv.pf_glBlendEquationSeparate) /* Only GL 2.0 + */
+ if (ctx->glBlendEquationSeparate) /* Only GL 2.0 + */
have_blend_equation_seperate = TRUE;
- if (ctx->drv.pf_glBlendFuncSeparate) /* Only GL 1.4 + */
+ if (ctx->glBlendFuncSeparate) /* Only GL 1.4 + */
have_blend_func_separate = TRUE;
#endif
@@ -546,8 +544,8 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
if (have_blend_equation_seperate &&
blend_state->blend_equation_rgb != blend_state->blend_equation_alpha)
- GE (glBlendEquationSeparate (blend_state->blend_equation_rgb,
- blend_state->blend_equation_alpha));
+ GE (ctx->glBlendEquationSeparate (blend_state->blend_equation_rgb,
+ blend_state->blend_equation_alpha));
else
GE (glBlendEquation (blend_state->blend_equation_rgb));
@@ -555,10 +553,10 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
(blend_state->blend_src_factor_rgb != blend_state->blend_src_factor_alpha ||
(blend_state->blend_src_factor_rgb !=
blend_state->blend_src_factor_alpha)))
- GE (glBlendFuncSeparate (blend_state->blend_src_factor_rgb,
- blend_state->blend_dst_factor_rgb,
- blend_state->blend_src_factor_alpha,
- blend_state->blend_dst_factor_alpha));
+ GE (ctx->glBlendFuncSeparate (blend_state->blend_src_factor_rgb,
+ blend_state->blend_dst_factor_rgb,
+ blend_state->blend_src_factor_alpha,
+ blend_state->blend_dst_factor_alpha));
else
#endif
GE (glBlendFunc (blend_state->blend_src_factor_rgb,
diff --git a/cogl/cogl-pipeline-progend-glsl.c b/cogl/cogl-pipeline-progend-glsl.c
index cc0f3dcb..7efbe258 100644
--- a/cogl/cogl-pipeline-progend-glsl.c
+++ b/cogl/cogl-pipeline-progend-glsl.c
@@ -44,17 +44,17 @@
#ifndef HAVE_COGL_GLES2
-#define glCreateProgram ctx->drv.pf_glCreateProgram
-#define glAttachShader ctx->drv.pf_glAttachShader
-#define glUseProgram ctx->drv.pf_glUseProgram
-#define glLinkProgram ctx->drv.pf_glLinkProgram
-#define glDeleteProgram ctx->drv.pf_glDeleteProgram
-#define glGetProgramInfoLog ctx->drv.pf_glGetProgramInfoLog
-#define glGetProgramiv ctx->drv.pf_glGetProgramiv
-#define glGetUniformLocation ctx->drv.pf_glGetUniformLocation
-#define glUniform1i ctx->drv.pf_glUniform1i
-#define glUniform1f ctx->drv.pf_glUniform1f
-#define glUniform4fv ctx->drv.pf_glUniform4fv
+#define glCreateProgram ctx->glCreateProgram
+#define glAttachShader ctx->glAttachShader
+#define glUseProgram ctx->glUseProgram
+#define glLinkProgram ctx->glLinkProgram
+#define glDeleteProgram ctx->glDeleteProgram
+#define glGetProgramInfoLog ctx->glGetProgramInfoLog
+#define glGetProgramiv ctx->glGetProgramiv
+#define glGetUniformLocation ctx->glGetUniformLocation
+#define glUniform1i ctx->glUniform1i
+#define glUniform1f ctx->glUniform1f
+#define glUniform4fv ctx->glUniform4fv
#else
diff --git a/cogl/cogl-pipeline-vertend-glsl.c b/cogl/cogl-pipeline-vertend-glsl.c
index 84a52434..44a747b8 100644
--- a/cogl/cogl-pipeline-vertend-glsl.c
+++ b/cogl/cogl-pipeline-vertend-glsl.c
@@ -43,12 +43,12 @@
#ifndef HAVE_COGL_GLES2
-#define glCreateShader ctx->drv.pf_glCreateShader
-#define glGetShaderiv ctx->drv.pf_glGetShaderiv
-#define glGetShaderInfoLog ctx->drv.pf_glGetShaderInfoLog
-#define glCompileShader ctx->drv.pf_glCompileShader
-#define glShaderSource ctx->drv.pf_glShaderSource
-#define glDeleteShader ctx->drv.pf_glDeleteShader
+#define glCreateShader ctx->glCreateShader
+#define glGetShaderiv ctx->glGetShaderiv
+#define glGetShaderInfoLog ctx->glGetShaderInfoLog
+#define glCompileShader ctx->glCompileShader
+#define glShaderSource ctx->glShaderSource
+#define glDeleteShader ctx->glDeleteShader
#endif /* HAVE_COGL_GLES2 */
diff --git a/cogl/cogl-program.c b/cogl/cogl-program.c
index 10d632c8..24a938d0 100644
--- a/cogl/cogl-program.c
+++ b/cogl/cogl-program.c
@@ -50,27 +50,27 @@ COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (program);
#ifndef HAVE_COGL_GLES2
-#define glGetUniformLocation ctx->drv.pf_glGetUniformLocation
-#define glUniform1f ctx->drv.pf_glUniform1f
-#define glUniform2f ctx->drv.pf_glUniform2f
-#define glUniform3f ctx->drv.pf_glUniform3f
-#define glUniform4f ctx->drv.pf_glUniform4f
-#define glUniform1fv ctx->drv.pf_glUniform1fv
-#define glUniform2fv ctx->drv.pf_glUniform2fv
-#define glUniform3fv ctx->drv.pf_glUniform3fv
-#define glUniform4fv ctx->drv.pf_glUniform4fv
-#define glUniform1i ctx->drv.pf_glUniform1i
-#define glUniform2i ctx->drv.pf_glUniform2i
-#define glUniform3i ctx->drv.pf_glUniform3i
-#define glUniform4i ctx->drv.pf_glUniform4i
-#define glUniform1iv ctx->drv.pf_glUniform1iv
-#define glUniform2iv ctx->drv.pf_glUniform2iv
-#define glUniform3iv ctx->drv.pf_glUniform3iv
-#define glUniform4iv ctx->drv.pf_glUniform4iv
-#define glUniformMatrix2fv ctx->drv.pf_glUniformMatrix2fv
-#define glUniformMatrix3fv ctx->drv.pf_glUniformMatrix3fv
-#define glUniformMatrix4fv ctx->drv.pf_glUniformMatrix4fv
-#define glProgramLocalParameter4fv ctx->drv.pf_glProgramLocalParameter4fv
+#define glGetUniformLocation ctx->glGetUniformLocation
+#define glUniform1f ctx->glUniform1f
+#define glUniform2f ctx->glUniform2f
+#define glUniform3f ctx->glUniform3f
+#define glUniform4f ctx->glUniform4f
+#define glUniform1fv ctx->glUniform1fv
+#define glUniform2fv ctx->glUniform2fv
+#define glUniform3fv ctx->glUniform3fv
+#define glUniform4fv ctx->glUniform4fv
+#define glUniform1i ctx->glUniform1i
+#define glUniform2i ctx->glUniform2i
+#define glUniform3i ctx->glUniform3i
+#define glUniform4i ctx->glUniform4i
+#define glUniform1iv ctx->glUniform1iv
+#define glUniform2iv ctx->glUniform2iv
+#define glUniform3iv ctx->glUniform3iv
+#define glUniform4iv ctx->glUniform4iv
+#define glUniformMatrix2fv ctx->glUniformMatrix2fv
+#define glUniformMatrix3fv ctx->glUniformMatrix3fv
+#define glUniformMatrix4fv ctx->glUniformMatrix4fv
+#define glProgramLocalParameter4fv ctx->glProgramLocalParameter4fv
#endif /* HAVE_COGL_GLES2 */
diff --git a/cogl/cogl-shader.c b/cogl/cogl-shader.c
index cb00836b..7b474bfc 100644
--- a/cogl/cogl-shader.c
+++ b/cogl/cogl-shader.c
@@ -37,16 +37,16 @@
#include <string.h>
#ifdef HAVE_COGL_GL
-#define glCreateShader ctx->drv.pf_glCreateShader
-#define glGetShaderiv ctx->drv.pf_glGetShaderiv
-#define glGetShaderInfoLog ctx->drv.pf_glGetShaderInfoLog
-#define glCompileShader ctx->drv.pf_glCompileShader
-#define glShaderSource ctx->drv.pf_glShaderSource
-#define glDeleteShader ctx->drv.pf_glDeleteShader
-#define glProgramString ctx->drv.pf_glProgramString
-#define glBindProgram ctx->drv.pf_glBindProgram
-#define glDeletePrograms ctx->drv.pf_glDeletePrograms
-#define glGenPrograms ctx->drv.pf_glGenPrograms
+#define glCreateShader ctx->glCreateShader
+#define glGetShaderiv ctx->glGetShaderiv
+#define glGetShaderInfoLog ctx->glGetShaderInfoLog
+#define glCompileShader ctx->glCompileShader
+#define glShaderSource ctx->glShaderSource
+#define glDeleteShader ctx->glDeleteShader
+#define glProgramString ctx->glProgramString
+#define glBindProgram ctx->glBindProgram
+#define glDeletePrograms ctx->glDeletePrograms
+#define glGenPrograms ctx->glGenPrograms
#define GET_CONTEXT _COGL_GET_CONTEXT
#else
#define GET_CONTEXT(CTXVAR,RETVAL) G_STMT_START { } G_STMT_END
diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c
index 57a193a0..86ccae10 100644
--- a/cogl/cogl-texture-2d.c
+++ b/cogl/cogl-texture-2d.c
@@ -531,7 +531,7 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
while ((gl_error = glGetError ()) != GL_NO_ERROR)
;
- ctx->drv.pf_glEGLImageTargetTexture2D (GL_TEXTURE_2D, image);
+ ctx->glEGLImageTargetTexture2D (GL_TEXTURE_2D, image);
if (glGetError () != GL_NO_ERROR)
{
g_set_error (error,
diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c
index 6b89887d..3803c2d8 100644
--- a/cogl/cogl-texture-3d.c
+++ b/cogl/cogl-texture-3d.c
@@ -49,8 +49,8 @@
#define GL_TEXTURE_WRAP_R 0x8072
#endif
-#define glTexImage3D ctx->drv.pf_glTexImage3D
-#define glTexSubImage3D ctx->drv.pf_glTexSubImage3D
+#define glTexImage3D ctx->glTexImage3D
+#define glTexSubImage3D ctx->glTexSubImage3D
static void _cogl_texture_3d_free (CoglTexture3D *tex_3d);
diff --git a/cogl/driver/gl/cogl-context-driver-gl.h b/cogl/driver/gl/cogl-context-driver-gl.h
index 2d8e5213..48f9fc3a 100644
--- a/cogl/driver/gl/cogl-context-driver-gl.h
+++ b/cogl/driver/gl/cogl-context-driver-gl.h
@@ -3,7 +3,7 @@
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
- * Copyright (C) 2007,2008,2009 Intel Corporation.
+ * Copyright (C) 2007,2008,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
@@ -26,28 +26,10 @@
#include "cogl.h"
-#ifndef APIENTRY
-#define APIENTRY
-#endif
-
-#define COGL_FEATURE_BEGIN(a, b, c, d, e, f, g)
-
-#define COGL_FEATURE_FUNCTION(ret, name, args) \
- ret (APIENTRY * pf_ ## name) args;
-
-#define COGL_FEATURE_END()
-
typedef struct _CoglContextDriver
{
- /* This defines a list of function pointers */
-#include "cogl-feature-functions-gl.h"
-
GLint gl_max_program_temoraries_arb;
} CoglContextDriver;
-#undef COGL_FEATURE_BEGIN
-#undef COGL_FEATURE_FUNCTION
-#undef COGL_FEATURE_END
-
#endif /* __COGL_CONTEXT_DRIVER_H */
diff --git a/cogl/driver/gl/cogl-feature-functions-gl.h b/cogl/driver/gl/cogl-feature-functions-gl.h
deleted file mode 100644
index 734c76d9..00000000
--- a/cogl/driver/gl/cogl-feature-functions-gl.h
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * 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/>.
- *
- *
- */
-
-/* This is included multiple times with different definitions for
- these macros */
-
-COGL_FEATURE_BEGIN (offscreen, 255, 255,
- /* for some reason the ARB version of this
- extension doesn't have an ARB suffix for the
- functions */
- "ARB:\0EXT\0",
- "framebuffer_object\0",
- COGL_FEATURE_OFFSCREEN,
- 0)
-COGL_FEATURE_FUNCTION (void, glGenRenderbuffers,
- (GLsizei n,
- GLuint *renderbuffers))
-COGL_FEATURE_FUNCTION (void, glDeleteRenderbuffers,
- (GLsizei n,
- const GLuint *renderbuffers))
-COGL_FEATURE_FUNCTION (void, glBindRenderbuffer,
- (GLenum target,
- GLuint renderbuffer))
-COGL_FEATURE_FUNCTION (void, glRenderbufferStorage,
- (GLenum target,
- GLenum internalformat,
- GLsizei width,
- GLsizei height))
-COGL_FEATURE_FUNCTION (void, glGenFramebuffers,
- (GLsizei n,
- GLuint *framebuffers))
-COGL_FEATURE_FUNCTION (void, glBindFramebuffer,
- (GLenum target,
- GLuint framebuffer))
-COGL_FEATURE_FUNCTION (void, glFramebufferTexture2D,
- (GLenum target,
- GLenum attachment,
- GLenum textarget,
- GLuint texture,
- GLint level))
-COGL_FEATURE_FUNCTION (void, glFramebufferRenderbuffer,
- (GLenum target,
- GLenum attachment,
- GLenum renderbuffertarget,
- GLuint renderbuffer))
-COGL_FEATURE_FUNCTION (GLenum, glCheckFramebufferStatus,
- (GLenum target))
-COGL_FEATURE_FUNCTION (void, glDeleteFramebuffers,
- (GLsizei n,
- const GLuint *framebuffers))
-COGL_FEATURE_FUNCTION (void, glGenerateMipmap,
- (GLenum target))
-COGL_FEATURE_FUNCTION (void, glGetFramebufferAttachmentParameteriv,
- (GLenum target,
- GLenum attachment,
- GLenum pname,
- GLint *params))
-COGL_FEATURE_END ()
-
-COGL_FEATURE_BEGIN (offscreen_blit, 255, 255,
- "EXT\0",
- "framebuffer_blit\0",
- COGL_FEATURE_OFFSCREEN_BLIT,
- 0)
-COGL_FEATURE_FUNCTION (void, glBlitFramebuffer,
- (GLint srcX0,
- GLint srcY0,
- GLint srcX1,
- GLint srcY1,
- GLint dstX0,
- GLint dstY0,
- GLint dstX1,
- GLint dstY1,
- GLbitfield mask,
- GLenum filter))
-COGL_FEATURE_END ()
-
-COGL_FEATURE_BEGIN (offscreen_multisample, 255, 255,
- "EXT\0",
- "framebuffer_multisample\0",
- COGL_FEATURE_OFFSCREEN_MULTISAMPLE,
- 0)
-COGL_FEATURE_FUNCTION (void, glRenderbufferStorageMultisample,
- (GLenum target,
- GLsizei samples,
- GLenum internalformat,
- GLsizei width,
- GLsizei height))
-COGL_FEATURE_END ()
-
-COGL_FEATURE_BEGIN (read_pixels_async, 2, 1,
- "EXT\0",
- "pixel_buffer_object\0",
- COGL_FEATURE_PBOS,
- 0)
-COGL_FEATURE_END ()
-
-/* ARB_fragment_program */
-COGL_FEATURE_BEGIN (arbfp, 255, 255,
- "ARB\0",
- "fragment_program\0",
- COGL_FEATURE_SHADERS_ARBFP,
- 0)
-COGL_FEATURE_FUNCTION (void, glGenPrograms,
- (GLsizei n,
- GLuint *programs))
-COGL_FEATURE_FUNCTION (void, glDeletePrograms,
- (GLsizei n,
- GLuint *programs))
-COGL_FEATURE_FUNCTION (void, glBindProgram,
- (GLenum target,
- GLuint program))
-COGL_FEATURE_FUNCTION (void, glProgramString,
- (GLenum target,
- GLenum format,
- GLsizei len,
- const void *program))
-COGL_FEATURE_FUNCTION (void, glProgramLocalParameter4fv,
- (GLenum target,
- GLuint index,
- GLfloat *params))
-COGL_FEATURE_END ()
-
-/* The function names in OpenGL 2.0 are different so we can't easily
- just check for GL 2.0 */
-COGL_FEATURE_BEGIN (shaders_glsl, 2, 0,
- "\0",
- "\0",
- COGL_FEATURE_SHADERS_GLSL,
- 0)
-COGL_FEATURE_FUNCTION (GLuint, glCreateProgram,
- (void))
-COGL_FEATURE_FUNCTION (GLuint, glCreateShader,
- (GLenum shaderType))
-COGL_FEATURE_FUNCTION (void, glShaderSource,
- (GLuint shader,
- GLsizei count,
- const GLchar **string,
- const GLint *length))
-COGL_FEATURE_FUNCTION (void, glCompileShader,
- (GLuint shader))
-COGL_FEATURE_FUNCTION (void, glDeleteShader,
- (GLuint shader))
-COGL_FEATURE_FUNCTION (void, glAttachShader,
- (GLuint program,
- GLuint shader))
-COGL_FEATURE_FUNCTION (void, glLinkProgram,
- (GLuint program))
-COGL_FEATURE_FUNCTION (void, glUseProgram,
- (GLuint program))
-COGL_FEATURE_FUNCTION (GLint, glGetUniformLocation,
- (GLuint program,
- const GLchar *name))
-COGL_FEATURE_FUNCTION (void, glDeleteProgram,
- (GLuint program))
-COGL_FEATURE_FUNCTION (void, glGetShaderInfoLog,
- (GLuint shader,
- GLsizei maxLength,
- GLsizei *length,
- GLchar *infoLog))
-COGL_FEATURE_FUNCTION (void, glGetShaderiv,
- (GLuint shader,
- GLenum pname,
- GLint *params))
-
-COGL_FEATURE_FUNCTION (void, glVertexAttribPointer,
- (GLuint index,
- GLint size,
- GLenum type,
- GLboolean normalized,
- GLsizei stride,
- const GLvoid *pointer))
-COGL_FEATURE_FUNCTION (void, glEnableVertexAttribArray,
- (GLuint index))
-COGL_FEATURE_FUNCTION (void, glDisableVertexAttribArray,
- (GLuint index))
-
-COGL_FEATURE_FUNCTION (void, glUniform1f,
- (GLint location,
- GLfloat v0))
-COGL_FEATURE_FUNCTION (void, glUniform2f,
- (GLint location,
- GLfloat v0,
- GLfloat v1))
-COGL_FEATURE_FUNCTION (void, glUniform3f,
- (GLint location,
- GLfloat v0,
- GLfloat v1,
- GLfloat v2))
-COGL_FEATURE_FUNCTION (void, glUniform4f,
- (GLint location,
- GLfloat v0,
- GLfloat v1,
- GLfloat v2,
- GLfloat v3))
-COGL_FEATURE_FUNCTION (void, glUniform1fv,
- (GLint location,
- GLsizei count,
- const GLfloat * value))
-COGL_FEATURE_FUNCTION (void, glUniform2fv,
- (GLint location,
- GLsizei count,
- const GLfloat * value))
-COGL_FEATURE_FUNCTION (void, glUniform3fv,
- (GLint location,
- GLsizei count,
- const GLfloat * value))
-COGL_FEATURE_FUNCTION (void, glUniform4fv,
- (GLint location,
- GLsizei count,
- const GLfloat * value))
-COGL_FEATURE_FUNCTION (void, glUniform1i,
- (GLint location,
- GLint v0))
-COGL_FEATURE_FUNCTION (void, glUniform2i,
- (GLint location,
- GLint v0,
- GLint v1))
-COGL_FEATURE_FUNCTION (void, glUniform3i,
- (GLint location,
- GLint v0,
- GLint v1,
- GLint v2))
-COGL_FEATURE_FUNCTION (void, glUniform4i,
- (GLint location,
- GLint v0,
- GLint v1,
- GLint v2,
- GLint v3))
-COGL_FEATURE_FUNCTION (void, glUniform1iv,
- (GLint location,
- GLsizei count,
- const GLint * value))
-COGL_FEATURE_FUNCTION (void, glUniform2iv,
- (GLint location,
- GLsizei count,
- const GLint * value))
-COGL_FEATURE_FUNCTION (void, glUniform3iv,
- (GLint location,
- GLsizei count,
- const GLint * value))
-COGL_FEATURE_FUNCTION (void, glUniform4iv,
- (GLint location,
- GLsizei count,
- const GLint * value))
-COGL_FEATURE_FUNCTION (void, glUniformMatrix2fv,
- (GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat *value))
-COGL_FEATURE_FUNCTION (void, glUniformMatrix3fv,
- (GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat *value))
-COGL_FEATURE_FUNCTION (void, glUniformMatrix4fv,
- (GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat *value))
-
-COGL_FEATURE_FUNCTION (void, glGetProgramiv,
- (GLuint program,
- GLenum pname,
- GLint *params))
-
-COGL_FEATURE_FUNCTION (void, glGetProgramInfoLog,
- (GLuint program,
- GLsizei bufSize,
- GLsizei *length,
- GLchar *infoLog))
-
-COGL_FEATURE_END ()
-
-COGL_FEATURE_BEGIN (vbos, 1, 5,
- "ARB\0",
- "vertex_buffer_object\0",
- COGL_FEATURE_VBOS |
- COGL_FEATURE_MAP_BUFFER_FOR_READ |
- COGL_FEATURE_MAP_BUFFER_FOR_WRITE,
- 0)
-COGL_FEATURE_FUNCTION (void, glGenBuffers,
- (GLuint n,
- GLuint *buffers))
-COGL_FEATURE_FUNCTION (void, glBindBuffer,
- (GLenum target,
- GLuint buffer))
-COGL_FEATURE_FUNCTION (void, glBufferData,
- (GLenum target,
- GLsizeiptr size,
- const GLvoid *data,
- GLenum usage))
-COGL_FEATURE_FUNCTION (void, glBufferSubData,
- (GLenum target,
- GLintptr offset,
- GLsizeiptr size,
- const GLvoid *data))
-COGL_FEATURE_FUNCTION (void *, glMapBuffer,
- (GLenum target,
- GLenum access))
-COGL_FEATURE_FUNCTION (GLboolean, glUnmapBuffer,
- (GLenum target))
-COGL_FEATURE_FUNCTION (void, glDeleteBuffers,
- (GLsizei n,
- const GLuint *buffers))
-COGL_FEATURE_END ()
-
-COGL_FEATURE_BEGIN (texture_rectangle, 255, 255,
- "ARB\0",
- "texture_rectangle\0",
- COGL_FEATURE_TEXTURE_RECTANGLE,
- 0)
-COGL_FEATURE_END ()
-
-/* Cogl requires OpenGL 1.2 so we assume these functions are always
- available and don't bother setting any feature flags. We still have
- to fetch the function pointers though because under Windows you can
- not call any function defined after GL 1.1 directly */
-COGL_FEATURE_BEGIN (in_1_2, 1, 2,
- "\0",
- "\0",
- 0,
- 0)
-COGL_FEATURE_FUNCTION (void, glDrawRangeElements,
- (GLenum mode,
- GLuint start,
- GLuint end,
- GLsizei count,
- GLenum type,
- const GLvoid *indices))
-COGL_FEATURE_FUNCTION (void, glBlendEquation,
- (GLenum mode))
-COGL_FEATURE_FUNCTION (void, glBlendColor,
- (GLclampf red,
- GLclampf green,
- GLclampf blue,
- GLclampf alpha))
-COGL_FEATURE_END ()
-
-COGL_FEATURE_BEGIN (texture_3d, 1, 2,
- "\0",
- "\0",
- COGL_FEATURE_TEXTURE_3D,
- 0)
-COGL_FEATURE_FUNCTION (void, glTexImage3D,
- (GLenum target, GLint level,
- GLint internalFormat,
- GLsizei width, GLsizei height,
- GLsizei depth, GLint border,
- GLenum format, GLenum type,
- const GLvoid *pixels))
-COGL_FEATURE_FUNCTION (void, glTexSubImage3D,
- (GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint zoffset, GLsizei width,
- GLsizei height, GLsizei depth,
- GLenum format,
- GLenum type, const GLvoid *pixels))
-COGL_FEATURE_END ()
-
-/* Available in GL 1.3 or the multitexture extension. These are
- required */
-COGL_FEATURE_BEGIN (multitexture, 1, 3,
- "ARB\0",
- "multitexture\0",
- 0,
- 0)
-COGL_FEATURE_FUNCTION (void, glActiveTexture,
- (GLenum texture))
-COGL_FEATURE_FUNCTION (void, glClientActiveTexture,
- (GLenum texture))
-COGL_FEATURE_END ()
-
-/* Optional, declared in 1.4 */
-COGL_FEATURE_BEGIN (blend_func_separate, 1, 4,
- "EXT\0",
- "blend_func_separate\0",
- 0,
- 0)
-COGL_FEATURE_FUNCTION (void, glBlendFuncSeparate,
- (GLenum srcRGB,
- GLenum dstRGB,
- GLenum srcAlpha,
- GLenum dstAlpha))
-COGL_FEATURE_END ()
-
-/* Optional, declared in 2.0 */
-COGL_FEATURE_BEGIN (blend_equation_separate, 2, 0,
- "EXT\0",
- "blend_equation_separate\0",
- 0,
- 0)
-COGL_FEATURE_FUNCTION (void, glBlendEquationSeparate,
- (GLenum modeRGB,
- GLenum modeAlpha))
-COGL_FEATURE_END ()
-
-COGL_FEATURE_BEGIN (point_sprites, 2, 0,
- "ARB\0",
- "point_sprite\0",
- COGL_FEATURE_POINT_SPRITE,
- 0)
-COGL_FEATURE_END ()
-COGL_FEATURE_BEGIN (EGL_image, 255, 255,
- "OES\0",
- "EGL_image\0",
- 0,
- COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE)
-COGL_FEATURE_FUNCTION (void, glEGLImageTargetTexture2D,
- (GLenum target,
- GLeglImageOES image))
-COGL_FEATURE_FUNCTION (void, glEGLImageTargetRenderbufferStorage,
- (GLenum target,
- GLeglImageOES image))
-COGL_FEATURE_END ()
diff --git a/cogl/driver/gl/cogl-gl.c b/cogl/driver/gl/cogl-gl.c
index a0c01981..906d7dad 100644
--- a/cogl/driver/gl/cogl-gl.c
+++ b/cogl/driver/gl/cogl-gl.c
@@ -117,37 +117,6 @@ _cogl_gl_check_version (GError **error)
return TRUE;
}
-/* Define a set of arrays containing the functions required from GL
- for each feature */
-#define COGL_FEATURE_BEGIN(name, min_gl_major, min_gl_minor, \
- namespaces, extension_names, \
- feature_flags, feature_flags_private) \
- static const CoglFeatureFunction cogl_feature_ ## name ## _funcs[] = {
-#define COGL_FEATURE_FUNCTION(ret, name, args) \
- { G_STRINGIFY (name), G_STRUCT_OFFSET (CoglContext, drv.pf_ ## name) },
-#define COGL_FEATURE_END() \
- { NULL, 0 }, \
- };
-#include "cogl-feature-functions-gl.h"
-
-/* Define an array of features */
-#undef COGL_FEATURE_BEGIN
-#define COGL_FEATURE_BEGIN(name, min_gl_major, min_gl_minor, \
- namespaces, extension_names, \
- feature_flags, feature_flags_private) \
- { min_gl_major, min_gl_minor, namespaces, \
- extension_names, feature_flags, feature_flags_private, 0, \
- cogl_feature_ ## name ## _funcs },
-#undef COGL_FEATURE_FUNCTION
-#define COGL_FEATURE_FUNCTION(ret, name, args)
-#undef COGL_FEATURE_END
-#define COGL_FEATURE_END()
-
-static const CoglFeatureData cogl_feature_data[] =
- {
-#include "cogl-feature-functions-gl.h"
- };
-
/* Query the GL extensions and lookup the corresponding function
* pointers. Theoretically the list of extensions can change for
* different GL contexts so it is the winsys backend's responsiblity
@@ -161,7 +130,6 @@ _cogl_gl_update_features (CoglContext *context)
int max_clip_planes = 0;
int num_stencil_bits = 0;
int gl_major = 0, gl_minor = 0;
- int i;
COGL_NOTE (WINSYS,
"Checking features\n"
@@ -182,6 +150,12 @@ _cogl_gl_update_features (CoglContext *context)
gl_extensions = (const char *)glGetString (GL_EXTENSIONS);
+ _cogl_feature_check_ext_functions (context,
+ gl_major,
+ gl_minor,
+ gl_extensions,
+ 0 /* gles_version */);
+
if (COGL_CHECK_GL_VERSION (gl_major, gl_minor, 2, 0) ||
_cogl_check_extension ("GL_ARB_texture_non_power_of_two", gl_extensions))
{
@@ -207,16 +181,38 @@ _cogl_gl_update_features (CoglContext *context)
if (max_clip_planes >= 4)
flags |= COGL_FEATURE_FOUR_CLIP_PLANES;
- for (i = 0; i < G_N_ELEMENTS (cogl_feature_data); i++)
- if (_cogl_feature_check (_cogl_context_get_winsys (context),
- "GL", cogl_feature_data + i,
- gl_major, gl_minor,
- gl_extensions,
- context))
- {
- private_flags |= cogl_feature_data[i].feature_flags_private;
- flags |= cogl_feature_data[i].feature_flags;
- }
+ if (context->glGenRenderbuffers)
+ flags |= COGL_FEATURE_OFFSCREEN;
+
+ if (context->glBlitFramebuffer)
+ flags |= COGL_FEATURE_OFFSCREEN_BLIT;
+
+ if (context->glRenderbufferStorageMultisample)
+ flags |= COGL_FEATURE_OFFSCREEN_MULTISAMPLE;
+
+ if (COGL_CHECK_GL_VERSION (gl_major, gl_minor, 2, 1) ||
+ _cogl_check_extension ("GL_EXT_pixel_buffer_object", gl_extensions))
+ flags |= COGL_FEATURE_PBOS;
+
+ if (context->glGenPrograms)
+ flags |= COGL_FEATURE_SHADERS_ARBFP;
+
+ if (context->glCreateProgram)
+ flags |= COGL_FEATURE_SHADERS_GLSL;
+
+ if (context->glGenBuffers)
+ flags |= (COGL_FEATURE_VBOS |
+ COGL_FEATURE_MAP_BUFFER_FOR_READ |
+ COGL_FEATURE_MAP_BUFFER_FOR_WRITE);
+
+ if (_cogl_check_extension ("GL_ARB_texture_rectangle", gl_extensions))
+ flags |= COGL_FEATURE_TEXTURE_RECTANGLE;
+
+ if (context->glTexImage3D)
+ flags |= COGL_FEATURE_TEXTURE_3D;
+
+ if (context->glEGLImageTargetTexture2D)
+ private_flags |= COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE;
/* Cache features */
context->private_feature_flags |= private_flags;
diff --git a/cogl/driver/gl/cogl-texture-driver-gl.c b/cogl/driver/gl/cogl-texture-driver-gl.c
index 72fd5742..d5e71262 100644
--- a/cogl/driver/gl/cogl-texture-driver-gl.c
+++ b/cogl/driver/gl/cogl-texture-driver-gl.c
@@ -46,8 +46,8 @@
#include <stdlib.h>
#include <math.h>
-#define glGenerateMipmap ctx->drv.pf_glGenerateMipmap
-#define glTexImage3D ctx->drv.pf_glTexImage3D
+#define glGenerateMipmap ctx->glGenerateMipmap
+#define glTexImage3D ctx->glTexImage3D
void
_cogl_texture_driver_gen (GLenum gl_target,
diff --git a/cogl/driver/gles/cogl-context-driver-gles.h b/cogl/driver/gles/cogl-context-driver-gles.h
index ca3b1d4b..4e3be2b3 100644
--- a/cogl/driver/gles/cogl-context-driver-gles.h
+++ b/cogl/driver/gles/cogl-context-driver-gles.h
@@ -3,7 +3,7 @@
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
- * Copyright (C) 2007,2008,2009 Intel Corporation.
+ * Copyright (C) 2007,2008,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
@@ -26,27 +26,9 @@
#include "cogl.h"
-#ifndef APIENTRY
-#define APIENTRY
-#endif
-
-#define COGL_FEATURE_BEGIN(a, b, c, d, e, f, g)
-
-#define COGL_FEATURE_FUNCTION(ret, name, args) \
- ret (APIENTRY * pf_ ## name) args;
-
-#define COGL_FEATURE_END()
-
typedef struct _CoglContextDriver
{
- /* This defines a list of function pointers */
-#include "cogl-feature-functions-gles.h"
-
} CoglContextDriver;
-#undef COGL_FEATURE_BEGIN
-#undef COGL_FEATURE_FUNCTION
-#undef COGL_FEATURE_END
-
#endif /* __COGL_CONTEXT_DRIVER_H */
diff --git a/cogl/driver/gles/cogl-feature-functions-gles.h b/cogl/driver/gles/cogl-feature-functions-gles.h
deleted file mode 100644
index 8282e1b9..00000000
--- a/cogl/driver/gles/cogl-feature-functions-gles.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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/>.
- *
- *
- */
-
-/* This is included multiple times with different definitions for
- these macros */
-
-COGL_FEATURE_BEGIN (offscreen, 255, 255,
- "OES\0",
- "framebuffer_object\0",
- COGL_FEATURE_OFFSCREEN,
- 0)
-COGL_FEATURE_FUNCTION (void, glGenRenderbuffers,
- (GLsizei n,
- GLuint *renderbuffers))
-COGL_FEATURE_FUNCTION (void, glDeleteRenderbuffers,
- (GLsizei n,
- const GLuint *renderbuffers))
-COGL_FEATURE_FUNCTION (void, glBindRenderbuffer,
- (GLenum target,
- GLuint renderbuffer))
-COGL_FEATURE_FUNCTION (void, glRenderbufferStorage,
- (GLenum target,
- GLenum internalformat,
- GLsizei width,
- GLsizei height))
-COGL_FEATURE_FUNCTION (void, glGenFramebuffers,
- (GLsizei n,
- GLuint *framebuffers))
-COGL_FEATURE_FUNCTION (void, glBindFramebuffer,
- (GLenum target,
- GLuint framebuffer))
-COGL_FEATURE_FUNCTION (void, glFramebufferTexture2D,
- (GLenum target,
- GLenum attachment,
- GLenum textarget,
- GLuint texture,
- GLint level))
-COGL_FEATURE_FUNCTION (void, glFramebufferRenderbuffer,
- (GLenum target,
- GLenum attachment,
- GLenum renderbuffertarget,
- GLuint renderbuffer))
-COGL_FEATURE_FUNCTION (GLenum, glCheckFramebufferStatus,
- (GLenum target))
-COGL_FEATURE_FUNCTION (void, glDeleteFramebuffers,
- (GLsizei n,
- const GLuint *framebuffers))
-COGL_FEATURE_FUNCTION (void, glGenerateMipmap,
- (GLenum target))
-COGL_FEATURE_FUNCTION (void, glGetFramebufferAttachmentParameteriv,
- (GLenum target,
- GLenum attachment,
- GLenum pname,
- GLint *params))
-COGL_FEATURE_END ()
-
-COGL_FEATURE_BEGIN (offscreen_blit, 255, 255,
- "ANGLE\0",
- "framebuffer_blit\0",
- COGL_FEATURE_OFFSCREEN_BLIT,
- 0)
-COGL_FEATURE_FUNCTION (void, glBlitFramebuffer,
- (GLint srcX0,
- GLint srcY0,
- GLint srcX1,
- GLint srcY1,
- GLint dstX0,
- GLint dstY0,
- GLint dstX1,
- GLint dstY1,
- GLbitfield mask,
- GLenum filter))
-COGL_FEATURE_END ()
-
-COGL_FEATURE_BEGIN (element_index_uint, 255, 255,
- "OES\0",
- "element_index_uint\0",
- COGL_FEATURE_UNSIGNED_INT_INDICES,
- 0)
-COGL_FEATURE_END ()
-
-COGL_FEATURE_BEGIN (texture_npot, 255, 255,
- "OES\0IMG\0",
- "texture_npot\0",
- COGL_FEATURE_TEXTURE_NPOT |
- COGL_FEATURE_TEXTURE_NPOT_BASIC |
- COGL_FEATURE_TEXTURE_NPOT_MIPMAP |
- COGL_FEATURE_TEXTURE_NPOT_REPEAT,
- 0)
-COGL_FEATURE_END ()
-
-COGL_FEATURE_BEGIN (texture_3d, 1, 2,
- "OES\0",
- "texture_3D\0",
- COGL_FEATURE_TEXTURE_3D,
- 0)
-COGL_FEATURE_FUNCTION (void, glTexImage3D,
- (GLenum target, GLint level,
- GLint internalFormat,
- GLsizei width, GLsizei height,
- GLsizei depth, GLint border,
- GLenum format, GLenum type,
- const GLvoid *pixels))
-COGL_FEATURE_FUNCTION (void, glTexSubImage3D,
- (GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, const GLvoid* pixels))
-COGL_FEATURE_END ()
-
-COGL_FEATURE_BEGIN (map_buffer, 255, 255,
- "OES\0",
- "mapbuffer\0",
- COGL_FEATURE_MAP_BUFFER_FOR_WRITE,
- 0)
-COGL_FEATURE_FUNCTION (void *, glMapBuffer,
- (GLenum target,
- GLenum access))
-COGL_FEATURE_FUNCTION (GLboolean, glUnmapBuffer,
- (GLenum target))
-COGL_FEATURE_END ()
-COGL_FEATURE_BEGIN (EGL_image, 255, 255,
- "OES\0",
- "EGL_image\0",
- 0,
- COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE)
-COGL_FEATURE_FUNCTION (void, glEGLImageTargetTexture2D,
- (GLenum target,
- GLeglImageOES image))
-COGL_FEATURE_FUNCTION (void, glEGLImageTargetRenderbufferStorage,
- (GLenum target,
- GLeglImageOES image))
-COGL_FEATURE_END ()
diff --git a/cogl/driver/gles/cogl-gles.c b/cogl/driver/gles/cogl-gles.c
index 2013d3e0..bf11194a 100644
--- a/cogl/driver/gles/cogl-gles.c
+++ b/cogl/driver/gles/cogl-gles.c
@@ -39,37 +39,6 @@ _cogl_gl_check_version (GError **error)
return TRUE;
}
-/* Define a set of arrays containing the functions required from GL
- for each feature */
-#define COGL_FEATURE_BEGIN(name, min_gl_major, min_gl_minor, \
- namespaces, extension_names, \
- feature_flags, feature_flags_private) \
- static const CoglFeatureFunction cogl_feature_ ## name ## _funcs[] = {
-#define COGL_FEATURE_FUNCTION(ret, name, args) \
- { G_STRINGIFY (name), G_STRUCT_OFFSET (CoglContext, drv.pf_ ## name) },
-#define COGL_FEATURE_END() \
- { NULL, 0 }, \
- };
-#include "cogl-feature-functions-gles.h"
-
-/* Define an array of features */
-#undef COGL_FEATURE_BEGIN
-#define COGL_FEATURE_BEGIN(name, min_gl_major, min_gl_minor, \
- namespaces, extension_names, \
- feature_flags, feature_flags_private) \
- { min_gl_major, min_gl_minor, namespaces, \
- extension_names, feature_flags, feature_flags_private, 0, \
- cogl_feature_ ## name ## _funcs },
-#undef COGL_FEATURE_FUNCTION
-#define COGL_FEATURE_FUNCTION(ret, name, args)
-#undef COGL_FEATURE_END
-#define COGL_FEATURE_END()
-
-static const CoglFeatureData cogl_feature_data[] =
- {
-#include "cogl-feature-functions-gles.h"
- };
-
/* Query the GL extensions and lookup the corresponding function
* pointers. Theoretically the list of extensions can change for
* different GL contexts so it is the winsys backend's responsiblity
@@ -84,7 +53,6 @@ _cogl_gl_update_features (CoglContext *context)
int max_clip_planes = 0;
#endif
int num_stencil_bits = 0;
- int i;
COGL_NOTE (WINSYS,
"Checking features\n"
@@ -99,6 +67,16 @@ _cogl_gl_update_features (CoglContext *context)
gl_extensions = (const char*) glGetString (GL_EXTENSIONS);
+ _cogl_feature_check_ext_functions (context,
+ -1 /* GL major version */,
+ -1 /* GL minor version */,
+ gl_extensions,
+#ifdef HAVE_COGL_GLES2
+ COGL_EXT_IN_GLES2
+#else
+ COGL_EXT_IN_GLES
+#endif
+ );
GE( glGetIntegerv (GL_STENCIL_BITS, &num_stencil_bits) );
/* We need at least three stencil bits to combine clips */
@@ -124,16 +102,32 @@ _cogl_gl_update_features (CoglContext *context)
/* Both GLES 1.1 and GLES 2.0 support point sprites in core */
flags |= COGL_FEATURE_POINT_SPRITE;
- for (i = 0; i < G_N_ELEMENTS (cogl_feature_data); i++)
- if (_cogl_feature_check (_cogl_context_get_winsys (context),
- "GL", cogl_feature_data + i,
- 0, 0,
- gl_extensions,
- context))
- {
- private_flags |= cogl_feature_data[i].feature_flags_private;
- flags |= cogl_feature_data[i].feature_flags;
- }
+ if (context->glGenRenderbuffers)
+ flags |= COGL_FEATURE_OFFSCREEN;
+
+ if (context->glBlitFramebuffer)
+ flags |= COGL_FEATURE_OFFSCREEN_BLIT;
+
+ if (_cogl_check_extension ("GL_OES_element_index_uint", gl_extensions))
+ flags |= COGL_FEATURE_UNSIGNED_INT_INDICES;
+
+ if (_cogl_check_extension ("GL_OES_texture_npot", gl_extensions) ||
+ _cogl_check_extension ("GL_IMG_texture_npot", gl_extensions))
+ flags |= (COGL_FEATURE_TEXTURE_NPOT |
+ COGL_FEATURE_TEXTURE_NPOT_BASIC |
+ COGL_FEATURE_TEXTURE_NPOT_MIPMAP |
+ COGL_FEATURE_TEXTURE_NPOT_REPEAT);
+
+ if (context->glTexImage3D)
+ flags |= COGL_FEATURE_TEXTURE_3D;
+
+ if (context->glMapBuffer)
+ /* The GL_OES_mapbuffer extension doesn't support mapping for
+ read */
+ flags |= COGL_FEATURE_MAP_BUFFER_FOR_WRITE;
+
+ if (context->glEGLImageTargetTexture2D)
+ flags |= COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE;
/* Cache features */
context->private_feature_flags |= private_flags;
diff --git a/cogl/driver/gles/cogl-texture-driver-gles.c b/cogl/driver/gles/cogl-texture-driver-gles.c
index bf67d835..a8fecbd8 100644
--- a/cogl/driver/gles/cogl-texture-driver-gles.c
+++ b/cogl/driver/gles/cogl-texture-driver-gles.c
@@ -46,8 +46,8 @@
#include <stdlib.h>
#include <math.h>
-#define glTexImage3D ctx->drv.pf_glTexImage3D
-#define glTexSubImage3D ctx->drv.pf_glTexSubImage3D
+#define glTexImage3D ctx->glTexImage3D
+#define glTexSubImage3D ctx->glTexSubImage3D
#ifndef GL_TEXTURE_3D
#define GL_TEXTURE_3D 0x806F
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index e06c80be..5597cd12 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -197,7 +197,7 @@ typedef struct _CoglTexturePixmapEGL
#undef COGL_WINSYS_FEATURE_BEGIN
#define COGL_WINSYS_FEATURE_BEGIN(name, namespaces, extension_names, \
egl_private_flags) \
- { 255, 255, namespaces, extension_names, \
+ { 255, 255, 0, namespaces, extension_names, \
0, egl_private_flags, \
0, \
cogl_egl_feature_ ## name ## _funcs },
@@ -353,7 +353,7 @@ check_egl_extensions (CoglRenderer *renderer)
egl_renderer->private_features = 0;
for (i = 0; i < G_N_ELEMENTS (winsys_feature_data); i++)
if (_cogl_feature_check (winsys,
- "EGL", winsys_feature_data + i, 0, 0,
+ "EGL", winsys_feature_data + i, 0, 0, 0,
egl_extensions,
egl_renderer))
{
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index d45015f6..1b41fde5 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -123,7 +123,7 @@ typedef struct _CoglTexturePixmapGLX
#define COGL_WINSYS_FEATURE_BEGIN(name, namespaces, extension_names, \
feature_flags, feature_flags_private, \
winsys_feature) \
- { 255, 255, namespaces, extension_names, \
+ { 255, 255, 0, namespaces, extension_names, \
feature_flags, feature_flags_private, \
winsys_feature, \
cogl_glx_feature_ ## name ## _funcs },
@@ -346,7 +346,7 @@ update_winsys_features (CoglContext *context)
for (i = 0; i < G_N_ELEMENTS (winsys_feature_data); i++)
if (_cogl_feature_check (_cogl_context_get_winsys (context),
- "GLX", winsys_feature_data + i, 0, 0,
+ "GLX", winsys_feature_data + i, 0, 0, 0,
glx_extensions,
glx_renderer))
{
@@ -384,7 +384,7 @@ update_winsys_features (CoglContext *context)
}
#endif
- if (glx_renderer->pf_glXCopySubBuffer || context->drv.pf_glBlitFramebuffer)
+ if (glx_renderer->pf_glXCopySubBuffer || context->glBlitFramebuffer)
COGL_FLAGS_SET (context->winsys_features,
COGL_WINSYS_FEATURE_SWAP_REGION, TRUE);
@@ -1143,7 +1143,7 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
rect[0], rect[1], rect[2], rect[3]);
}
}
- else if (context->drv.pf_glBlitFramebuffer)
+ else if (context->glBlitFramebuffer)
{
int i;
/* XXX: checkout how this state interacts with the code to use
@@ -1154,9 +1154,9 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
int *rect = &rectangles[4 * i];
int x2 = rect[0] + rect[2];
int y2 = rect[1] + rect[3];
- context->drv.pf_glBlitFramebuffer (rect[0], rect[1], x2, y2,
- rect[0], rect[1], x2, y2,
- GL_COLOR_BUFFER_BIT, GL_NEAREST);
+ context->glBlitFramebuffer (rect[0], rect[1], x2, y2,
+ rect[0], rect[1], x2, y2,
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
glDrawBuffer (GL_BACK);
}
diff --git a/cogl/winsys/cogl-winsys-wgl.c b/cogl/winsys/cogl-winsys-wgl.c
index c221775c..acee20da 100644
--- a/cogl/winsys/cogl-winsys-wgl.c
+++ b/cogl/winsys/cogl-winsys-wgl.c
@@ -107,7 +107,7 @@ typedef struct _CoglOnscreenWgl
#define COGL_WINSYS_FEATURE_BEGIN(name, namespaces, extension_names, \
feature_flags, feature_flags_private, \
winsys_feature) \
- { 255, 255, namespaces, extension_names, \
+ { 255, 255, 0, namespaces, extension_names, \
feature_flags, feature_flags_private, \
winsys_feature, \
cogl_wgl_feature_ ## name ## _funcs },
@@ -567,7 +567,7 @@ update_winsys_features (CoglContext *context)
for (i = 0; i < G_N_ELEMENTS (winsys_feature_data); i++)
if (_cogl_feature_check (_cogl_context_get_winsys (context),
- "WGL", winsys_feature_data + i, 0, 0,
+ "WGL", winsys_feature_data + i, 0, 0, 0,
wgl_extensions,
wgl_renderer))
{