cogl: Make it easier to add checks for GL extensions

Previously if you need to depend on a new GL feature you had to:

- Add typedefs for all of the functions in cogl-defines.h.in

- Add function pointers for each of the functions in
  cogl-context-driver.h

- Add an initializer for the function pointers in
  cogl-context-driver.c

- Add a check for the extension and all of the functions in
  cogl_features_init. If the extension is available under multiple
  names then you have to duplicate the checks.

This is quite tedious and error prone. This patch moves all of the
features and their functions into a list of macro invocations in
cogl-feature-functions.h. The macros can be redefined to implement all
of the above tasks from the same header.

The features are described in a struct with a pointer to a table of
functions. A new function takes the feature description from this
struct and checks for its availability. The feature can take a list of
extension names with a list of alternate namespaces (such as "EXT" or
"ARB"). It can also detect the feature from a particular version of
GL.

The typedefs are now gone and instead the function pointer in the Cogl
context just directly contains the type.

Some of the functions in the context were previously declared with the
'ARB' extension. This has been removed so that now all the functions
have no suffix. This makes more sense when the extension could
potentially be merged into GL core as well.
This commit is contained in:
Neil Roberts 2009-11-17 13:52:40 +00:00
parent 4734b7be41
commit 91cde78a70
17 changed files with 795 additions and 1031 deletions

View File

@ -99,6 +99,8 @@ libclutter_cogl_la_SOURCES = \
$(srcdir)/cogl-bitmap-pixbuf.c \
$(srcdir)/cogl-clip-stack.h \
$(srcdir)/cogl-clip-stack.c \
$(srcdir)/cogl-feature-private.h \
$(srcdir)/cogl-feature-private.c \
$(srcdir)/cogl-fixed.c \
$(srcdir)/cogl-color.c \
$(srcdir)/cogl-vertex-buffer-private.h \

View File

@ -0,0 +1,141 @@
/*
* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include "cogl.h"
#include "cogl-context.h"
#include "cogl-feature-private.h"
gboolean
_cogl_feature_check (const CoglFeatureData *data,
guint gl_major, guint gl_minor,
const gchar *extensions_string)
{
const gchar *suffix = NULL;
int func_num;
_COGL_GET_CONTEXT (ctx, FALSE);
/* 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))
suffix = "";
else
{
/* Otherwise try all of the extensions */
const gchar *namespace, *namespace_suffix;
guint namespace_len;
for (namespace = data->namespaces;
*namespace;
namespace += strlen (namespace) + 1)
{
const gchar *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_set_size (full_extension_name, 0);
g_string_append (full_extension_name, "GL_");
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 (!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')
{
suffix = namespace_suffix;
break;
}
}
}
/* If we couldn't find anything that provides the functions then
give up */
if (suffix == NULL)
return FALSE;
/* Try to get all of the entry points */
for (func_num = 0; data->functions[func_num].name; func_num++)
{
void *func;
gchar *full_function_name;
full_function_name = g_strconcat (data->functions[func_num].name,
suffix, NULL);
func = cogl_get_proc_address (full_function_name);
g_free (full_function_name);
if (func == NULL)
break;
/* Set the function pointer in the context */
*(void **) ((guchar *) ctx +
data->functions[func_num].pointer_offset) = func;
}
/* If one of the functions wasn't found then we should set all of
the function pointers back to NULL so that the rest of Cogl can
safely do feature testing by just looking at the function
pointers */
if (data->functions[func_num].name)
{
while (func_num-- > 0)
*(void **) ((guchar *) ctx +
data->functions[func_num].pointer_offset) = NULL;
return FALSE;
}
else
return TRUE;
}

View File

@ -0,0 +1,71 @@
/*
* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __COGL_FEATURE_PRIVATE_H
#define __COGL_FEATURE_PRIVATE_H
#include <glib.h>
#define COGL_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 _CoglFeatureFunction CoglFeatureFunction;
struct _CoglFeatureFunction
{
/* The name of the function without the "EXT" or "ARB" suffix */
const gchar *name;
/* The offset in the context of where to store the function pointer */
guint pointer_offset;
};
typedef struct _CoglFeatureData CoglFeatureData;
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 */
guchar min_gl_major, min_gl_minor;
/* \0 separated list of namespaces to try. Eg "EXT\0ARB\0" */
const gchar *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
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 gchar *extension_names;
/* A set of feature flags to enable if the extension is available */
CoglFeatureFlags feature_flags;
/* A list of functions required for this feature. Terminated with a
NULL name */
const CoglFeatureFunction *functions;
};
gboolean _cogl_feature_check (const CoglFeatureData *data,
guint gl_major, guint gl_minor,
const gchar *extensions_string);
#endif /* __COGL_FEATURE_PRIVATE_H */

View File

@ -42,11 +42,11 @@
#ifdef HAVE_COGL_GL
#define glGenBuffers ctx->drv.pf_glGenBuffersARB
#define glBindBuffer ctx->drv.pf_glBindBufferARB
#define glBufferData ctx->drv.pf_glBufferDataARB
#define glBufferSubData ctx->drv.pf_glBufferSubDataARB
#define glDeleteBuffers ctx->drv.pf_glDeleteBuffersARB
#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 glDeleteBuffers ctx->drv.pf_glDeleteBuffers
#define glClientActiveTexture ctx->drv.pf_glClientActiveTexture
#elif defined (HAVE_COGL_GLES2)

View File

@ -150,13 +150,14 @@
#if defined (HAVE_COGL_GL)
#define glGenBuffers ctx->drv.pf_glGenBuffersARB
#define glBindBuffer ctx->drv.pf_glBindBufferARB
#define glBufferData ctx->drv.pf_glBufferDataARB
#define glBufferSubData ctx->drv.pf_glBufferSubDataARB
#define glDeleteBuffers ctx->drv.pf_glDeleteBuffersARB
#define glMapBuffer ctx->drv.pf_glMapBufferARB
#define glUnmapBuffer ctx->drv.pf_glUnmapBufferARB
#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 glActiveTexture ctx->drv.pf_glActiveTexture
#define glClientActiveTexture ctx->drv.pf_glClientActiveTexture
#ifndef GL_ARRAY_BUFFER
@ -175,9 +176,9 @@
#if defined (HAVE_COGL_GL)
#define glVertexAttribPointer ctx->drv.pf_glVertexAttribPointerARB
#define glEnableVertexAttribArray ctx->drv.pf_glEnableVertexAttribArrayARB
#define glDisableVertexAttribArray ctx->drv.pf_glEnableVertexAttribArrayARB
#define glVertexAttribPointer ctx->drv.pf_glVertexAttribPointer
#define glEnableVertexAttribArray ctx->drv.pf_glEnableVertexAttribArray
#define glDisableVertexAttribArray ctx->drv.pf_glEnableVertexAttribArray
#define MAY_HAVE_PROGRAMABLE_GL
#elif defined (HAVE_COGL_GLES2)

View File

@ -27,59 +27,13 @@
#include "cogl-context.h"
#define COGL_FEATURE_BEGIN(a, b, c, d, e, f)
#define COGL_FEATURE_FUNCTION(ret, name, args) \
_context->drv.pf_ ## name = NULL;
#define COGL_FEATURE_END()
void
_cogl_create_context_driver (CoglContext *_context)
{
_context->drv.pf_glGenRenderbuffers = NULL;
_context->drv.pf_glBindRenderbuffer = NULL;
_context->drv.pf_glRenderbufferStorage = NULL;
_context->drv.pf_glGenFramebuffers = NULL;
_context->drv.pf_glBindFramebuffer = NULL;
_context->drv.pf_glFramebufferTexture2D = NULL;
_context->drv.pf_glFramebufferRenderbuffer = NULL;
_context->drv.pf_glCheckFramebufferStatus = NULL;
_context->drv.pf_glDeleteFramebuffers = NULL;
_context->drv.pf_glBlitFramebufferEXT = NULL;
_context->drv.pf_glRenderbufferStorageMultisampleEXT = NULL;
_context->drv.pf_glCreateProgramObjectARB = NULL;
_context->drv.pf_glCreateShaderObjectARB = NULL;
_context->drv.pf_glShaderSourceARB = NULL;
_context->drv.pf_glCompileShaderARB = NULL;
_context->drv.pf_glAttachObjectARB = NULL;
_context->drv.pf_glLinkProgramARB = NULL;
_context->drv.pf_glUseProgramObjectARB = NULL;
_context->drv.pf_glGetUniformLocationARB = NULL;
_context->drv.pf_glDeleteObjectARB = NULL;
_context->drv.pf_glGetInfoLogARB = NULL;
_context->drv.pf_glGetObjectParameterivARB = NULL;
_context->drv.pf_glUniform1fARB = NULL;
_context->drv.pf_glUniform2fARB = NULL;
_context->drv.pf_glUniform3fARB = NULL;
_context->drv.pf_glUniform4fARB = NULL;
_context->drv.pf_glUniform1fvARB = NULL;
_context->drv.pf_glUniform2fvARB = NULL;
_context->drv.pf_glUniform3fvARB = NULL;
_context->drv.pf_glUniform4fvARB = NULL;
_context->drv.pf_glUniform1iARB = NULL;
_context->drv.pf_glUniform2iARB = NULL;
_context->drv.pf_glUniform3iARB = NULL;
_context->drv.pf_glUniform4iARB = NULL;
_context->drv.pf_glUniform1ivARB = NULL;
_context->drv.pf_glUniform2ivARB = NULL;
_context->drv.pf_glUniform3ivARB = NULL;
_context->drv.pf_glUniform4ivARB = NULL;
_context->drv.pf_glUniformMatrix2fvARB = NULL;
_context->drv.pf_glUniformMatrix3fvARB = NULL;
_context->drv.pf_glUniformMatrix4fvARB = NULL;
_context->drv.pf_glDrawRangeElements = NULL;
_context->drv.pf_glActiveTexture = NULL;
_context->drv.pf_glClientActiveTexture = NULL;
_context->drv.pf_glBlendFuncSeparate = NULL;
_context->drv.pf_glBlendEquationSeparate = NULL;
#include "cogl-feature-functions.h"
}

View File

@ -26,79 +26,22 @@
#include "cogl.h"
#define COGL_FEATURE_BEGIN(a, b, c, d, e, f)
#define COGL_FEATURE_FUNCTION(ret, name, args) \
ret (* pf_ ## name) args;
#define COGL_FEATURE_END()
typedef struct _CoglContextDriver
{
/* Relying on glext.h to define these */
COGL_PFNGLGENRENDERBUFFERSPROC pf_glGenRenderbuffers;
COGL_PFNGLDELETERENDERBUFFERSPROC pf_glDeleteRenderbuffers;
COGL_PFNGLBINDRENDERBUFFERPROC pf_glBindRenderbuffer;
COGL_PFNGLRENDERBUFFERSTORAGEPROC pf_glRenderbufferStorage;
COGL_PFNGLGENFRAMEBUFFERSPROC pf_glGenFramebuffers;
COGL_PFNGLBINDFRAMEBUFFERPROC pf_glBindFramebuffer;
COGL_PFNGLFRAMEBUFFERTEXTURE2DPROC pf_glFramebufferTexture2D;
COGL_PFNGLFRAMEBUFFERRENDERBUFFERPROC pf_glFramebufferRenderbuffer;
COGL_PFNGLCHECKFRAMEBUFFERSTATUSPROC pf_glCheckFramebufferStatus;
COGL_PFNGLDELETEFRAMEBUFFERSPROC pf_glDeleteFramebuffers;
COGL_PFNGLGENERATEMIPMAPPROC pf_glGenerateMipmap;
COGL_PFNGLBLITFRAMEBUFFEREXTPROC pf_glBlitFramebufferEXT;
COGL_PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC pf_glRenderbufferStorageMultisampleEXT;
COGL_PFNGLCREATEPROGRAMOBJECTARBPROC pf_glCreateProgramObjectARB;
COGL_PFNGLCREATESHADEROBJECTARBPROC pf_glCreateShaderObjectARB;
COGL_PFNGLSHADERSOURCEARBPROC pf_glShaderSourceARB;
COGL_PFNGLCOMPILESHADERARBPROC pf_glCompileShaderARB;
COGL_PFNGLATTACHOBJECTARBPROC pf_glAttachObjectARB;
COGL_PFNGLLINKPROGRAMARBPROC pf_glLinkProgramARB;
COGL_PFNGLUSEPROGRAMOBJECTARBPROC pf_glUseProgramObjectARB;
COGL_PFNGLGETUNIFORMLOCATIONARBPROC pf_glGetUniformLocationARB;
COGL_PFNGLDELETEOBJECTARBPROC pf_glDeleteObjectARB;
COGL_PFNGLGETINFOLOGARBPROC pf_glGetInfoLogARB;
COGL_PFNGLGETOBJECTPARAMETERIVARBPROC pf_glGetObjectParameterivARB;
COGL_PFNGLVERTEXATTRIBPOINTERARBPROC pf_glVertexAttribPointerARB;
COGL_PFNGLENABLEVERTEXATTRIBARRAYARBPROC pf_glEnableVertexAttribArrayARB;
COGL_PFNGLDISABLEVERTEXATTRIBARRAYARBPROC pf_glDisableVertexAttribArrayARB;
COGL_PFNGLGENBUFFERSARBPROC pf_glGenBuffersARB;
COGL_PFNGLBINDBUFFERARBPROC pf_glBindBufferARB;
COGL_PFNGLBUFFERDATAARBPROC pf_glBufferDataARB;
COGL_PFNGLBUFFERSUBDATAARBPROC pf_glBufferSubDataARB;
COGL_PFNGLMAPBUFFERARBPROC pf_glMapBufferARB;
COGL_PFNGLUNMAPBUFFERARBPROC pf_glUnmapBufferARB;
COGL_PFNGLDELETEBUFFERSARBPROC pf_glDeleteBuffersARB;
COGL_PFNGLUNIFORM1FARBPROC pf_glUniform1fARB;
COGL_PFNGLUNIFORM2FARBPROC pf_glUniform2fARB;
COGL_PFNGLUNIFORM3FARBPROC pf_glUniform3fARB;
COGL_PFNGLUNIFORM4FARBPROC pf_glUniform4fARB;
COGL_PFNGLUNIFORM1FVARBPROC pf_glUniform1fvARB;
COGL_PFNGLUNIFORM2FVARBPROC pf_glUniform2fvARB;
COGL_PFNGLUNIFORM3FVARBPROC pf_glUniform3fvARB;
COGL_PFNGLUNIFORM4FVARBPROC pf_glUniform4fvARB;
COGL_PFNGLUNIFORM1IARBPROC pf_glUniform1iARB;
COGL_PFNGLUNIFORM2IARBPROC pf_glUniform2iARB;
COGL_PFNGLUNIFORM3IARBPROC pf_glUniform3iARB;
COGL_PFNGLUNIFORM4IARBPROC pf_glUniform4iARB;
COGL_PFNGLUNIFORM1IVARBPROC pf_glUniform1ivARB;
COGL_PFNGLUNIFORM2IVARBPROC pf_glUniform2ivARB;
COGL_PFNGLUNIFORM3IVARBPROC pf_glUniform3ivARB;
COGL_PFNGLUNIFORM4IVARBPROC pf_glUniform4ivARB;
COGL_PFNGLUNIFORMMATRIX2FVARBPROC pf_glUniformMatrix2fvARB;
COGL_PFNGLUNIFORMMATRIX3FVARBPROC pf_glUniformMatrix3fvARB;
COGL_PFNGLUNIFORMMATRIX4FVARBPROC pf_glUniformMatrix4fvARB;
COGL_PFNGLDRAWRANGEELEMENTSPROC pf_glDrawRangeElements;
COGL_PFNGLACTIVETEXTUREPROC pf_glActiveTexture;
COGL_PFNGLCLIENTACTIVETEXTUREPROC pf_glClientActiveTexture;
COGL_PFNGLBLENDEQUATIONPROC pf_glBlendEquation;
COGL_PFNGLBLENDCOLORPROC pf_glBlendColor;
COGL_PFNGLBLENDFUNCSEPARATEPROC pf_glBlendFuncSeparate;
COGL_PFNGLBLENDEQUATIONSEPARATEPROC pf_glBlendEquationSeparate;
/* This defines a list of function pointers */
#include "cogl-feature-functions.h"
} CoglContextDriver;
#undef COGL_FEATURE_BEGIN
#undef COGL_FEATURE_FUNCTION
#undef COGL_FEATURE_END
#endif /* __COGL_CONTEXT_DRIVER_H */

View File

@ -687,367 +687,6 @@ G_BEGIN_DECLS
#define CLUTTER_COGL_HAS_GL 1
#define COGL_HAS_GL 1
/* Extension function prototypes */
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
typedef void
(APIENTRYP COGL_PFNGLGENRENDERBUFFERSPROC)
(GLsizei n,
GLuint *renderbuffers);
typedef void
(APIENTRYP COGL_PFNGLBINDRENDERBUFFERPROC)
(GLenum target,
GLuint renderbuffer);
typedef void
(APIENTRYP COGL_PFNGLRENDERBUFFERSTORAGEPROC)
(GLenum target,
GLenum internalformat,
GLsizei width,
GLsizei height);
typedef void
(APIENTRYP COGL_PFNGLGENFRAMEBUFFERSPROC)
(GLsizei n,
GLuint *framebuffers);
typedef void
(APIENTRYP COGL_PFNGLBINDFRAMEBUFFERPROC)
(GLenum target,
GLuint framebuffer);
typedef void
(APIENTRYP COGL_PFNGLFRAMEBUFFERTEXTURE2DPROC)
(GLenum target,
GLenum attachment,
GLenum textarget,
GLuint texture,
GLint level);
typedef void
(APIENTRYP COGL_PFNGLFRAMEBUFFERRENDERBUFFERPROC)
(GLenum target,
GLenum attachment,
GLenum renderbuffertarget,
GLuint renderbuffer);
typedef GLenum
(APIENTRYP COGL_PFNGLCHECKFRAMEBUFFERSTATUSPROC)
(GLenum target);
typedef void
(APIENTRYP COGL_PFNGLDELETEFRAMEBUFFERSPROC)
(GLsizei n,
const GLuint *framebuffers);
typedef void
(APIENTRYP COGL_PFNGLDELETERENDERBUFFERSPROC)
(GLsizei n,
const GLuint *renderbuffers);
typedef void
(APIENTRYP COGL_PFNGLGENERATEMIPMAPPROC)
(GLenum target);
typedef void
(APIENTRYP COGL_PFNGLBLITFRAMEBUFFEREXTPROC)
(GLint srcX0,
GLint srcY0,
GLint srcX1,
GLint srcY1,
GLint dstX0,
GLint dstY0,
GLint dstX1,
GLint dstY1,
GLbitfield mask,
GLenum filter);
typedef void
(APIENTRYP COGL_PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)
(GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height);
typedef GLhandleARB
(APIENTRYP COGL_PFNGLCREATEPROGRAMOBJECTARBPROC)
(void);
typedef GLhandleARB
(APIENTRYP COGL_PFNGLCREATESHADEROBJECTARBPROC)
(GLenum shaderType);
typedef void
(APIENTRYP COGL_PFNGLSHADERSOURCEARBPROC)
(GLhandleARB shaderObj,
GLsizei count,
const GLcharARB* *string,
const GLint *length);
typedef void
(APIENTRYP COGL_PFNGLCOMPILESHADERARBPROC)
(GLhandleARB shaderObj);
typedef void
(APIENTRYP COGL_PFNGLATTACHOBJECTARBPROC)
(GLhandleARB containerObj,
GLhandleARB obj);
typedef void
(APIENTRYP COGL_PFNGLLINKPROGRAMARBPROC)
(GLhandleARB programObj);
typedef void
(APIENTRYP COGL_PFNGLUSEPROGRAMOBJECTARBPROC)
(GLhandleARB programObj);
typedef GLint
(APIENTRYP COGL_PFNGLGETUNIFORMLOCATIONARBPROC)
(GLhandleARB programObj,
const GLcharARB *name);
typedef void
(APIENTRYP COGL_PFNGLDELETEOBJECTARBPROC)
(GLhandleARB obj);
typedef void
(APIENTRYP COGL_PFNGLGETINFOLOGARBPROC)
(GLhandleARB obj,
GLsizei maxLength,
GLsizei *length,
GLcharARB *infoLog);
typedef void
(APIENTRYP COGL_PFNGLGETOBJECTPARAMETERIVARBPROC)
(GLhandleARB obj,
GLenum pname,
GLint *params);
typedef void
(APIENTRYP COGL_PFNGLVERTEXATTRIBPOINTERARBPROC)
(GLuint index,
GLint size,
GLenum type,
GLboolean normalized,
GLsizei stride,
const GLvoid *pointer);
typedef void
(APIENTRYP COGL_PFNGLENABLEVERTEXATTRIBARRAYARBPROC)
(GLuint index);
typedef void
(APIENTRYP COGL_PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)
(GLuint index);
typedef void
(APIENTRYP COGL_PFNGLGENBUFFERSARBPROC)
(GLuint n,
GLuint *buffers);
typedef void
(APIENTRYP COGL_PFNGLBINDBUFFERARBPROC)
(GLenum target,
GLuint buffer);
typedef void
(APIENTRYP COGL_PFNGLBUFFERDATAARBPROC)
(GLenum target,
GLsizeiptr size,
const GLvoid *data,
GLenum usage);
typedef void
(APIENTRYP COGL_PFNGLBUFFERSUBDATAARBPROC)
(GLenum target,
GLintptr offset,
GLsizeiptr size,
const GLvoid *data);
typedef void *
(APIENTRYP COGL_PFNGLMAPBUFFERARBPROC)
(GLenum target,
GLenum access);
typedef GLboolean
(APIENTRYP COGL_PFNGLUNMAPBUFFERARBPROC)
(GLenum target);
typedef void
(APIENTRYP COGL_PFNGLDELETEBUFFERSARBPROC)
(GLsizei n,
const GLuint *buffers);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM1FARBPROC)
(GLint location,
GLfloat v0);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM2FARBPROC)
(GLint location,
GLfloat v0,
GLfloat v1);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM3FARBPROC)
(GLint location,
GLfloat v0,
GLfloat v1,
GLfloat v2);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM4FARBPROC)
(GLint location,
GLfloat v0,
GLfloat v1,
GLfloat v2,
GLfloat v3);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM1FVARBPROC)
(GLint location,
GLsizei count,
const GLfloat * value);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM2FVARBPROC)
(GLint location,
GLsizei count,
const GLfloat * value);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM3FVARBPROC)
(GLint location,
GLsizei count,
const GLfloat * value);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM4FVARBPROC)
(GLint location,
GLsizei count,
const GLfloat * value);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM1IARBPROC)
(GLint location,
GLint v0);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM2IARBPROC)
(GLint location,
GLint v0,
GLint v1);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM3IARBPROC)
(GLint location,
GLint v0,
GLint v1,
GLint v2);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM4IARBPROC)
(GLint location,
GLint v0,
GLint v1,
GLint v2,
GLint v3);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM1IVARBPROC)
(GLint location,
GLsizei count,
const GLint * value);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM2IVARBPROC)
(GLint location,
GLsizei count,
const GLint * value);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM3IVARBPROC)
(GLint location,
GLsizei count,
const GLint * value);
typedef void
(APIENTRYP COGL_PFNGLUNIFORM4IVARBPROC)
(GLint location,
GLsizei count,
const GLint * value);
typedef void
(APIENTRYP COGL_PFNGLUNIFORMMATRIX2FVARBPROC)
(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
typedef void
(APIENTRYP COGL_PFNGLUNIFORMMATRIX3FVARBPROC)
(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
typedef void
(APIENTRYP COGL_PFNGLUNIFORMMATRIX4FVARBPROC)
(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
typedef void
(APIENTRYP COGL_PFNGLDRAWRANGEELEMENTSPROC)
(GLenum mode,
GLuint start,
GLuint end,
GLsizei count,
GLenum type,
const GLvoid *indices);
typedef void
(APIENTRYP COGL_PFNGLACTIVETEXTUREPROC)
(GLenum texture);
typedef void
(APIENTRYP COGL_PFNGLCLIENTACTIVETEXTUREPROC)
(GLenum texture);
typedef void
(APIENTRYP COGL_PFNGLBLENDFUNCSEPARATEPROC)
(GLenum srcRGB,
GLenum dstRGB,
GLenum srcAlpha,
GLenum dstAlpha);
typedef void
(APIENTRYP COGL_PFNGLBLENDEQUATIONSEPARATEPROC)
(GLenum modeRGB,
GLenum modeAlpha);
typedef void
(APIENTRYP COGL_PFNGLBLENDEQUATIONPROC)
(GLenum mode);
typedef void
(APIENTRYP COGL_PFNGLBLENDCOLORPROC)
(GLclampf red,
GLclampf green,
GLclampf blue,
GLclampf alpha);
G_END_DECLS
#endif

View File

@ -0,0 +1,326 @@
/*
* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* 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)
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_END ()
COGL_FEATURE_BEGIN (offscreen_blit, 255, 255,
"EXT\0",
"framebuffer_blit\0",
COGL_FEATURE_OFFSCREEN_BLIT)
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)
COGL_FEATURE_FUNCTION (void, glRenderbufferStorageMultisample,
(GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height))
COGL_FEATURE_END ()
COGL_FEATURE_BEGIN (shaders_glsl, 255, 255,
"ARB\0",
"shader_objects\0"
"vertex_shader\0"
"fragment_shader\0",
COGL_FEATURE_SHADERS_GLSL)
COGL_FEATURE_FUNCTION (GLhandleARB, glCreateProgramObject,
(void))
COGL_FEATURE_FUNCTION (GLhandleARB, glCreateShaderObject,
(GLenum shaderType))
COGL_FEATURE_FUNCTION (void, glShaderSource,
(GLhandleARB shaderObj,
GLsizei count,
const GLcharARB* *string,
const GLint *length))
COGL_FEATURE_FUNCTION (void, glCompileShader,
(GLhandleARB shaderObj))
COGL_FEATURE_FUNCTION (void, glAttachObject,
(GLhandleARB containerObj,
GLhandleARB obj))
COGL_FEATURE_FUNCTION (void, glLinkProgram,
(GLhandleARB programObj))
COGL_FEATURE_FUNCTION (void, glUseProgramObject,
(GLhandleARB programObj))
COGL_FEATURE_FUNCTION (GLint, glGetUniformLocation,
(GLhandleARB programObj,
const GLcharARB *name))
COGL_FEATURE_FUNCTION (void, glDeleteObject,
(GLhandleARB obj))
COGL_FEATURE_FUNCTION (void, glGetInfoLog,
(GLhandleARB obj,
GLsizei maxLength,
GLsizei *length,
GLcharARB *infoLog))
COGL_FEATURE_FUNCTION (void, glGetObjectParameteriv,
(GLhandleARB obj,
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_END ()
COGL_FEATURE_BEGIN (vbos, 255, 255,
"ARB\0",
"vertex_buffer_object\0",
COGL_FEATURE_VBOS)
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 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)
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 ()
/* Available in GL 1.3 or the multitexture extension. These are
required */
COGL_FEATURE_BEGIN (multitexture, 1, 3,
"ARB\0",
"multitexture\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 (in_1_4, 1, 4,
"\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 (in_2_0, 2, 0,
"\0",
"\0",
0)
COGL_FEATURE_FUNCTION (void, glBlendEquationSeparate,
(GLenum modeRGB,
GLenum modeAlpha))
COGL_FEATURE_END ()

View File

@ -34,32 +34,31 @@
#include <glib.h>
/* Expecting ARB functions not to be defined */
#define glCreateProgramObjectARB ctx->drv.pf_glCreateProgramObjectARB
#define glAttachObjectARB ctx->drv.pf_glAttachObjectARB
#define glUseProgramObjectARB ctx->drv.pf_glUseProgramObjectARB
#define glLinkProgramARB ctx->drv.pf_glLinkProgramARB
#define glGetUniformLocationARB ctx->drv.pf_glGetUniformLocationARB
#define glUniform1fARB ctx->drv.pf_glUniform1fARB
#define glUniform2fARB ctx->drv.pf_glUniform2fARB
#define glUniform3fARB ctx->drv.pf_glUniform3fARB
#define glUniform4fARB ctx->drv.pf_glUniform4fARB
#define glUniform1fvARB ctx->drv.pf_glUniform1fvARB
#define glUniform2fvARB ctx->drv.pf_glUniform2fvARB
#define glUniform3fvARB ctx->drv.pf_glUniform3fvARB
#define glUniform4fvARB ctx->drv.pf_glUniform4fvARB
#define glUniform1iARB ctx->drv.pf_glUniform1iARB
#define glUniform2iARB ctx->drv.pf_glUniform2iARB
#define glUniform3iARB ctx->drv.pf_glUniform3iARB
#define glUniform4iARB ctx->drv.pf_glUniform4iARB
#define glUniform1ivARB ctx->drv.pf_glUniform1ivARB
#define glUniform2ivARB ctx->drv.pf_glUniform2ivARB
#define glUniform3ivARB ctx->drv.pf_glUniform3ivARB
#define glUniform4ivARB ctx->drv.pf_glUniform4ivARB
#define glUniformMatrix2fvARB ctx->drv.pf_glUniformMatrix2fvARB
#define glUniformMatrix3fvARB ctx->drv.pf_glUniformMatrix3fvARB
#define glUniformMatrix4fvARB ctx->drv.pf_glUniformMatrix4fvARB
#define glDeleteObjectARB ctx->drv.pf_glDeleteObjectARB
#define glCreateProgramObject ctx->drv.pf_glCreateProgramObject
#define glAttachObject ctx->drv.pf_glAttachObject
#define glUseProgramObject ctx->drv.pf_glUseProgramObject
#define glLinkProgram ctx->drv.pf_glLinkProgram
#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 glDeleteObject ctx->drv.pf_glDeleteObject
static void _cogl_program_free (CoglProgram *program);
@ -71,7 +70,7 @@ _cogl_program_free (CoglProgram *program)
/* Frees program resources but its handle is not
released! Do that separately before this! */
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
glDeleteObjectARB (program->gl_handle);
glDeleteObject (program->gl_handle);
}
CoglHandle
@ -81,7 +80,7 @@ cogl_create_program (void)
_COGL_GET_CONTEXT (ctx, 0);
program = g_slice_new (CoglProgram);
program->gl_handle = glCreateProgramObjectARB ();
program->gl_handle = glCreateProgramObject ();
return _cogl_program_handle_new (program);
}
@ -101,7 +100,7 @@ cogl_program_attach_shader (CoglHandle program_handle,
program = _cogl_program_pointer_from_handle (program_handle);
shader = _cogl_shader_pointer_from_handle (shader_handle);
glAttachObjectARB (program->gl_handle, shader->gl_handle);
glAttachObject (program->gl_handle, shader->gl_handle);
}
void
@ -115,7 +114,7 @@ cogl_program_link (CoglHandle handle)
program = _cogl_program_pointer_from_handle (handle);
glLinkProgramARB (program->gl_handle);
glLinkProgram (program->gl_handle);
}
void
@ -141,7 +140,7 @@ cogl_program_use (CoglHandle handle)
gl_handle = program->gl_handle;
}
glUseProgramObjectARB (gl_handle);
glUseProgramObject (gl_handle);
}
int
@ -156,7 +155,7 @@ cogl_program_get_uniform_location (CoglHandle handle,
program = _cogl_program_pointer_from_handle (handle);
return glGetUniformLocationARB (program->gl_handle, uniform_name);
return glGetUniformLocation (program->gl_handle, uniform_name);
}
void
@ -164,7 +163,7 @@ cogl_program_uniform_1f (int uniform_no,
gfloat value)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
glUniform1fARB (uniform_no, value);
glUniform1f (uniform_no, value);
}
void
@ -172,7 +171,7 @@ cogl_program_uniform_1i (int uniform_no,
gint value)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
glUniform1iARB (uniform_no, value);
glUniform1i (uniform_no, value);
}
void
@ -186,16 +185,16 @@ cogl_program_uniform_float (int uniform_no,
switch (size)
{
case 1:
glUniform1fvARB (uniform_no, count, value);
glUniform1fv (uniform_no, count, value);
break;
case 2:
glUniform2fvARB (uniform_no, count, value);
glUniform2fv (uniform_no, count, value);
break;
case 3:
glUniform3fvARB (uniform_no, count, value);
glUniform3fv (uniform_no, count, value);
break;
case 4:
glUniform4fvARB (uniform_no, count, value);
glUniform4fv (uniform_no, count, value);
break;
default:
g_warning ("%s called with invalid size parameter", G_STRFUNC);
@ -213,16 +212,16 @@ cogl_program_uniform_int (int uniform_no,
switch (size)
{
case 1:
glUniform1ivARB (uniform_no, count, value);
glUniform1iv (uniform_no, count, value);
break;
case 2:
glUniform2ivARB (uniform_no, count, value);
glUniform2iv (uniform_no, count, value);
break;
case 3:
glUniform3ivARB (uniform_no, count, value);
glUniform3iv (uniform_no, count, value);
break;
case 4:
glUniform4ivARB (uniform_no, count, value);
glUniform4iv (uniform_no, count, value);
break;
default:
g_warning ("%s called with invalid size parameter", G_STRFUNC);
@ -241,13 +240,13 @@ cogl_program_uniform_matrix (int uniform_no,
switch (size)
{
case 2 :
glUniformMatrix2fvARB (uniform_no, count, transpose, value);
glUniformMatrix2fv (uniform_no, count, transpose, value);
break;
case 3 :
glUniformMatrix3fvARB (uniform_no, count, transpose, value);
glUniformMatrix3fv (uniform_no, count, transpose, value);
break;
case 4 :
glUniformMatrix4fvARB (uniform_no, count, transpose, value);
glUniformMatrix4fv (uniform_no, count, transpose, value);
break;
default :
g_warning ("%s called with invalid size parameter", G_STRFUNC);

View File

@ -33,13 +33,12 @@
#include <glib.h>
/* Expecting ARB functions not to be defined */
#define glCreateShaderObjectARB ctx->drv.pf_glCreateShaderObjectARB
#define glGetObjectParameterivARB ctx->drv.pf_glGetObjectParameterivARB
#define glGetInfoLogARB ctx->drv.pf_glGetInfoLogARB
#define glCompileShaderARB ctx->drv.pf_glCompileShaderARB
#define glShaderSourceARB ctx->drv.pf_glShaderSourceARB
#define glDeleteObjectARB ctx->drv.pf_glDeleteObjectARB
#define glCreateShaderObject ctx->drv.pf_glCreateShaderObject
#define glGetObjectParameteriv ctx->drv.pf_glGetObjectParameteriv
#define glGetInfoLog ctx->drv.pf_glGetInfoLog
#define glCompileShader ctx->drv.pf_glCompileShader
#define glShaderSource ctx->drv.pf_glShaderSource
#define glDeleteObject ctx->drv.pf_glDeleteObject
static void _cogl_shader_free (CoglShader *shader);
@ -51,7 +50,7 @@ _cogl_shader_free (CoglShader *shader)
/* Frees shader resources but its handle is not
released! Do that separately before this! */
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
glDeleteObjectARB (shader->gl_handle);
glDeleteObject (shader->gl_handle);
}
CoglHandle
@ -74,7 +73,7 @@ cogl_create_shader (CoglShaderType type)
}
shader = g_slice_new (CoglShader);
shader->gl_handle = glCreateShaderObjectARB (gl_type);
shader->gl_handle = glCreateShaderObject (gl_type);
return _cogl_shader_handle_new (shader);
}
@ -91,7 +90,7 @@ cogl_shader_source (CoglHandle handle,
shader = _cogl_shader_pointer_from_handle (handle);
glShaderSourceARB (shader->gl_handle, 1, &source, NULL);
glShaderSource (shader->gl_handle, 1, &source, NULL);
}
void
@ -105,7 +104,7 @@ cogl_shader_compile (CoglHandle handle)
shader = _cogl_shader_pointer_from_handle (handle);
glCompileShaderARB (shader->gl_handle);
glCompileShader (shader->gl_handle);
}
gchar *
@ -121,7 +120,7 @@ cogl_shader_get_info_log (CoglHandle handle)
shader = _cogl_shader_pointer_from_handle (handle);
glGetInfoLogARB (shader->gl_handle, 511, &len, buffer);
glGetInfoLog (shader->gl_handle, 511, &len, buffer);
buffer[len]='\0';
return g_strdup (buffer);
@ -143,7 +142,7 @@ cogl_shader_get_type (CoglHandle handle)
shader = _cogl_shader_pointer_from_handle (handle);
GE (glGetObjectParameterivARB (shader->gl_handle, GL_SHADER_TYPE, &type));
GE (glGetObjectParameteriv (shader->gl_handle, GL_SHADER_TYPE, &type));
if (type == GL_VERTEX_SHADER)
return COGL_SHADER_TYPE_VERTEX;
else if (type == GL_FRAGMENT_SHADER)
@ -168,7 +167,7 @@ cogl_shader_is_compiled (CoglHandle handle)
shader = _cogl_shader_pointer_from_handle (handle);
GE (glGetObjectParameterivARB (shader->gl_handle, GL_COMPILE_STATUS, &status));
GE (glGetObjectParameteriv (shader->gl_handle, GL_COMPILE_STATUS, &status));
if (status == GL_TRUE)
return TRUE;
else

View File

@ -31,17 +31,7 @@
#include "cogl-internal.h"
#include "cogl-context.h"
#define COGL_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 _CoglGLSymbolTableEntry
{
const char *name;
void *ptr;
} CoglGLSymbolTableEntry;
#include "cogl-feature-private.h"
gboolean
cogl_check_extension (const gchar *name, const gchar *ext)
@ -68,26 +58,6 @@ cogl_check_extension (const gchar *name, const gchar *ext)
return FALSE;
}
gboolean
_cogl_resolve_gl_symbols (CoglGLSymbolTableEntry *symbol_table,
const char *suffix)
{
int i;
gboolean status = TRUE;
for (i = 0; symbol_table[i].name; i++)
{
char *full_name = g_strdup_printf ("%s%s", symbol_table[i].name, suffix);
*((CoglFuncPtr *)symbol_table[i].ptr) = cogl_get_proc_address (full_name);
g_free (full_name);
if (!*((CoglFuncPtr *)symbol_table[i].ptr))
{
status = FALSE;
break;
}
}
return status;
}
#ifdef HAVE_CLUTTER_OSX
static gboolean
really_enable_npot (void)
@ -197,6 +167,34 @@ _cogl_check_driver_valid (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) \
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() \
};
#include "cogl-feature-functions.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) \
{ min_gl_major, min_gl_minor, namespaces, \
extension_names, feature_flags, \
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.h"
};
void
_cogl_features_init (void)
{
@ -204,10 +202,8 @@ _cogl_features_init (void)
const gchar *gl_extensions;
GLint max_clip_planes = 0;
GLint num_stencil_bits = 0;
gboolean fbo_ARB = FALSE;
gboolean fbo_EXT = FALSE;
const char *suffix;
int gl_major = 0, gl_minor = 0;
int i;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -232,229 +228,6 @@ _cogl_features_init (void)
}
#endif
if (cogl_check_extension ("GL_ARB_shader_objects", gl_extensions) &&
cogl_check_extension ("GL_ARB_vertex_shader", gl_extensions) &&
cogl_check_extension ("GL_ARB_fragment_shader", gl_extensions))
{
ctx->drv.pf_glCreateProgramObjectARB =
(COGL_PFNGLCREATEPROGRAMOBJECTARBPROC)
cogl_get_proc_address ("glCreateProgramObjectARB");
ctx->drv.pf_glCreateShaderObjectARB =
(COGL_PFNGLCREATESHADEROBJECTARBPROC)
cogl_get_proc_address ("glCreateShaderObjectARB");
ctx->drv.pf_glShaderSourceARB =
(COGL_PFNGLSHADERSOURCEARBPROC)
cogl_get_proc_address ("glShaderSourceARB");
ctx->drv.pf_glCompileShaderARB =
(COGL_PFNGLCOMPILESHADERARBPROC)
cogl_get_proc_address ("glCompileShaderARB");
ctx->drv.pf_glAttachObjectARB =
(COGL_PFNGLATTACHOBJECTARBPROC)
cogl_get_proc_address ("glAttachObjectARB");
ctx->drv.pf_glLinkProgramARB =
(COGL_PFNGLLINKPROGRAMARBPROC)
cogl_get_proc_address ("glLinkProgramARB");
ctx->drv.pf_glUseProgramObjectARB =
(COGL_PFNGLUSEPROGRAMOBJECTARBPROC)
cogl_get_proc_address ("glUseProgramObjectARB");
ctx->drv.pf_glGetUniformLocationARB =
(COGL_PFNGLGETUNIFORMLOCATIONARBPROC)
cogl_get_proc_address ("glGetUniformLocationARB");
ctx->drv.pf_glDeleteObjectARB =
(COGL_PFNGLDELETEOBJECTARBPROC)
cogl_get_proc_address ("glDeleteObjectARB");
ctx->drv.pf_glGetInfoLogARB =
(COGL_PFNGLGETINFOLOGARBPROC)
cogl_get_proc_address ("glGetInfoLogARB");
ctx->drv.pf_glGetObjectParameterivARB =
(COGL_PFNGLGETOBJECTPARAMETERIVARBPROC)
cogl_get_proc_address ("glGetObjectParameterivARB");
ctx->drv.pf_glUniform1fARB =
(COGL_PFNGLUNIFORM1FARBPROC)
cogl_get_proc_address ("glUniform1fARB");
ctx->drv.pf_glVertexAttribPointerARB =
(COGL_PFNGLVERTEXATTRIBPOINTERARBPROC)
cogl_get_proc_address ("glVertexAttribPointerARB");
ctx->drv.pf_glEnableVertexAttribArrayARB =
(COGL_PFNGLENABLEVERTEXATTRIBARRAYARBPROC)
cogl_get_proc_address ("glEnableVertexAttribArrayARB");
ctx->drv.pf_glDisableVertexAttribArrayARB =
(COGL_PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)
cogl_get_proc_address ("glDisableVertexAttribArrayARB");
ctx->drv.pf_glUniform2fARB =
(COGL_PFNGLUNIFORM2FARBPROC)
cogl_get_proc_address ("glUniform2fARB");
ctx->drv.pf_glUniform3fARB =
(COGL_PFNGLUNIFORM3FARBPROC)
cogl_get_proc_address ("glUniform3fARB");
ctx->drv.pf_glUniform4fARB =
(COGL_PFNGLUNIFORM4FARBPROC)
cogl_get_proc_address ("glUniform4fARB");
ctx->drv.pf_glUniform1fvARB =
(COGL_PFNGLUNIFORM1FVARBPROC)
cogl_get_proc_address ("glUniform1fvARB");
ctx->drv.pf_glUniform2fvARB =
(COGL_PFNGLUNIFORM2FVARBPROC)
cogl_get_proc_address ("glUniform2fvARB");
ctx->drv.pf_glUniform3fvARB =
(COGL_PFNGLUNIFORM3FVARBPROC)
cogl_get_proc_address ("glUniform3fvARB");
ctx->drv.pf_glUniform4fvARB =
(COGL_PFNGLUNIFORM4FVARBPROC)
cogl_get_proc_address ("glUniform4fvARB");
ctx->drv.pf_glUniform1iARB =
(COGL_PFNGLUNIFORM1IARBPROC)
cogl_get_proc_address ("glUniform1iARB");
ctx->drv.pf_glUniform2iARB =
(COGL_PFNGLUNIFORM2IARBPROC)
cogl_get_proc_address ("glUniform2iARB");
ctx->drv.pf_glUniform3iARB =
(COGL_PFNGLUNIFORM3IARBPROC)
cogl_get_proc_address ("glUniform3iARB");
ctx->drv.pf_glUniform4iARB =
(COGL_PFNGLUNIFORM4IARBPROC)
cogl_get_proc_address ("glUniform4iARB");
ctx->drv.pf_glUniform1ivARB =
(COGL_PFNGLUNIFORM1IVARBPROC)
cogl_get_proc_address ("glUniform1ivARB");
ctx->drv.pf_glUniform2ivARB =
(COGL_PFNGLUNIFORM2IVARBPROC)
cogl_get_proc_address ("glUniform2ivARB");
ctx->drv.pf_glUniform3ivARB =
(COGL_PFNGLUNIFORM3IVARBPROC)
cogl_get_proc_address ("glUniform3ivARB");
ctx->drv.pf_glUniform4ivARB =
(COGL_PFNGLUNIFORM4IVARBPROC)
cogl_get_proc_address ("glUniform4ivARB");
ctx->drv.pf_glUniformMatrix2fvARB =
(COGL_PFNGLUNIFORMMATRIX2FVARBPROC)
cogl_get_proc_address ("glUniformMatrix2fvARB");
ctx->drv.pf_glUniformMatrix3fvARB =
(COGL_PFNGLUNIFORMMATRIX3FVARBPROC)
cogl_get_proc_address ("glUniformMatrix3fvARB");
ctx->drv.pf_glUniformMatrix4fvARB =
(COGL_PFNGLUNIFORMMATRIX4FVARBPROC)
cogl_get_proc_address ("glUniformMatrix4fvARB");
if (ctx->drv.pf_glCreateProgramObjectARB &&
ctx->drv.pf_glCreateShaderObjectARB &&
ctx->drv.pf_glShaderSourceARB &&
ctx->drv.pf_glCompileShaderARB &&
ctx->drv.pf_glAttachObjectARB &&
ctx->drv.pf_glLinkProgramARB &&
ctx->drv.pf_glUseProgramObjectARB &&
ctx->drv.pf_glGetUniformLocationARB &&
ctx->drv.pf_glDeleteObjectARB &&
ctx->drv.pf_glGetInfoLogARB &&
ctx->drv.pf_glGetObjectParameterivARB &&
ctx->drv.pf_glUniform1fARB &&
ctx->drv.pf_glUniform2fARB &&
ctx->drv.pf_glUniform3fARB &&
ctx->drv.pf_glUniform4fARB &&
ctx->drv.pf_glUniform1fvARB &&
ctx->drv.pf_glUniform2fvARB &&
ctx->drv.pf_glUniform3fvARB &&
ctx->drv.pf_glUniform4fvARB &&
ctx->drv.pf_glUniform1iARB &&
ctx->drv.pf_glUniform2iARB &&
ctx->drv.pf_glUniform3iARB &&
ctx->drv.pf_glUniform4iARB &&
ctx->drv.pf_glUniform1ivARB &&
ctx->drv.pf_glUniform2ivARB &&
ctx->drv.pf_glUniform3ivARB &&
ctx->drv.pf_glUniform4ivARB &&
ctx->drv.pf_glUniformMatrix2fvARB &&
ctx->drv.pf_glUniformMatrix3fvARB &&
ctx->drv.pf_glUniformMatrix4fvARB &&
ctx->drv.pf_glVertexAttribPointerARB &&
ctx->drv.pf_glEnableVertexAttribArrayARB &&
ctx->drv.pf_glDisableVertexAttribArrayARB)
flags |= COGL_FEATURE_SHADERS_GLSL;
}
fbo_ARB = cogl_check_extension ("GL_ARB_framebuffer_object", gl_extensions);
if (fbo_ARB)
suffix = "";
else
{
fbo_EXT = cogl_check_extension ("GL_EXT_framebuffer_object", gl_extensions);
if (fbo_EXT)
suffix = "EXT";
}
if (fbo_ARB || fbo_EXT)
{
CoglGLSymbolTableEntry symbol_table[] = {
{"glGenRenderbuffers", &ctx->drv.pf_glGenRenderbuffers},
{"glDeleteRenderbuffers", &ctx->drv.pf_glDeleteRenderbuffers},
{"glBindRenderbuffer", &ctx->drv.pf_glBindRenderbuffer},
{"glRenderbufferStorage", &ctx->drv.pf_glRenderbufferStorage},
{"glGenFramebuffers", &ctx->drv.pf_glGenFramebuffers},
{"glBindFramebuffer", &ctx->drv.pf_glBindFramebuffer},
{"glFramebufferTexture2D", &ctx->drv.pf_glFramebufferTexture2D},
{"glFramebufferRenderbuffer", &ctx->drv.pf_glFramebufferRenderbuffer},
{"glCheckFramebufferStatus", &ctx->drv.pf_glCheckFramebufferStatus},
{"glDeleteFramebuffers", &ctx->drv.pf_glDeleteFramebuffers},
{"glGenerateMipmap", &ctx->drv.pf_glGenerateMipmap},
{NULL, NULL}
};
if (_cogl_resolve_gl_symbols (symbol_table, suffix))
flags |= COGL_FEATURE_OFFSCREEN;
}
if (cogl_check_extension ("GL_EXT_framebuffer_blit", gl_extensions))
{
ctx->drv.pf_glBlitFramebufferEXT =
(COGL_PFNGLBLITFRAMEBUFFEREXTPROC)
cogl_get_proc_address ("glBlitFramebufferEXT");
if (ctx->drv.pf_glBlitFramebufferEXT)
flags |= COGL_FEATURE_OFFSCREEN_BLIT;
}
if (cogl_check_extension ("GL_EXT_framebuffer_multisample", gl_extensions))
{
ctx->drv.pf_glRenderbufferStorageMultisampleEXT =
(COGL_PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)
cogl_get_proc_address ("glRenderbufferStorageMultisampleEXT");
if (ctx->drv.pf_glRenderbufferStorageMultisampleEXT)
flags |= COGL_FEATURE_OFFSCREEN_MULTISAMPLE;
}
GE( glGetIntegerv (GL_STENCIL_BITS, &num_stencil_bits) );
/* We need at least three stencil bits to combine clips */
if (num_stencil_bits > 2)
@ -464,83 +237,11 @@ _cogl_features_init (void)
if (max_clip_planes >= 4)
flags |= COGL_FEATURE_FOUR_CLIP_PLANES;
if (cogl_check_extension ("GL_ARB_vertex_buffer_object", gl_extensions))
{
ctx->drv.pf_glGenBuffersARB =
(COGL_PFNGLGENBUFFERSARBPROC)
cogl_get_proc_address ("glGenBuffersARB");
ctx->drv.pf_glBindBufferARB =
(COGL_PFNGLBINDBUFFERARBPROC)
cogl_get_proc_address ("glBindBufferARB");
ctx->drv.pf_glBufferDataARB =
(COGL_PFNGLBUFFERDATAARBPROC)
cogl_get_proc_address ("glBufferDataARB");
ctx->drv.pf_glBufferSubDataARB =
(COGL_PFNGLBUFFERSUBDATAARBPROC)
cogl_get_proc_address ("glBufferSubDataARB");
ctx->drv.pf_glDeleteBuffersARB =
(COGL_PFNGLDELETEBUFFERSARBPROC)
cogl_get_proc_address ("glDeleteBuffersARB");
ctx->drv.pf_glMapBufferARB =
(COGL_PFNGLMAPBUFFERARBPROC)
cogl_get_proc_address ("glMapBufferARB");
ctx->drv.pf_glUnmapBufferARB =
(COGL_PFNGLUNMAPBUFFERARBPROC)
cogl_get_proc_address ("glUnmapBufferARB");
if (ctx->drv.pf_glGenBuffersARB
&& ctx->drv.pf_glBindBufferARB
&& ctx->drv.pf_glBufferDataARB
&& ctx->drv.pf_glBufferSubDataARB
&& ctx->drv.pf_glDeleteBuffersARB
&& ctx->drv.pf_glMapBufferARB
&& ctx->drv.pf_glUnmapBufferARB)
flags |= COGL_FEATURE_VBOS;
}
/* These should always be available because they are defined in GL
1.2, but we can't call it directly because under Windows
functions > 1.1 aren't exported */
ctx->drv.pf_glDrawRangeElements =
(COGL_PFNGLDRAWRANGEELEMENTSPROC)
cogl_get_proc_address ("glDrawRangeElements");
ctx->drv.pf_glBlendEquation =
(COGL_PFNGLBLENDEQUATIONPROC)
cogl_get_proc_address ("glBlendEquation");
ctx->drv.pf_glBlendColor =
(COGL_PFNGLBLENDCOLORPROC)
cogl_get_proc_address ("glBlendColor");
/* Available in 1.3 or in the GL_ARB_multitexture extension */
if (COGL_CHECK_GL_VERSION (gl_major, gl_minor, 1, 3))
{
ctx->drv.pf_glActiveTexture =
(COGL_PFNGLACTIVETEXTUREPROC)
cogl_get_proc_address ("glActiveTexture");
ctx->drv.pf_glClientActiveTexture =
(COGL_PFNGLCLIENTACTIVETEXTUREPROC)
cogl_get_proc_address ("glClientActiveTexture");
}
else if (cogl_check_extension ("GL_ARB_multitexture", gl_extensions))
{
ctx->drv.pf_glActiveTexture =
(COGL_PFNGLACTIVETEXTUREPROC)
cogl_get_proc_address ("glActiveTextureARB");
ctx->drv.pf_glClientActiveTexture =
(COGL_PFNGLCLIENTACTIVETEXTUREPROC)
cogl_get_proc_address ("glClientActiveTextureARB");
}
/* Available in 1.4 */
if (COGL_CHECK_GL_VERSION (gl_major, gl_minor, 1, 4))
ctx->drv.pf_glBlendFuncSeparate =
(COGL_PFNGLBLENDFUNCSEPARATEPROC)
cogl_get_proc_address ("glBlendFuncSeparate");
/* Available in 2.0 */
if (COGL_CHECK_GL_VERSION (gl_major, gl_minor, 2, 0))
ctx->drv.pf_glBlendEquationSeparate =
(COGL_PFNGLBLENDEQUATIONSEPARATEPROC)
cogl_get_proc_address ("glBlendEquationSeparate");
for (i = 0; i < G_N_ELEMENTS (cogl_feature_data); i++)
if (_cogl_feature_check (cogl_feature_data + i,
gl_major, gl_minor,
gl_extensions))
flags |= cogl_feature_data[i].feature_flags;
/* Cache features */
ctx->feature_flags = flags;

View File

@ -28,22 +28,19 @@
#include "cogl-context.h"
#include "cogl-gles2-wrapper.h"
#define COGL_FEATURE_BEGIN(a, b, c, d, e, f)
#define COGL_FEATURE_FUNCTION(ret, name, args) \
_context->drv.pf_ ## name = NULL;
#define COGL_FEATURE_END()
void
_cogl_create_context_driver (CoglContext *context)
_cogl_create_context_driver (CoglContext *_context)
{
context->drv.pf_glGenRenderbuffers = NULL;
context->drv.pf_glBindRenderbuffer = NULL;
context->drv.pf_glRenderbufferStorage = NULL;
context->drv.pf_glGenFramebuffers = NULL;
context->drv.pf_glBindFramebuffer = NULL;
context->drv.pf_glFramebufferTexture2D = NULL;
context->drv.pf_glFramebufferRenderbuffer = NULL;
context->drv.pf_glCheckFramebufferStatus = NULL;
context->drv.pf_glDeleteFramebuffers = NULL;
#include "cogl-feature-functions.h"
/* Init the GLES2 wrapper */
#ifdef HAVE_COGL_GLES2
cogl_gles2_wrapper_init (&context->drv.gles2);
cogl_gles2_wrapper_init (&_context->drv.gles2);
#endif
}

View File

@ -27,25 +27,26 @@
#include "cogl.h"
#include "cogl-gles2-wrapper.h"
typedef struct _CoglContextDriver
#define COGL_FEATURE_BEGIN(a, b, c, d, e, f)
#define COGL_FEATURE_FUNCTION(ret, name, args) \
ret (* pf_ ## name) args;
#define COGL_FEATURE_END()
typedef struct _CoglContextDriver
{
COGL_PFNGLGENRENDERBUFFERSPROC pf_glGenRenderbuffers;
COGL_PFNGLDELETERENDERBUFFERSPROC pf_glDeleteRenderbuffers;
COGL_PFNGLBINDRENDERBUFFERPROC pf_glBindRenderbuffer;
COGL_PFNGLRENDERBUFFERSTORAGEPROC pf_glRenderbufferStorage;
COGL_PFNGLGENFRAMEBUFFERSPROC pf_glGenFramebuffers;
COGL_PFNGLBINDFRAMEBUFFERPROC pf_glBindFramebuffer;
COGL_PFNGLFRAMEBUFFERTEXTURE2DPROC pf_glFramebufferTexture2D;
COGL_PFNGLFRAMEBUFFERRENDERBUFFERPROC pf_glFramebufferRenderbuffer;
COGL_PFNGLCHECKFRAMEBUFFERSTATUSPROC pf_glCheckFramebufferStatus;
COGL_PFNGLDELETEFRAMEBUFFERSPROC pf_glDeleteFramebuffers;
COGL_PFNGLGENERATEMIPMAPPROC pf_glGenerateMipmap;
/* This defines a list of function pointers */
#include "cogl-feature-functions.h"
#ifdef HAVE_COGL_GLES2
CoglGles2Wrapper gles2;
#endif
} CoglContextDriver;
#undef COGL_FEATURE_BEGIN
#undef COGL_FEATURE_FUNCTION
#undef COGL_FEATURE_END
#endif /* __COGL_CONTEXT_DRIVER_H */

View File

@ -633,76 +633,6 @@ G_BEGIN_DECLS
#define CGL_SHININESS 0x1601
#endif
/* Extension function prototypes */
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
typedef void
(APIENTRYP COGL_PFNGLGENRENDERBUFFERSPROC)
(GLsizei n,
GLuint *renderbuffers);
typedef void
(APIENTRYP COGL_PFNGLBINDRENDERBUFFERPROC)
(GLenum target,
GLuint renderbuffer);
typedef void
(APIENTRYP COGL_PFNGLRENDERBUFFERSTORAGEPROC)
(GLenum target,
GLenum internalformat,
GLsizei width,
GLsizei height);
typedef void
(APIENTRYP COGL_PFNGLGENFRAMEBUFFERSPROC)
(GLsizei n,
GLuint *framebuffers);
typedef void
(APIENTRYP COGL_PFNGLBINDFRAMEBUFFERPROC)
(GLenum target,
GLuint framebuffer);
typedef void
(APIENTRYP COGL_PFNGLFRAMEBUFFERTEXTURE2DPROC)
(GLenum target,
GLenum attachment,
GLenum textarget,
GLuint texture,
GLint level);
typedef void
(APIENTRYP COGL_PFNGLFRAMEBUFFERRENDERBUFFERPROC)
(GLenum target,
GLenum attachment,
GLenum renderbuffertarget,
GLuint renderbuffer);
typedef GLenum
(APIENTRYP COGL_PFNGLCHECKFRAMEBUFFERSTATUSPROC)
(GLenum target);
typedef void
(APIENTRYP COGL_PFNGLDELETEFRAMEBUFFERSPROC)
(GLsizei n,
const GLuint *framebuffers);
typedef void
(APIENTRYP COGL_PFNGLDELETERENDERBUFFERSPROC)
(GLsizei n,
const GLuint *renderbuffers);
typedef void
(APIENTRYP COGL_PFNGLGENERATEMIPMAPPROC)
(GLenum target);
G_END_DECLS
#endif

View File

@ -0,0 +1,72 @@
/*
* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* 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 */
"OES:\0",
"framebuffer_object\0",
COGL_FEATURE_OFFSCREEN)
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_END ()

View File

@ -30,12 +30,7 @@
#include "cogl.h"
#include "cogl-internal.h"
#include "cogl-context.h"
typedef struct _CoglGLSymbolTableEntry
{
const char *name;
void *ptr;
} CoglGLSymbolTableEntry;
#include "cogl-feature-private.h"
gboolean
cogl_check_extension (const gchar *name, const gchar *ext)
@ -62,26 +57,6 @@ cogl_check_extension (const gchar *name, const gchar *ext)
return FALSE;
}
gboolean
_cogl_resolve_gl_symbols (CoglGLSymbolTableEntry *symbol_table,
const char *suffix)
{
int i;
gboolean status = TRUE;
for (i = 0; symbol_table[i].name; i++)
{
char *full_name = g_strdup_printf ("%s%s", symbol_table[i].name, suffix);
*((CoglFuncPtr *)symbol_table[i].ptr) = cogl_get_proc_address (full_name);
g_free (full_name);
if (!*((CoglFuncPtr *)symbol_table[i].ptr))
{
status = FALSE;
break;
}
}
return status;
}
gboolean
_cogl_check_driver_valid (GError **error)
{
@ -89,6 +64,34 @@ _cogl_check_driver_valid (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) \
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() \
};
#include "cogl-feature-functions.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) \
{ min_gl_major, min_gl_minor, namespaces, \
extension_names, feature_flags, \
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.h"
};
void
_cogl_features_init (void)
{
@ -96,32 +99,17 @@ _cogl_features_init (void)
int max_clip_planes = 0;
GLint num_stencil_bits = 0;
const char *gl_extensions;
int i;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
gl_extensions = (const char*) glGetString (GL_EXTENSIONS);
if (cogl_check_extension ("GL_OES_framebuffer_object", gl_extensions))
{
g_assert (0);
CoglGLSymbolTableEntry symbol_table[] = {
{"glGenRenderbuffers", &ctx->drv.pf_glGenRenderbuffers},
{"glDeleteRenderbuffers", &ctx->drv.pf_glDeleteRenderbuffers},
{"glBindRenderbuffer", &ctx->drv.pf_glBindRenderbuffer},
{"glRenderbufferStorage", &ctx->drv.pf_glRenderbufferStorage},
{"glGenFramebuffers", &ctx->drv.pf_glGenFramebuffers},
{"glBindFramebuffer", &ctx->drv.pf_glBindFramebuffer},
{"glFramebufferTexture2D", &ctx->drv.pf_glFramebufferTexture2D},
{"glFramebufferRenderbuffer", &ctx->drv.pf_glFramebufferRenderbuffer},
{"glCheckFramebufferStatus", &ctx->drv.pf_glCheckFramebufferStatus},
{"glDeleteFramebuffers", &ctx->drv.pf_glDeleteFramebuffers},
{"glGenerateMipmap", &ctx->drv.pf_glGenerateMipmap},
{NULL, NULL}
};
if (_cogl_resolve_gl_symbols (symbol_table, "OES"))
flags |= COGL_FEATURE_OFFSCREEN;
}
for (i = 0; i < G_N_ELEMENTS (cogl_feature_data); i++)
if (_cogl_feature_check (cogl_feature_data + i,
0, 0,
gl_extensions))
flags |= cogl_feature_data[i].feature_flags;
GE( glGetIntegerv (GL_STENCIL_BITS, &num_stencil_bits) );
/* We need at least three stencil bits to combine clips */