Make the CoglContext structure a bit more maintainable

This moves most of cogl-context.{c.h} to cogl/common with some driver
specific members now living in a CoglContextDriver struct.  Driver specific
context initialization and typedefs now live in
cogl/{gl,gles}/cogl-context-driver.{c,h}

Driver specific members can be found under ctx->drv.stuff
This commit is contained in:
Robert Bragg 2009-07-28 01:34:33 +01:00
parent 157eb437ba
commit 2eea83de75
25 changed files with 417 additions and 601 deletions

View File

@ -58,6 +58,8 @@ libclutter_cogl_common_la_SOURCES = \
$(top_builddir)/clutter/cogl/common/cogl-enum-types.h \ $(top_builddir)/clutter/cogl/common/cogl-enum-types.h \
$(top_builddir)/clutter/cogl/common/cogl-enum-types.c \ $(top_builddir)/clutter/cogl/common/cogl-enum-types.c \
cogl-handle.h \ cogl-handle.h \
cogl-context.h \
cogl-context.c \
cogl-internal.h \ cogl-internal.h \
cogl.c \ cogl.c \
cogl-util.h \ cogl-util.h \

View File

@ -243,7 +243,7 @@ validate_blend_statements (CoglBlendStringStatement *statements,
if (n_statements == 2) if (n_statements == 2)
{ {
/* glBlendEquationSeperate is GL 2.0 only */ /* glBlendEquationSeperate is GL 2.0 only */
if (!ctx->pf_glBlendEquationSeparate && if (!ctx->drv.pf_glBlendEquationSeparate &&
statements[0].function->type != statements[1].function->type) statements[0].function->type != statements[1].function->type)
{ {
error_string = "Separate blend functions for the RGB an A " error_string = "Separate blend functions for the RGB an A "

View File

@ -32,15 +32,16 @@
#include "cogl-texture-private.h" #include "cogl-texture-private.h"
#include "cogl-material-private.h" #include "cogl-material-private.h"
#include "cogl-gles2-wrapper.h"
#include <string.h> #include <string.h>
extern void
_cogl_create_context_driver (CoglContext *context);
static CoglContext *_context = NULL; static CoglContext *_context = NULL;
static gboolean gl_is_indirect = FALSE; static gboolean gl_is_indirect = FALSE;
static gboolean static gboolean
cogl_create_context () cogl_create_context (void)
{ {
GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 }; GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 };
gulong enable_flags = 0; gulong enable_flags = 0;
@ -68,15 +69,14 @@ cogl_create_context ()
_context->default_gl_texture_2d_tex = COGL_INVALID_HANDLE; _context->default_gl_texture_2d_tex = COGL_INVALID_HANDLE;
_context->default_gl_texture_rect_tex = COGL_INVALID_HANDLE; _context->default_gl_texture_rect_tex = COGL_INVALID_HANDLE;
_context->texture_download_material = COGL_INVALID_HANDLE;
_context->journal = g_array_new (FALSE, FALSE, sizeof (CoglJournalEntry)); _context->journal = g_array_new (FALSE, FALSE, sizeof (CoglJournalEntry));
_context->logged_vertices = g_array_new (FALSE, FALSE, sizeof (GLfloat)); _context->logged_vertices = g_array_new (FALSE, FALSE, sizeof (GLfloat));
_context->polygon_vertices = g_array_new (FALSE, FALSE,
sizeof (CoglTextureGLVertex));
_context->current_material = NULL; _context->current_material = NULL;
_context->current_material_flags = 0; _context->current_material_flags = 0;
memset (&_context->current_material_flush_options,
0, sizeof (CoglMaterialFlushOptions));
_context->current_layers = g_array_new (FALSE, FALSE, _context->current_layers = g_array_new (FALSE, FALSE,
sizeof (CoglLayerInfo)); sizeof (CoglLayerInfo));
_context->n_texcoord_arrays_enabled = 0; _context->n_texcoord_arrays_enabled = 0;
@ -91,10 +91,14 @@ cogl_create_context ()
_context->last_path = 0; _context->last_path = 0;
_context->stencil_material = cogl_material_new (); _context->stencil_material = cogl_material_new ();
/* Init the GLES2 wrapper */ _context->in_begin_gl_block = FALSE;
#ifdef HAVE_COGL_GLES2
cogl_gles2_wrapper_init (&_context->gles2); _context->viewport_width = 0;
#endif _context->viewport_height = 0;
_context->quad_indices_byte = COGL_INVALID_HANDLE;
_context->quad_indices_short = COGL_INVALID_HANDLE;
_context->quad_indices_short_len = 0;
/* Initialise the clip stack */ /* Initialise the clip stack */
_cogl_clip_stack_state_init (); _cogl_clip_stack_state_init ();
@ -102,23 +106,26 @@ cogl_create_context ()
/* Initialise matrix stack */ /* Initialise matrix stack */
_cogl_current_matrix_state_init (); _cogl_current_matrix_state_init ();
/* Initialise the driver specific state */
_cogl_create_context_driver (_context);
/* Create default textures used for fall backs */ /* Create default textures used for fall backs */
_context->default_gl_texture_2d_tex = _context->default_gl_texture_2d_tex =
cogl_texture_new_from_data (1, /* width */ cogl_texture_new_from_data (1, /* width */
1, /* height */ 1, /* height */
COGL_TEXTURE_NO_SLICING, /* flags */ COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_RGBA_8888, /* data format */ COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* data format */
/* internal format */ /* internal format */
COGL_PIXEL_FORMAT_RGBA_8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE,
0, /* auto calc row stride */ 0, /* auto calc row stride */
default_texture_data); default_texture_data);
_context->default_gl_texture_rect_tex = _context->default_gl_texture_rect_tex =
cogl_texture_new_from_data (1, /* width */ cogl_texture_new_from_data (1, /* width */
1, /* height */ 1, /* height */
COGL_TEXTURE_NO_SLICING, /* flags */ COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_RGBA_8888, /* data format */ COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* data format */
/* internal format */ /* internal format */
COGL_PIXEL_FORMAT_RGBA_8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE,
0, /* auto calc row stride */ 0, /* auto calc row stride */
default_texture_data); default_texture_data);
@ -128,10 +135,6 @@ cogl_create_context ()
_cogl_material_get_cogl_enable_flags (_context->source_material); _cogl_material_get_cogl_enable_flags (_context->source_material);
cogl_enable (enable_flags); cogl_enable (enable_flags);
_context->quad_indices_byte = COGL_INVALID_HANDLE;
_context->quad_indices_short = COGL_INVALID_HANDLE;
_context->quad_indices_short_len = 0;
return TRUE; return TRUE;
} }
@ -161,8 +164,6 @@ _cogl_destroy_context ()
if (_context->logged_vertices) if (_context->logged_vertices)
g_array_free (_context->logged_vertices, TRUE); g_array_free (_context->logged_vertices, TRUE);
if (_context->polygon_vertices)
g_array_free (_context->polygon_vertices, TRUE);
if (_context->current_layers) if (_context->current_layers)
g_array_free (_context->current_layers, TRUE); g_array_free (_context->current_layers, TRUE);

View File

@ -24,12 +24,12 @@
#ifndef __COGL_CONTEXT_H #ifndef __COGL_CONTEXT_H
#define __COGL_CONTEXT_H #define __COGL_CONTEXT_H
#include "cogl-context-driver.h"
#include "cogl-primitives.h" #include "cogl-primitives.h"
#include "cogl-clip-stack.h" #include "cogl-clip-stack.h"
#include "cogl-matrix-stack.h" #include "cogl-matrix-stack.h"
#include "cogl-current-matrix.h" #include "cogl-current-matrix.h"
#include "cogl-material-private.h" #include "cogl-material-private.h"
#include "cogl-gles2-wrapper.h"
typedef struct typedef struct
{ {
@ -48,15 +48,15 @@ typedef struct
{ {
/* Features cache */ /* Features cache */
CoglFeatureFlags feature_flags; CoglFeatureFlags feature_flags;
gboolean features_cached;
/* Enable cache */ /* Enable cache */
gulong enable_flags; gulong enable_flags;
guint8 color_alpha; guint8 color_alpha;
guint features_cached : 1; gboolean enable_backface_culling;
guint enable_backface_culling : 1;
guint indirect : 1; gboolean indirect;
guint in_begin_gl_block : 1;
/* Client-side matrix stack or NULL if none */ /* Client-side matrix stack or NULL if none */
CoglMatrixMode matrix_mode; CoglMatrixMode matrix_mode;
@ -73,7 +73,6 @@ typedef struct
/* Textures */ /* Textures */
CoglHandle default_gl_texture_2d_tex; CoglHandle default_gl_texture_2d_tex;
CoglHandle default_gl_texture_rect_tex; CoglHandle default_gl_texture_rect_tex;
CoglHandle texture_download_material;
/* Batching geometry... */ /* Batching geometry... */
/* We journal the texture rectangles we want to submit to OpenGL so /* We journal the texture rectangles we want to submit to OpenGL so
@ -111,16 +110,12 @@ typedef struct
guint quad_indices_short_len; guint quad_indices_short_len;
CoglHandle quad_indices_short; CoglHandle quad_indices_short;
gfloat viewport_width; gboolean in_begin_gl_block;
gfloat viewport_height;
#ifdef HAVE_COGL_GLES2 guint viewport_width;
CoglGles2Wrapper gles2; guint viewport_height;
/* Viewport store for FBOs. Needed because glPushAttrib() isn't CoglContextDriver drv;
supported */
GLint viewport_store[4];
#endif
} CoglContext; } CoglContext;
CoglContext * CoglContext *

View File

@ -49,12 +49,12 @@
#endif #endif
#ifdef HAVE_COGL_GL #ifdef HAVE_COGL_GL
#define glActiveTexture ctx->pf_glActiveTexture #define glActiveTexture ctx->drv.pf_glActiveTexture
#define glClientActiveTexture ctx->pf_glClientActiveTexture #define glClientActiveTexture ctx->drv.pf_glClientActiveTexture
#define glBlendFuncSeparate ctx->pf_glBlendFuncSeparate #define glBlendFuncSeparate ctx->drv.pf_glBlendFuncSeparate
#define glBlendEquation ctx->pf_glBlendEquation #define glBlendEquation ctx->drv.pf_glBlendEquation
#define glBlendColor ctx->pf_glBlendColor #define glBlendColor ctx->drv.pf_glBlendColor
#define glBlendEquationSeparate ctx->pf_glBlendEquationSeparate #define glBlendEquationSeparate ctx->drv.pf_glBlendEquationSeparate
#endif #endif
static void _cogl_material_free (CoglMaterial *tex); static void _cogl_material_free (CoglMaterial *tex);
@ -1547,7 +1547,7 @@ _cogl_material_flush_base_gl_state (CoglMaterial *material,
gboolean have_blend_equation_seperate = TRUE; gboolean have_blend_equation_seperate = TRUE;
#elif defined (HAVE_COGL_GL) #elif defined (HAVE_COGL_GL)
gboolean have_blend_equation_seperate = FALSE; gboolean have_blend_equation_seperate = FALSE;
if (ctx->pf_glBlendEquationSeparate) /* Only GL 2.0 + */ if (ctx->drv.pf_glBlendEquationSeparate) /* Only GL 2.0 + */
have_blend_equation_seperate = TRUE; have_blend_equation_seperate = TRUE;
#endif #endif

View File

@ -40,12 +40,12 @@
#ifdef HAVE_COGL_GL #ifdef HAVE_COGL_GL
#define glGenBuffers ctx->pf_glGenBuffersARB #define glGenBuffers ctx->drv.pf_glGenBuffersARB
#define glBindBuffer ctx->pf_glBindBufferARB #define glBindBuffer ctx->drv.pf_glBindBufferARB
#define glBufferData ctx->pf_glBufferDataARB #define glBufferData ctx->drv.pf_glBufferDataARB
#define glBufferSubData ctx->pf_glBufferSubDataARB #define glBufferSubData ctx->drv.pf_glBufferSubDataARB
#define glDeleteBuffers ctx->pf_glDeleteBuffersARB #define glDeleteBuffers ctx->drv.pf_glDeleteBuffersARB
#define glClientActiveTexture ctx->pf_glClientActiveTexture #define glClientActiveTexture ctx->drv.pf_glClientActiveTexture
#elif defined (HAVE_COGL_GLES2) #elif defined (HAVE_COGL_GLES2)

View File

@ -149,15 +149,15 @@
#if defined (HAVE_COGL_GL) #if defined (HAVE_COGL_GL)
#define glGenBuffers ctx->pf_glGenBuffersARB #define glGenBuffers ctx->drv.pf_glGenBuffersARB
#define glBindBuffer ctx->pf_glBindBufferARB #define glBindBuffer ctx->drv.pf_glBindBufferARB
#define glBufferData ctx->pf_glBufferDataARB #define glBufferData ctx->drv.pf_glBufferDataARB
#define glBufferSubData ctx->pf_glBufferSubDataARB #define glBufferSubData ctx->drv.pf_glBufferSubDataARB
#define glDeleteBuffers ctx->pf_glDeleteBuffersARB #define glDeleteBuffers ctx->drv.pf_glDeleteBuffersARB
#define glMapBuffer ctx->pf_glMapBufferARB #define glMapBuffer ctx->drv.pf_glMapBufferARB
#define glUnmapBuffer ctx->pf_glUnmapBufferARB #define glUnmapBuffer ctx->drv.pf_glUnmapBufferARB
#define glActiveTexture ctx->pf_glActiveTexture #define glActiveTexture ctx->drv.pf_glActiveTexture
#define glClientActiveTexture ctx->pf_glClientActiveTexture #define glClientActiveTexture ctx->drv.pf_glClientActiveTexture
#ifndef GL_ARRAY_BUFFER #ifndef GL_ARRAY_BUFFER
#define GL_ARRAY_BUFFER GL_ARRAY_BUFFER_ARB #define GL_ARRAY_BUFFER GL_ARRAY_BUFFER_ARB
#endif #endif
@ -174,9 +174,9 @@
#if defined (HAVE_COGL_GL) #if defined (HAVE_COGL_GL)
#define glVertexAttribPointer ctx->pf_glVertexAttribPointerARB #define glVertexAttribPointer ctx->drv.pf_glVertexAttribPointerARB
#define glEnableVertexAttribArray ctx->pf_glEnableVertexAttribArrayARB #define glEnableVertexAttribArray ctx->drv.pf_glEnableVertexAttribArrayARB
#define glDisableVertexAttribArray ctx->pf_glEnableVertexAttribArrayARB #define glDisableVertexAttribArray ctx->drv.pf_glEnableVertexAttribArrayARB
#define MAY_HAVE_PROGRAMABLE_GL #define MAY_HAVE_PROGRAMABLE_GL
#elif defined (HAVE_COGL_GLES2) #elif defined (HAVE_COGL_GLES2)
@ -197,7 +197,7 @@
#else /* HAVE_COGL_GL */ #else /* HAVE_COGL_GL */
#define glDrawRangeElements(mode, start, end, count, type, indices) \ #define glDrawRangeElements(mode, start, end, count, type, indices) \
ctx->pf_glDrawRangeElements (mode, start, end, count, type, indices) ctx->drv.pf_glDrawRangeElements (mode, start, end, count, type, indices)
#endif /* HAVE_COGL_GL */ #endif /* HAVE_COGL_GL */

View File

@ -49,7 +49,7 @@ typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
#endif #endif
#ifdef HAVE_COGL_GL #ifdef HAVE_COGL_GL
#define glClientActiveTexture ctx->pf_glClientActiveTexture #define glClientActiveTexture ctx->drv.pf_glClientActiveTexture
#endif #endif
#ifdef COGL_GL_DEBUG #ifdef COGL_GL_DEBUG

View File

@ -33,7 +33,7 @@ cogl_sources = \
cogl-fbo.c \ cogl-fbo.c \
cogl-shader.c \ cogl-shader.c \
cogl-program.c \ cogl-program.c \
cogl-context.c \ cogl-context-driver.c \
$(NULL) $(NULL)
INCLUDES = \ INCLUDES = \

View File

@ -0,0 +1,84 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,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 "cogl-context.h"
void
_cogl_create_context_driver (CoglContext *_context)
{
_context->drv.pf_glGenRenderbuffersEXT = NULL;
_context->drv.pf_glBindRenderbufferEXT = NULL;
_context->drv.pf_glRenderbufferStorageEXT = NULL;
_context->drv.pf_glGenFramebuffersEXT = NULL;
_context->drv.pf_glBindFramebufferEXT = NULL;
_context->drv.pf_glFramebufferTexture2DEXT = NULL;
_context->drv.pf_glFramebufferRenderbufferEXT = NULL;
_context->drv.pf_glCheckFramebufferStatusEXT = NULL;
_context->drv.pf_glDeleteFramebuffersEXT = 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;
}

View File

@ -21,99 +21,13 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#ifndef __COGL_CONTEXT_H #ifndef __COGL_CONTEXT_DRIVER_H
#define __COGL_CONTEXT_H #define __COGL_CONTEXT_DRIVER_H
#include "cogl-primitives.h" #include "cogl.h"
#include "cogl-clip-stack.h"
#include "cogl-matrix-stack.h"
#include "cogl-current-matrix.h"
#include "cogl-material-private.h"
typedef struct typedef struct _CoglContextDriver
{ {
GLfloat v[3];
GLfloat t[2];
GLubyte c[4];
} CoglTextureGLVertex;
typedef struct
{
CoglBufferTarget target;
CoglHandle offscreen;
} CoglDrawBufferState;
typedef struct
{
/* Features cache */
CoglFeatureFlags feature_flags;
gboolean features_cached;
/* Enable cache */
gulong enable_flags;
guint8 color_alpha;
gboolean enable_backface_culling;
gboolean indirect;
/* Client-side matrix stack or NULL if none */
CoglMatrixMode matrix_mode;
CoglMatrixStack *modelview_stack;
CoglMatrixStack *projection_stack;
/* Cache of inverse projection matrix */
float inverse_projection[16];
/* Materials */
CoglHandle default_material;
CoglHandle source_material;
/* Textures */
CoglHandle default_gl_texture_2d_tex;
CoglHandle default_gl_texture_rect_tex;
/* Batching geometry... */
/* We journal the texture rectangles we want to submit to OpenGL so
* we have an oppertunity to optimise the final order so that we
* can batch things together. */
GArray *journal;
GArray *logged_vertices;
/* Some simple caching, to minimize state changes... */
CoglHandle current_material;
gulong current_material_flags;
CoglMaterialFlushOptions current_material_flush_options;
GArray *current_layers;
guint n_texcoord_arrays_enabled;
/* Framebuffer objects */
GSList *draw_buffer_stack;
/* Clip stack */
CoglClipStackState clip;
/* Primitives */
floatVec2 path_start;
floatVec2 path_pen;
GArray *path_nodes;
guint last_path;
floatVec2 path_nodes_min;
floatVec2 path_nodes_max;
CoglHandle stencil_material;
/* Pre-generated VBOs containing indices to generate GL_TRIANGLES
out of a vertex array of quads */
CoglHandle quad_indices_byte;
guint quad_indices_short_len;
CoglHandle quad_indices_short;
gboolean in_begin_gl_block;
guint viewport_width;
guint viewport_height;
/* Relying on glext.h to define these */ /* Relying on glext.h to define these */
COGL_PFNGLGENRENDERBUFFERSEXTPROC pf_glGenRenderbuffersEXT; COGL_PFNGLGENRENDERBUFFERSEXTPROC pf_glGenRenderbuffersEXT;
COGL_PFNGLDELETERENDERBUFFERSEXTPROC pf_glDeleteRenderbuffersEXT; COGL_PFNGLDELETERENDERBUFFERSEXTPROC pf_glDeleteRenderbuffersEXT;
@ -182,16 +96,8 @@ typedef struct
COGL_PFNGLBLENDCOLORPROC pf_glBlendColor; COGL_PFNGLBLENDCOLORPROC pf_glBlendColor;
COGL_PFNGLBLENDFUNCSEPARATEPROC pf_glBlendFuncSeparate; COGL_PFNGLBLENDFUNCSEPARATEPROC pf_glBlendFuncSeparate;
COGL_PFNGLBLENDEQUATIONSEPARATEPROC pf_glBlendEquationSeparate; COGL_PFNGLBLENDEQUATIONSEPARATEPROC pf_glBlendEquationSeparate;
} CoglContext;
CoglContext * } CoglContextDriver;
_cogl_context_get_default ();
/* Obtains the context and returns retval if NULL */ #endif /* __COGL_CONTEXT_DRIVER_H */
#define _COGL_GET_CONTEXT(ctxvar, retval) \
CoglContext *ctxvar = _cogl_context_get_default (); \
if (ctxvar == NULL) return retval;
#define NO_RETVAL
#endif /* __COGL_CONTEXT_H */

View File

@ -1,259 +0,0 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,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 "cogl.h"
#include "cogl-internal.h"
#include "cogl-util.h"
#include "cogl-context.h"
#include "cogl-texture-private.h"
#include "cogl-material-private.h"
#include <string.h>
static CoglContext *_context = NULL;
static gboolean gl_is_indirect = FALSE;
static gboolean
cogl_create_context ()
{
GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 };
gulong enable_flags = 0;
CoglDrawBufferState *draw_buffer;
if (_context != NULL)
return FALSE;
/* Allocate context memory */
_context = (CoglContext*) g_malloc (sizeof (CoglContext));
/* Init default values */
_context->feature_flags = 0;
_context->features_cached = FALSE;
_context->enable_flags = 0;
_context->color_alpha = 0;
_context->enable_backface_culling = FALSE;
_context->indirect = gl_is_indirect;
_context->default_material = cogl_material_new ();
_context->source_material = NULL;
_context->default_gl_texture_2d_tex = COGL_INVALID_HANDLE;
_context->default_gl_texture_rect_tex = COGL_INVALID_HANDLE;
_context->journal = g_array_new (FALSE, FALSE, sizeof (CoglJournalEntry));
_context->logged_vertices = g_array_new (FALSE, FALSE, sizeof (GLfloat));
_context->current_material = NULL;
_context->current_material_flags = 0;
memset (&_context->current_material_flush_options,
0, sizeof (CoglMaterialFlushOptions));
_context->current_layers = g_array_new (FALSE, FALSE,
sizeof (CoglLayerInfo));
_context->n_texcoord_arrays_enabled = 0;
draw_buffer = g_slice_new0 (CoglDrawBufferState);
draw_buffer->target = COGL_WINDOW_BUFFER;
draw_buffer->offscreen = COGL_INVALID_HANDLE;
_context->draw_buffer_stack =
g_slist_prepend (NULL, draw_buffer);
_context->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode));
_context->last_path = 0;
_context->stencil_material = cogl_material_new ();
_context->in_begin_gl_block = FALSE;
_context->viewport_width = 0;
_context->viewport_height = 0;
_context->pf_glGenRenderbuffersEXT = NULL;
_context->pf_glBindRenderbufferEXT = NULL;
_context->pf_glRenderbufferStorageEXT = NULL;
_context->pf_glGenFramebuffersEXT = NULL;
_context->pf_glBindFramebufferEXT = NULL;
_context->pf_glFramebufferTexture2DEXT = NULL;
_context->pf_glFramebufferRenderbufferEXT = NULL;
_context->pf_glCheckFramebufferStatusEXT = NULL;
_context->pf_glDeleteFramebuffersEXT = NULL;
_context->pf_glBlitFramebufferEXT = NULL;
_context->pf_glRenderbufferStorageMultisampleEXT = NULL;
_context->pf_glCreateProgramObjectARB = NULL;
_context->pf_glCreateShaderObjectARB = NULL;
_context->pf_glShaderSourceARB = NULL;
_context->pf_glCompileShaderARB = NULL;
_context->pf_glAttachObjectARB = NULL;
_context->pf_glLinkProgramARB = NULL;
_context->pf_glUseProgramObjectARB = NULL;
_context->pf_glGetUniformLocationARB = NULL;
_context->pf_glDeleteObjectARB = NULL;
_context->pf_glGetInfoLogARB = NULL;
_context->pf_glGetObjectParameterivARB = NULL;
_context->pf_glUniform1fARB = NULL;
_context->pf_glUniform2fARB = NULL;
_context->pf_glUniform3fARB = NULL;
_context->pf_glUniform4fARB = NULL;
_context->pf_glUniform1fvARB = NULL;
_context->pf_glUniform2fvARB = NULL;
_context->pf_glUniform3fvARB = NULL;
_context->pf_glUniform4fvARB = NULL;
_context->pf_glUniform1iARB = NULL;
_context->pf_glUniform2iARB = NULL;
_context->pf_glUniform3iARB = NULL;
_context->pf_glUniform4iARB = NULL;
_context->pf_glUniform1ivARB = NULL;
_context->pf_glUniform2ivARB = NULL;
_context->pf_glUniform3ivARB = NULL;
_context->pf_glUniform4ivARB = NULL;
_context->pf_glUniformMatrix2fvARB = NULL;
_context->pf_glUniformMatrix3fvARB = NULL;
_context->pf_glUniformMatrix4fvARB = NULL;
_context->pf_glDrawRangeElements = NULL;
_context->pf_glActiveTexture = NULL;
_context->pf_glClientActiveTexture = NULL;
_context->pf_glBlendFuncSeparate = NULL;
_context->pf_glBlendEquationSeparate = NULL;
/* Initialise the clip stack */
_cogl_clip_stack_state_init ();
/* Initialise matrix stack */
_cogl_current_matrix_state_init ();
/* Create default textures used for fall backs */
_context->default_gl_texture_2d_tex =
cogl_texture_new_from_data (1, /* width */
1, /* height */
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* data format */
/* internal format */
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
0, /* auto calc row stride */
default_texture_data);
_context->default_gl_texture_rect_tex =
cogl_texture_new_from_data (1, /* width */
1, /* height */
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_RGBA_8888_PRE, /* data format */
/* internal format */
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
0, /* auto calc row stride */
default_texture_data);
cogl_set_source (_context->default_material);
_cogl_material_flush_gl_state (_context->source_material, NULL);
enable_flags =
_cogl_material_get_cogl_enable_flags (_context->source_material);
cogl_enable (enable_flags);
_context->quad_indices_byte = COGL_INVALID_HANDLE;
_context->quad_indices_short = COGL_INVALID_HANDLE;
_context->quad_indices_short_len = 0;
return TRUE;
}
void
_cogl_destroy_context ()
{
if (_context == NULL)
return;
_cogl_clip_stack_state_destroy ();
_cogl_current_matrix_state_destroy ();
if (_context->path_nodes)
g_array_free (_context->path_nodes, TRUE);
if (_context->default_gl_texture_2d_tex)
cogl_handle_unref (_context->default_gl_texture_2d_tex);
if (_context->default_gl_texture_rect_tex)
cogl_handle_unref (_context->default_gl_texture_rect_tex);
if (_context->default_material)
cogl_handle_unref (_context->default_material);
if (_context->journal)
g_array_free (_context->journal, TRUE);
if (_context->logged_vertices)
g_array_free (_context->logged_vertices, TRUE);
if (_context->current_layers)
g_array_free (_context->current_layers, TRUE);
if (_context->quad_indices_byte)
cogl_handle_unref (_context->quad_indices_byte);
if (_context->quad_indices_short)
cogl_handle_unref (_context->quad_indices_short);
g_free (_context);
}
CoglContext *
_cogl_context_get_default ()
{
/* Create if doesn't exist yet */
if (_context == NULL)
cogl_create_context ();
return _context;
}
/**
* _cogl_set_indirect_context:
* @indirect: TRUE if GL context is indirect
*
* Advises COGL that the GL context is indirect (commands are sent
* over a socket). COGL uses this information to try to avoid
* round-trips in its use of GL, for example.
*
* This function cannot be called "on the fly," only before COGL
* initializes.
*/
void
_cogl_set_indirect_context (gboolean indirect)
{
/* we get called multiple times if someone creates
* more than the default stage
*/
if (_context != NULL)
{
if (indirect != _context->indirect)
g_warning ("Right now all stages will be treated as "
"either direct or indirect, ignoring attempt "
"to change to indirect=%d", indirect);
return;
}
gl_is_indirect = indirect;
}

View File

@ -34,18 +34,18 @@
#include "cogl-handle.h" #include "cogl-handle.h"
/* Expecting EXT functions not to be defined - redirect to pointers in context */ /* Expecting EXT functions not to be defined - redirect to pointers in context */
#define glGenRenderbuffersEXT ctx->pf_glGenRenderbuffersEXT #define glGenRenderbuffersEXT ctx->drv.pf_glGenRenderbuffersEXT
#define glDeleteRenderbuffersEXT ctx->pf_glDeleteRenderbuffersEXT #define glDeleteRenderbuffersEXT ctx->drv.pf_glDeleteRenderbuffersEXT
#define glBindRenderbufferEXT ctx->pf_glBindRenderbufferEXT #define glBindRenderbufferEXT ctx->drv.pf_glBindRenderbufferEXT
#define glRenderbufferStorageEXT ctx->pf_glRenderbufferStorageEXT #define glRenderbufferStorageEXT ctx->drv.pf_glRenderbufferStorageEXT
#define glGenFramebuffersEXT ctx->pf_glGenFramebuffersEXT #define glGenFramebuffersEXT ctx->drv.pf_glGenFramebuffersEXT
#define glBindFramebufferEXT ctx->pf_glBindFramebufferEXT #define glBindFramebufferEXT ctx->drv.pf_glBindFramebufferEXT
#define glFramebufferTexture2DEXT ctx->pf_glFramebufferTexture2DEXT #define glFramebufferTexture2DEXT ctx->drv.pf_glFramebufferTexture2DEXT
#define glFramebufferRenderbufferEXT ctx->pf_glFramebufferRenderbufferEXT #define glFramebufferRenderbufferEXT ctx->drv.pf_glFramebufferRenderbufferEXT
#define glCheckFramebufferStatusEXT ctx->pf_glCheckFramebufferStatusEXT #define glCheckFramebufferStatusEXT ctx->drv.pf_glCheckFramebufferStatusEXT
#define glDeleteFramebuffersEXT ctx->pf_glDeleteFramebuffersEXT #define glDeleteFramebuffersEXT ctx->drv.pf_glDeleteFramebuffersEXT
#define glBlitFramebufferEXT ctx->pf_glBlitFramebufferEXT #define glBlitFramebufferEXT ctx->drv.pf_glBlitFramebufferEXT
#define glRenderbufferStorageMultisampleEXT ctx->pf_glRenderbufferStorageMultisampleEXT #define glRenderbufferStorageMultisampleEXT ctx->drv.pf_glRenderbufferStorageMultisampleEXT
#ifndef GL_READ_FRAMEBUFFER_EXT #ifndef GL_READ_FRAMEBUFFER_EXT
#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 #define GL_READ_FRAMEBUFFER_EXT 0x8CA8

View File

@ -37,7 +37,7 @@
#define _COGL_MAX_BEZ_RECURSE_DEPTH 16 #define _COGL_MAX_BEZ_RECURSE_DEPTH 16
#define glClientActiveTexture ctx->pf_glClientActiveTexture #define glClientActiveTexture ctx->drv.pf_glClientActiveTexture
void void
_cogl_path_add_node (gboolean new_sub_path, _cogl_path_add_node (gboolean new_sub_path,

View File

@ -35,31 +35,31 @@
#include <glib.h> #include <glib.h>
/* Expecting ARB functions not to be defined */ /* Expecting ARB functions not to be defined */
#define glCreateProgramObjectARB ctx->pf_glCreateProgramObjectARB #define glCreateProgramObjectARB ctx->drv.pf_glCreateProgramObjectARB
#define glAttachObjectARB ctx->pf_glAttachObjectARB #define glAttachObjectARB ctx->drv.pf_glAttachObjectARB
#define glUseProgramObjectARB ctx->pf_glUseProgramObjectARB #define glUseProgramObjectARB ctx->drv.pf_glUseProgramObjectARB
#define glLinkProgramARB ctx->pf_glLinkProgramARB #define glLinkProgramARB ctx->drv.pf_glLinkProgramARB
#define glGetUniformLocationARB ctx->pf_glGetUniformLocationARB #define glGetUniformLocationARB ctx->drv.pf_glGetUniformLocationARB
#define glUniform1fARB ctx->pf_glUniform1fARB #define glUniform1fARB ctx->drv.pf_glUniform1fARB
#define glUniform2fARB ctx->pf_glUniform2fARB #define glUniform2fARB ctx->drv.pf_glUniform2fARB
#define glUniform3fARB ctx->pf_glUniform3fARB #define glUniform3fARB ctx->drv.pf_glUniform3fARB
#define glUniform4fARB ctx->pf_glUniform4fARB #define glUniform4fARB ctx->drv.pf_glUniform4fARB
#define glUniform1fvARB ctx->pf_glUniform1fvARB #define glUniform1fvARB ctx->drv.pf_glUniform1fvARB
#define glUniform2fvARB ctx->pf_glUniform2fvARB #define glUniform2fvARB ctx->drv.pf_glUniform2fvARB
#define glUniform3fvARB ctx->pf_glUniform3fvARB #define glUniform3fvARB ctx->drv.pf_glUniform3fvARB
#define glUniform4fvARB ctx->pf_glUniform4fvARB #define glUniform4fvARB ctx->drv.pf_glUniform4fvARB
#define glUniform1iARB ctx->pf_glUniform1iARB #define glUniform1iARB ctx->drv.pf_glUniform1iARB
#define glUniform2iARB ctx->pf_glUniform2iARB #define glUniform2iARB ctx->drv.pf_glUniform2iARB
#define glUniform3iARB ctx->pf_glUniform3iARB #define glUniform3iARB ctx->drv.pf_glUniform3iARB
#define glUniform4iARB ctx->pf_glUniform4iARB #define glUniform4iARB ctx->drv.pf_glUniform4iARB
#define glUniform1ivARB ctx->pf_glUniform1ivARB #define glUniform1ivARB ctx->drv.pf_glUniform1ivARB
#define glUniform2ivARB ctx->pf_glUniform2ivARB #define glUniform2ivARB ctx->drv.pf_glUniform2ivARB
#define glUniform3ivARB ctx->pf_glUniform3ivARB #define glUniform3ivARB ctx->drv.pf_glUniform3ivARB
#define glUniform4ivARB ctx->pf_glUniform4ivARB #define glUniform4ivARB ctx->drv.pf_glUniform4ivARB
#define glUniformMatrix2fvARB ctx->pf_glUniformMatrix2fvARB #define glUniformMatrix2fvARB ctx->drv.pf_glUniformMatrix2fvARB
#define glUniformMatrix3fvARB ctx->pf_glUniformMatrix3fvARB #define glUniformMatrix3fvARB ctx->drv.pf_glUniformMatrix3fvARB
#define glUniformMatrix4fvARB ctx->pf_glUniformMatrix4fvARB #define glUniformMatrix4fvARB ctx->drv.pf_glUniformMatrix4fvARB
#define glDeleteObjectARB ctx->pf_glDeleteObjectARB #define glDeleteObjectARB ctx->drv.pf_glDeleteObjectARB
static void _cogl_program_free (CoglProgram *program); static void _cogl_program_free (CoglProgram *program);

View File

@ -34,12 +34,12 @@
#include <glib.h> #include <glib.h>
/* Expecting ARB functions not to be defined */ /* Expecting ARB functions not to be defined */
#define glCreateShaderObjectARB ctx->pf_glCreateShaderObjectARB #define glCreateShaderObjectARB ctx->drv.pf_glCreateShaderObjectARB
#define glGetObjectParameterivARB ctx->pf_glGetObjectParameterivARB #define glGetObjectParameterivARB ctx->drv.pf_glGetObjectParameterivARB
#define glGetInfoLogARB ctx->pf_glGetInfoLogARB #define glGetInfoLogARB ctx->drv.pf_glGetInfoLogARB
#define glCompileShaderARB ctx->pf_glCompileShaderARB #define glCompileShaderARB ctx->drv.pf_glCompileShaderARB
#define glShaderSourceARB ctx->pf_glShaderSourceARB #define glShaderSourceARB ctx->drv.pf_glShaderSourceARB
#define glDeleteObjectARB ctx->pf_glDeleteObjectARB #define glDeleteObjectARB ctx->drv.pf_glDeleteObjectARB
static void _cogl_shader_free (CoglShader *shader); static void _cogl_shader_free (CoglShader *shader);

View File

@ -45,7 +45,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#define glGenerateMipmap ctx->pf_glGenerateMipmapEXT #define glGenerateMipmap ctx->drv.pf_glGenerateMipmapEXT
void void
_cogl_texture_driver_bind (GLenum gl_target, _cogl_texture_driver_bind (GLenum gl_target,

View File

@ -188,251 +188,251 @@ _cogl_features_init (void)
cogl_check_extension ("GL_ARB_vertex_shader", gl_extensions) && cogl_check_extension ("GL_ARB_vertex_shader", gl_extensions) &&
cogl_check_extension ("GL_ARB_fragment_shader", gl_extensions)) cogl_check_extension ("GL_ARB_fragment_shader", gl_extensions))
{ {
ctx->pf_glCreateProgramObjectARB = ctx->drv.pf_glCreateProgramObjectARB =
(COGL_PFNGLCREATEPROGRAMOBJECTARBPROC) (COGL_PFNGLCREATEPROGRAMOBJECTARBPROC)
cogl_get_proc_address ("glCreateProgramObjectARB"); cogl_get_proc_address ("glCreateProgramObjectARB");
ctx->pf_glCreateShaderObjectARB = ctx->drv.pf_glCreateShaderObjectARB =
(COGL_PFNGLCREATESHADEROBJECTARBPROC) (COGL_PFNGLCREATESHADEROBJECTARBPROC)
cogl_get_proc_address ("glCreateShaderObjectARB"); cogl_get_proc_address ("glCreateShaderObjectARB");
ctx->pf_glShaderSourceARB = ctx->drv.pf_glShaderSourceARB =
(COGL_PFNGLSHADERSOURCEARBPROC) (COGL_PFNGLSHADERSOURCEARBPROC)
cogl_get_proc_address ("glShaderSourceARB"); cogl_get_proc_address ("glShaderSourceARB");
ctx->pf_glCompileShaderARB = ctx->drv.pf_glCompileShaderARB =
(COGL_PFNGLCOMPILESHADERARBPROC) (COGL_PFNGLCOMPILESHADERARBPROC)
cogl_get_proc_address ("glCompileShaderARB"); cogl_get_proc_address ("glCompileShaderARB");
ctx->pf_glAttachObjectARB = ctx->drv.pf_glAttachObjectARB =
(COGL_PFNGLATTACHOBJECTARBPROC) (COGL_PFNGLATTACHOBJECTARBPROC)
cogl_get_proc_address ("glAttachObjectARB"); cogl_get_proc_address ("glAttachObjectARB");
ctx->pf_glLinkProgramARB = ctx->drv.pf_glLinkProgramARB =
(COGL_PFNGLLINKPROGRAMARBPROC) (COGL_PFNGLLINKPROGRAMARBPROC)
cogl_get_proc_address ("glLinkProgramARB"); cogl_get_proc_address ("glLinkProgramARB");
ctx->pf_glUseProgramObjectARB = ctx->drv.pf_glUseProgramObjectARB =
(COGL_PFNGLUSEPROGRAMOBJECTARBPROC) (COGL_PFNGLUSEPROGRAMOBJECTARBPROC)
cogl_get_proc_address ("glUseProgramObjectARB"); cogl_get_proc_address ("glUseProgramObjectARB");
ctx->pf_glGetUniformLocationARB = ctx->drv.pf_glGetUniformLocationARB =
(COGL_PFNGLGETUNIFORMLOCATIONARBPROC) (COGL_PFNGLGETUNIFORMLOCATIONARBPROC)
cogl_get_proc_address ("glGetUniformLocationARB"); cogl_get_proc_address ("glGetUniformLocationARB");
ctx->pf_glDeleteObjectARB = ctx->drv.pf_glDeleteObjectARB =
(COGL_PFNGLDELETEOBJECTARBPROC) (COGL_PFNGLDELETEOBJECTARBPROC)
cogl_get_proc_address ("glDeleteObjectARB"); cogl_get_proc_address ("glDeleteObjectARB");
ctx->pf_glGetInfoLogARB = ctx->drv.pf_glGetInfoLogARB =
(COGL_PFNGLGETINFOLOGARBPROC) (COGL_PFNGLGETINFOLOGARBPROC)
cogl_get_proc_address ("glGetInfoLogARB"); cogl_get_proc_address ("glGetInfoLogARB");
ctx->pf_glGetObjectParameterivARB = ctx->drv.pf_glGetObjectParameterivARB =
(COGL_PFNGLGETOBJECTPARAMETERIVARBPROC) (COGL_PFNGLGETOBJECTPARAMETERIVARBPROC)
cogl_get_proc_address ("glGetObjectParameterivARB"); cogl_get_proc_address ("glGetObjectParameterivARB");
ctx->pf_glUniform1fARB = ctx->drv.pf_glUniform1fARB =
(COGL_PFNGLUNIFORM1FARBPROC) (COGL_PFNGLUNIFORM1FARBPROC)
cogl_get_proc_address ("glUniform1fARB"); cogl_get_proc_address ("glUniform1fARB");
ctx->pf_glVertexAttribPointerARB = ctx->drv.pf_glVertexAttribPointerARB =
(COGL_PFNGLVERTEXATTRIBPOINTERARBPROC) (COGL_PFNGLVERTEXATTRIBPOINTERARBPROC)
cogl_get_proc_address ("glVertexAttribPointerARB"); cogl_get_proc_address ("glVertexAttribPointerARB");
ctx->pf_glEnableVertexAttribArrayARB = ctx->drv.pf_glEnableVertexAttribArrayARB =
(COGL_PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (COGL_PFNGLENABLEVERTEXATTRIBARRAYARBPROC)
cogl_get_proc_address ("glEnableVertexAttribArrayARB"); cogl_get_proc_address ("glEnableVertexAttribArrayARB");
ctx->pf_glDisableVertexAttribArrayARB = ctx->drv.pf_glDisableVertexAttribArrayARB =
(COGL_PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (COGL_PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)
cogl_get_proc_address ("glDisableVertexAttribArrayARB"); cogl_get_proc_address ("glDisableVertexAttribArrayARB");
ctx->pf_glUniform2fARB = ctx->drv.pf_glUniform2fARB =
(COGL_PFNGLUNIFORM2FARBPROC) (COGL_PFNGLUNIFORM2FARBPROC)
cogl_get_proc_address ("glUniform2fARB"); cogl_get_proc_address ("glUniform2fARB");
ctx->pf_glUniform3fARB = ctx->drv.pf_glUniform3fARB =
(COGL_PFNGLUNIFORM3FARBPROC) (COGL_PFNGLUNIFORM3FARBPROC)
cogl_get_proc_address ("glUniform3fARB"); cogl_get_proc_address ("glUniform3fARB");
ctx->pf_glUniform4fARB = ctx->drv.pf_glUniform4fARB =
(COGL_PFNGLUNIFORM4FARBPROC) (COGL_PFNGLUNIFORM4FARBPROC)
cogl_get_proc_address ("glUniform4fARB"); cogl_get_proc_address ("glUniform4fARB");
ctx->pf_glUniform1fvARB = ctx->drv.pf_glUniform1fvARB =
(COGL_PFNGLUNIFORM1FVARBPROC) (COGL_PFNGLUNIFORM1FVARBPROC)
cogl_get_proc_address ("glUniform1fvARB"); cogl_get_proc_address ("glUniform1fvARB");
ctx->pf_glUniform2fvARB = ctx->drv.pf_glUniform2fvARB =
(COGL_PFNGLUNIFORM2FVARBPROC) (COGL_PFNGLUNIFORM2FVARBPROC)
cogl_get_proc_address ("glUniform2fvARB"); cogl_get_proc_address ("glUniform2fvARB");
ctx->pf_glUniform3fvARB = ctx->drv.pf_glUniform3fvARB =
(COGL_PFNGLUNIFORM3FVARBPROC) (COGL_PFNGLUNIFORM3FVARBPROC)
cogl_get_proc_address ("glUniform3fvARB"); cogl_get_proc_address ("glUniform3fvARB");
ctx->pf_glUniform4fvARB = ctx->drv.pf_glUniform4fvARB =
(COGL_PFNGLUNIFORM4FVARBPROC) (COGL_PFNGLUNIFORM4FVARBPROC)
cogl_get_proc_address ("glUniform4fvARB"); cogl_get_proc_address ("glUniform4fvARB");
ctx->pf_glUniform1iARB = ctx->drv.pf_glUniform1iARB =
(COGL_PFNGLUNIFORM1IARBPROC) (COGL_PFNGLUNIFORM1IARBPROC)
cogl_get_proc_address ("glUniform1iARB"); cogl_get_proc_address ("glUniform1iARB");
ctx->pf_glUniform2iARB = ctx->drv.pf_glUniform2iARB =
(COGL_PFNGLUNIFORM2IARBPROC) (COGL_PFNGLUNIFORM2IARBPROC)
cogl_get_proc_address ("glUniform2iARB"); cogl_get_proc_address ("glUniform2iARB");
ctx->pf_glUniform3iARB = ctx->drv.pf_glUniform3iARB =
(COGL_PFNGLUNIFORM3IARBPROC) (COGL_PFNGLUNIFORM3IARBPROC)
cogl_get_proc_address ("glUniform3iARB"); cogl_get_proc_address ("glUniform3iARB");
ctx->pf_glUniform4iARB = ctx->drv.pf_glUniform4iARB =
(COGL_PFNGLUNIFORM4IARBPROC) (COGL_PFNGLUNIFORM4IARBPROC)
cogl_get_proc_address ("glUniform4iARB"); cogl_get_proc_address ("glUniform4iARB");
ctx->pf_glUniform1ivARB = ctx->drv.pf_glUniform1ivARB =
(COGL_PFNGLUNIFORM1IVARBPROC) (COGL_PFNGLUNIFORM1IVARBPROC)
cogl_get_proc_address ("glUniform1ivARB"); cogl_get_proc_address ("glUniform1ivARB");
ctx->pf_glUniform2ivARB = ctx->drv.pf_glUniform2ivARB =
(COGL_PFNGLUNIFORM2IVARBPROC) (COGL_PFNGLUNIFORM2IVARBPROC)
cogl_get_proc_address ("glUniform2ivARB"); cogl_get_proc_address ("glUniform2ivARB");
ctx->pf_glUniform3ivARB = ctx->drv.pf_glUniform3ivARB =
(COGL_PFNGLUNIFORM3IVARBPROC) (COGL_PFNGLUNIFORM3IVARBPROC)
cogl_get_proc_address ("glUniform3ivARB"); cogl_get_proc_address ("glUniform3ivARB");
ctx->pf_glUniform4ivARB = ctx->drv.pf_glUniform4ivARB =
(COGL_PFNGLUNIFORM4IVARBPROC) (COGL_PFNGLUNIFORM4IVARBPROC)
cogl_get_proc_address ("glUniform4ivARB"); cogl_get_proc_address ("glUniform4ivARB");
ctx->pf_glUniformMatrix2fvARB = ctx->drv.pf_glUniformMatrix2fvARB =
(COGL_PFNGLUNIFORMMATRIX2FVARBPROC) (COGL_PFNGLUNIFORMMATRIX2FVARBPROC)
cogl_get_proc_address ("glUniformMatrix2fvARB"); cogl_get_proc_address ("glUniformMatrix2fvARB");
ctx->pf_glUniformMatrix3fvARB = ctx->drv.pf_glUniformMatrix3fvARB =
(COGL_PFNGLUNIFORMMATRIX3FVARBPROC) (COGL_PFNGLUNIFORMMATRIX3FVARBPROC)
cogl_get_proc_address ("glUniformMatrix3fvARB"); cogl_get_proc_address ("glUniformMatrix3fvARB");
ctx->pf_glUniformMatrix4fvARB = ctx->drv.pf_glUniformMatrix4fvARB =
(COGL_PFNGLUNIFORMMATRIX4FVARBPROC) (COGL_PFNGLUNIFORMMATRIX4FVARBPROC)
cogl_get_proc_address ("glUniformMatrix4fvARB"); cogl_get_proc_address ("glUniformMatrix4fvARB");
if (ctx->pf_glCreateProgramObjectARB && if (ctx->drv.pf_glCreateProgramObjectARB &&
ctx->pf_glCreateShaderObjectARB && ctx->drv.pf_glCreateShaderObjectARB &&
ctx->pf_glShaderSourceARB && ctx->drv.pf_glShaderSourceARB &&
ctx->pf_glCompileShaderARB && ctx->drv.pf_glCompileShaderARB &&
ctx->pf_glAttachObjectARB && ctx->drv.pf_glAttachObjectARB &&
ctx->pf_glLinkProgramARB && ctx->drv.pf_glLinkProgramARB &&
ctx->pf_glUseProgramObjectARB && ctx->drv.pf_glUseProgramObjectARB &&
ctx->pf_glGetUniformLocationARB && ctx->drv.pf_glGetUniformLocationARB &&
ctx->pf_glDeleteObjectARB && ctx->drv.pf_glDeleteObjectARB &&
ctx->pf_glGetInfoLogARB && ctx->drv.pf_glGetInfoLogARB &&
ctx->pf_glGetObjectParameterivARB && ctx->drv.pf_glGetObjectParameterivARB &&
ctx->pf_glUniform1fARB && ctx->drv.pf_glUniform1fARB &&
ctx->pf_glUniform2fARB && ctx->drv.pf_glUniform2fARB &&
ctx->pf_glUniform3fARB && ctx->drv.pf_glUniform3fARB &&
ctx->pf_glUniform4fARB && ctx->drv.pf_glUniform4fARB &&
ctx->pf_glUniform1fvARB && ctx->drv.pf_glUniform1fvARB &&
ctx->pf_glUniform2fvARB && ctx->drv.pf_glUniform2fvARB &&
ctx->pf_glUniform3fvARB && ctx->drv.pf_glUniform3fvARB &&
ctx->pf_glUniform4fvARB && ctx->drv.pf_glUniform4fvARB &&
ctx->pf_glUniform1iARB && ctx->drv.pf_glUniform1iARB &&
ctx->pf_glUniform2iARB && ctx->drv.pf_glUniform2iARB &&
ctx->pf_glUniform3iARB && ctx->drv.pf_glUniform3iARB &&
ctx->pf_glUniform4iARB && ctx->drv.pf_glUniform4iARB &&
ctx->pf_glUniform1ivARB && ctx->drv.pf_glUniform1ivARB &&
ctx->pf_glUniform2ivARB && ctx->drv.pf_glUniform2ivARB &&
ctx->pf_glUniform3ivARB && ctx->drv.pf_glUniform3ivARB &&
ctx->pf_glUniform4ivARB && ctx->drv.pf_glUniform4ivARB &&
ctx->pf_glUniformMatrix2fvARB && ctx->drv.pf_glUniformMatrix2fvARB &&
ctx->pf_glUniformMatrix3fvARB && ctx->drv.pf_glUniformMatrix3fvARB &&
ctx->pf_glUniformMatrix4fvARB && ctx->drv.pf_glUniformMatrix4fvARB &&
ctx->pf_glVertexAttribPointerARB && ctx->drv.pf_glVertexAttribPointerARB &&
ctx->pf_glEnableVertexAttribArrayARB && ctx->drv.pf_glEnableVertexAttribArrayARB &&
ctx->pf_glDisableVertexAttribArrayARB) ctx->drv.pf_glDisableVertexAttribArrayARB)
flags |= COGL_FEATURE_SHADERS_GLSL; flags |= COGL_FEATURE_SHADERS_GLSL;
} }
if (cogl_check_extension ("GL_EXT_framebuffer_object", gl_extensions) || if (cogl_check_extension ("GL_EXT_framebuffer_object", gl_extensions) ||
cogl_check_extension ("GL_ARB_framebuffer_object", gl_extensions)) cogl_check_extension ("GL_ARB_framebuffer_object", gl_extensions))
{ {
ctx->pf_glGenRenderbuffersEXT = ctx->drv.pf_glGenRenderbuffersEXT =
(COGL_PFNGLGENRENDERBUFFERSEXTPROC) (COGL_PFNGLGENRENDERBUFFERSEXTPROC)
cogl_get_proc_address ("glGenRenderbuffersEXT"); cogl_get_proc_address ("glGenRenderbuffersEXT");
ctx->pf_glDeleteRenderbuffersEXT = ctx->drv.pf_glDeleteRenderbuffersEXT =
(COGL_PFNGLDELETERENDERBUFFERSEXTPROC) (COGL_PFNGLDELETERENDERBUFFERSEXTPROC)
cogl_get_proc_address ("glDeleteRenderbuffersEXT"); cogl_get_proc_address ("glDeleteRenderbuffersEXT");
ctx->pf_glBindRenderbufferEXT = ctx->drv.pf_glBindRenderbufferEXT =
(COGL_PFNGLBINDRENDERBUFFEREXTPROC) (COGL_PFNGLBINDRENDERBUFFEREXTPROC)
cogl_get_proc_address ("glBindRenderbufferEXT"); cogl_get_proc_address ("glBindRenderbufferEXT");
ctx->pf_glRenderbufferStorageEXT = ctx->drv.pf_glRenderbufferStorageEXT =
(COGL_PFNGLRENDERBUFFERSTORAGEEXTPROC) (COGL_PFNGLRENDERBUFFERSTORAGEEXTPROC)
cogl_get_proc_address ("glRenderbufferStorageEXT"); cogl_get_proc_address ("glRenderbufferStorageEXT");
ctx->pf_glGenFramebuffersEXT = ctx->drv.pf_glGenFramebuffersEXT =
(COGL_PFNGLGENFRAMEBUFFERSEXTPROC) (COGL_PFNGLGENFRAMEBUFFERSEXTPROC)
cogl_get_proc_address ("glGenFramebuffersEXT"); cogl_get_proc_address ("glGenFramebuffersEXT");
ctx->pf_glBindFramebufferEXT = ctx->drv.pf_glBindFramebufferEXT =
(COGL_PFNGLBINDFRAMEBUFFEREXTPROC) (COGL_PFNGLBINDFRAMEBUFFEREXTPROC)
cogl_get_proc_address ("glBindFramebufferEXT"); cogl_get_proc_address ("glBindFramebufferEXT");
ctx->pf_glFramebufferTexture2DEXT = ctx->drv.pf_glFramebufferTexture2DEXT =
(COGL_PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (COGL_PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)
cogl_get_proc_address ("glFramebufferTexture2DEXT"); cogl_get_proc_address ("glFramebufferTexture2DEXT");
ctx->pf_glFramebufferRenderbufferEXT = ctx->drv.pf_glFramebufferRenderbufferEXT =
(COGL_PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (COGL_PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)
cogl_get_proc_address ("glFramebufferRenderbufferEXT"); cogl_get_proc_address ("glFramebufferRenderbufferEXT");
ctx->pf_glCheckFramebufferStatusEXT = ctx->drv.pf_glCheckFramebufferStatusEXT =
(COGL_PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (COGL_PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)
cogl_get_proc_address ("glCheckFramebufferStatusEXT"); cogl_get_proc_address ("glCheckFramebufferStatusEXT");
ctx->pf_glDeleteFramebuffersEXT = ctx->drv.pf_glDeleteFramebuffersEXT =
(COGL_PFNGLDELETEFRAMEBUFFERSEXTPROC) (COGL_PFNGLDELETEFRAMEBUFFERSEXTPROC)
cogl_get_proc_address ("glDeleteFramebuffersEXT"); cogl_get_proc_address ("glDeleteFramebuffersEXT");
ctx->pf_glGenerateMipmapEXT = ctx->drv.pf_glGenerateMipmapEXT =
(COGL_PFNGLGENERATEMIPMAPEXTPROC) (COGL_PFNGLGENERATEMIPMAPEXTPROC)
cogl_get_proc_address ("glGenerateMipmapEXT"); cogl_get_proc_address ("glGenerateMipmapEXT");
if (ctx->pf_glGenRenderbuffersEXT && if (ctx->drv.pf_glGenRenderbuffersEXT &&
ctx->pf_glBindRenderbufferEXT && ctx->drv.pf_glBindRenderbufferEXT &&
ctx->pf_glRenderbufferStorageEXT && ctx->drv.pf_glRenderbufferStorageEXT &&
ctx->pf_glGenFramebuffersEXT && ctx->drv.pf_glGenFramebuffersEXT &&
ctx->pf_glBindFramebufferEXT && ctx->drv.pf_glBindFramebufferEXT &&
ctx->pf_glFramebufferTexture2DEXT && ctx->drv.pf_glFramebufferTexture2DEXT &&
ctx->pf_glFramebufferRenderbufferEXT && ctx->drv.pf_glFramebufferRenderbufferEXT &&
ctx->pf_glCheckFramebufferStatusEXT && ctx->drv.pf_glCheckFramebufferStatusEXT &&
ctx->pf_glDeleteFramebuffersEXT && ctx->drv.pf_glDeleteFramebuffersEXT &&
ctx->pf_glGenerateMipmapEXT) ctx->drv.pf_glGenerateMipmapEXT)
flags |= COGL_FEATURE_OFFSCREEN; flags |= COGL_FEATURE_OFFSCREEN;
} }
if (cogl_check_extension ("GL_EXT_framebuffer_blit", gl_extensions)) if (cogl_check_extension ("GL_EXT_framebuffer_blit", gl_extensions))
{ {
ctx->pf_glBlitFramebufferEXT = ctx->drv.pf_glBlitFramebufferEXT =
(COGL_PFNGLBLITFRAMEBUFFEREXTPROC) (COGL_PFNGLBLITFRAMEBUFFEREXTPROC)
cogl_get_proc_address ("glBlitFramebufferEXT"); cogl_get_proc_address ("glBlitFramebufferEXT");
if (ctx->pf_glBlitFramebufferEXT) if (ctx->drv.pf_glBlitFramebufferEXT)
flags |= COGL_FEATURE_OFFSCREEN_BLIT; flags |= COGL_FEATURE_OFFSCREEN_BLIT;
} }
if (cogl_check_extension ("GL_EXT_framebuffer_multisample", gl_extensions)) if (cogl_check_extension ("GL_EXT_framebuffer_multisample", gl_extensions))
{ {
ctx->pf_glRenderbufferStorageMultisampleEXT = ctx->drv.pf_glRenderbufferStorageMultisampleEXT =
(COGL_PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (COGL_PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)
cogl_get_proc_address ("glRenderbufferStorageMultisampleEXT"); cogl_get_proc_address ("glRenderbufferStorageMultisampleEXT");
if (ctx->pf_glRenderbufferStorageMultisampleEXT) if (ctx->drv.pf_glRenderbufferStorageMultisampleEXT)
flags |= COGL_FEATURE_OFFSCREEN_MULTISAMPLE; flags |= COGL_FEATURE_OFFSCREEN_MULTISAMPLE;
} }
@ -447,64 +447,64 @@ _cogl_features_init (void)
if (cogl_check_extension ("GL_ARB_vertex_buffer_object", gl_extensions)) if (cogl_check_extension ("GL_ARB_vertex_buffer_object", gl_extensions))
{ {
ctx->pf_glGenBuffersARB = ctx->drv.pf_glGenBuffersARB =
(COGL_PFNGLGENBUFFERSARBPROC) (COGL_PFNGLGENBUFFERSARBPROC)
cogl_get_proc_address ("glGenBuffersARB"); cogl_get_proc_address ("glGenBuffersARB");
ctx->pf_glBindBufferARB = ctx->drv.pf_glBindBufferARB =
(COGL_PFNGLBINDBUFFERARBPROC) (COGL_PFNGLBINDBUFFERARBPROC)
cogl_get_proc_address ("glBindBufferARB"); cogl_get_proc_address ("glBindBufferARB");
ctx->pf_glBufferDataARB = ctx->drv.pf_glBufferDataARB =
(COGL_PFNGLBUFFERDATAARBPROC) (COGL_PFNGLBUFFERDATAARBPROC)
cogl_get_proc_address ("glBufferDataARB"); cogl_get_proc_address ("glBufferDataARB");
ctx->pf_glBufferSubDataARB = ctx->drv.pf_glBufferSubDataARB =
(COGL_PFNGLBUFFERSUBDATAARBPROC) (COGL_PFNGLBUFFERSUBDATAARBPROC)
cogl_get_proc_address ("glBufferSubDataARB"); cogl_get_proc_address ("glBufferSubDataARB");
ctx->pf_glDeleteBuffersARB = ctx->drv.pf_glDeleteBuffersARB =
(COGL_PFNGLDELETEBUFFERSARBPROC) (COGL_PFNGLDELETEBUFFERSARBPROC)
cogl_get_proc_address ("glDeleteBuffersARB"); cogl_get_proc_address ("glDeleteBuffersARB");
ctx->pf_glMapBufferARB = ctx->drv.pf_glMapBufferARB =
(COGL_PFNGLMAPBUFFERARBPROC) (COGL_PFNGLMAPBUFFERARBPROC)
cogl_get_proc_address ("glMapBufferARB"); cogl_get_proc_address ("glMapBufferARB");
ctx->pf_glUnmapBufferARB = ctx->drv.pf_glUnmapBufferARB =
(COGL_PFNGLUNMAPBUFFERARBPROC) (COGL_PFNGLUNMAPBUFFERARBPROC)
cogl_get_proc_address ("glUnmapBufferARB"); cogl_get_proc_address ("glUnmapBufferARB");
if (ctx->pf_glGenBuffersARB if (ctx->drv.pf_glGenBuffersARB
&& ctx->pf_glBindBufferARB && ctx->drv.pf_glBindBufferARB
&& ctx->pf_glBufferDataARB && ctx->drv.pf_glBufferDataARB
&& ctx->pf_glBufferSubDataARB && ctx->drv.pf_glBufferSubDataARB
&& ctx->pf_glDeleteBuffersARB && ctx->drv.pf_glDeleteBuffersARB
&& ctx->pf_glMapBufferARB && ctx->drv.pf_glMapBufferARB
&& ctx->pf_glUnmapBufferARB) && ctx->drv.pf_glUnmapBufferARB)
flags |= COGL_FEATURE_VBOS; flags |= COGL_FEATURE_VBOS;
} }
/* These should always be available because they are defined in GL /* These should always be available because they are defined in GL
1.2, but we can't call it directly because under Windows 1.2, but we can't call it directly because under Windows
functions > 1.1 aren't exported */ functions > 1.1 aren't exported */
ctx->pf_glDrawRangeElements = ctx->drv.pf_glDrawRangeElements =
(COGL_PFNGLDRAWRANGEELEMENTSPROC) (COGL_PFNGLDRAWRANGEELEMENTSPROC)
cogl_get_proc_address ("glDrawRangeElements"); cogl_get_proc_address ("glDrawRangeElements");
ctx->pf_glActiveTexture = ctx->drv.pf_glActiveTexture =
(COGL_PFNGLACTIVETEXTUREPROC) (COGL_PFNGLACTIVETEXTUREPROC)
cogl_get_proc_address ("glActiveTexture"); cogl_get_proc_address ("glActiveTexture");
ctx->pf_glClientActiveTexture = ctx->drv.pf_glClientActiveTexture =
(COGL_PFNGLCLIENTACTIVETEXTUREPROC) (COGL_PFNGLCLIENTACTIVETEXTUREPROC)
cogl_get_proc_address ("glClientActiveTexture"); cogl_get_proc_address ("glClientActiveTexture");
ctx->pf_glBlendEquation = ctx->drv.pf_glBlendEquation =
(COGL_PFNGLBLENDEQUATIONPROC) (COGL_PFNGLBLENDEQUATIONPROC)
cogl_get_proc_address ("glBlendEquation"); cogl_get_proc_address ("glBlendEquation");
ctx->pf_glBlendColor = ctx->drv.pf_glBlendColor =
(COGL_PFNGLBLENDCOLORPROC) (COGL_PFNGLBLENDCOLORPROC)
cogl_get_proc_address ("glBlendColor"); cogl_get_proc_address ("glBlendColor");
/* Available in 1.4 */ /* Available in 1.4 */
ctx->pf_glBlendFuncSeparate = ctx->drv.pf_glBlendFuncSeparate =
(COGL_PFNGLBLENDFUNCSEPARATEPROC) (COGL_PFNGLBLENDFUNCSEPARATEPROC)
cogl_get_proc_address ("glBlendFuncSeparate"); cogl_get_proc_address ("glBlendFuncSeparate");
/* Available in 2.0 */ /* Available in 2.0 */
ctx->pf_glBlendEquationSeparate = ctx->drv.pf_glBlendEquationSeparate =
(COGL_PFNGLBLENDEQUATIONSEPARATEPROC) (COGL_PFNGLBLENDEQUATIONSEPARATEPROC)
cogl_get_proc_address ("glBlendEquationSeparate"); cogl_get_proc_address ("glBlendEquationSeparate");

View File

@ -54,7 +54,7 @@ libclutter_cogl_gles_la_SOURCES = \
cogl-primitives.c \ cogl-primitives.c \
cogl-texture-driver.c \ cogl-texture-driver.c \
cogl-fbo.c \ cogl-fbo.c \
cogl-context.c \ cogl-context-driver.c \
cogl-gles2-wrapper.h \ cogl-gles2-wrapper.h \
cogl-program.h \ cogl-program.h \
cogl-program.c \ cogl-program.c \

View File

@ -0,0 +1,41 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,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 "cogl-context.h"
#include "cogl-gles2-wrapper.h"
void
_cogl_create_context_driver (CoglContext *context)
{
context->drv.texture_download_material = COGL_INVALID_HANDLE;
/* Init the GLES2 wrapper */
#ifdef HAVE_COGL_GLES2
cogl_gles2_wrapper_init (&context->drv.gles2);
#endif
}

View File

@ -0,0 +1,44 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,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_CONTEXT_DRIVER_H
#define __COGL_CONTEXT_DRIVER_H
#include "cogl-gles2-wrapper.h"
typedef struct _CoglContextDriver
{
CoglHandle texture_download_material;
#ifdef HAVE_COGL_GLES2
CoglGles2Wrapper gles2;
/* Viewport store for FBOs. Needed because glPushAttrib() isn't
supported */
GLint viewport_store[4];
#endif
} CoglContextDriver;
#endif /* __COGL_CONTEXT_DRIVER_H */

View File

@ -170,7 +170,7 @@ cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
{ {
/* Push the viewport and matrix setup if redirecting /* Push the viewport and matrix setup if redirecting
from a non-screen buffer */ from a non-screen buffer */
GE( glGetIntegerv (GL_VIEWPORT, ctx->viewport_store) ); GE( glGetIntegerv (GL_VIEWPORT, ctx->drv.viewport_store) );
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION); _cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_push (); _cogl_current_matrix_push ();
@ -223,8 +223,10 @@ cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
{ {
/* Pop viewport and matrices if redirecting back /* Pop viewport and matrices if redirecting back
from an offscreen buffer */ from an offscreen buffer */
GE( glViewport (ctx->viewport_store[0], ctx->viewport_store[1], GE( glViewport (ctx->drv.viewport_store[0],
ctx->viewport_store[2], ctx->viewport_store[3]) ); ctx->drv.viewport_store[1],
ctx->drv.viewport_store[2],
ctx->drv.viewport_store[3]) );
_cogl_set_current_matrix (COGL_MATRIX_PROJECTION); _cogl_set_current_matrix (COGL_MATRIX_PROJECTION);
_cogl_current_matrix_pop (); _cogl_current_matrix_pop ();

View File

@ -48,7 +48,7 @@
{ \ { \
CoglContext *__ctxvar = _cogl_context_get_default (); \ CoglContext *__ctxvar = _cogl_context_get_default (); \
if (__ctxvar == NULL) return retval; \ if (__ctxvar == NULL) return retval; \
wvar = &__ctxvar->gles2; \ wvar = &__ctxvar->drv.gles2; \
} }
#define _COGL_GLES2_CHANGE_SETTING(w, var, val) \ #define _COGL_GLES2_CHANGE_SETTING(w, var, val) \

View File

@ -56,10 +56,10 @@ _cogl_program_free (CoglProgram *program)
_cogl_gles2_clear_cache_for_program ((CoglHandle) program); _cogl_gles2_clear_cache_for_program ((CoglHandle) program);
if (ctx->gles2.settings.user_program == (CoglHandle) program) if (ctx->drv.gles2.settings.user_program == (CoglHandle) program)
{ {
ctx->gles2.settings.user_program = COGL_INVALID_HANDLE; ctx->drv.gles2.settings.user_program = COGL_INVALID_HANDLE;
ctx->gles2.settings_dirty = TRUE; ctx->drv.gles2.settings_dirty = TRUE;
} }
for (i = 0; i < COGL_GLES2_NUM_CUSTOM_UNIFORMS; i++) for (i = 0; i < COGL_GLES2_NUM_CUSTOM_UNIFORMS; i++)
@ -118,8 +118,8 @@ cogl_program_use (CoglHandle handle)
if (handle != COGL_INVALID_HANDLE && !cogl_is_program (handle)) if (handle != COGL_INVALID_HANDLE && !cogl_is_program (handle))
return; return;
ctx->gles2.settings.user_program = handle; ctx->drv.gles2.settings.user_program = handle;
ctx->gles2.settings_dirty = TRUE; ctx->drv.gles2.settings_dirty = TRUE;
} }
int int
@ -181,7 +181,7 @@ cogl_program_uniform_x (int uniform_no,
if (uniform_no >= 0 && uniform_no < COGL_GLES2_NUM_CUSTOM_UNIFORMS if (uniform_no >= 0 && uniform_no < COGL_GLES2_NUM_CUSTOM_UNIFORMS
&& size >= 1 && size <= 4 && count >= 1) && size >= 1 && size <= 4 && count >= 1)
{ {
CoglBoxedValue *bv = ctx->gles2.custom_uniforms + uniform_no; CoglBoxedValue *bv = ctx->drv.gles2.custom_uniforms + uniform_no;
if (count == 1) if (count == 1)
{ {
@ -210,7 +210,7 @@ cogl_program_uniform_x (int uniform_no,
bv->size = size; bv->size = size;
bv->count = count; bv->count = count;
ctx->gles2.dirty_custom_uniforms |= 1 << uniform_no; ctx->drv.gles2.dirty_custom_uniforms |= 1 << uniform_no;
} }
} }
@ -245,7 +245,7 @@ cogl_program_uniform_matrix (int uniform_no,
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
bv = ctx->gles2.custom_uniforms + uniform_no; bv = ctx->drv.gles2.custom_uniforms + uniform_no;
cogl_program_uniform_x (uniform_no, size, count, COGL_BOXED_MATRIX, cogl_program_uniform_x (uniform_no, size, count, COGL_BOXED_MATRIX,
sizeof (float) * size * size, value); sizeof (float) * size * size, value);

View File

@ -252,20 +252,20 @@ _cogl_texture_driver_download_from_gl (CoglTexture *tex,
/* Direct copy operation */ /* Direct copy operation */
if (ctx->texture_download_material == COGL_INVALID_HANDLE) if (ctx->drv.texture_download_material == COGL_INVALID_HANDLE)
{ {
ctx->texture_download_material = cogl_material_new (); ctx->drv.texture_download_material = cogl_material_new ();
cogl_material_set_blend (ctx->texture_download_material, cogl_material_set_blend (ctx->drv.texture_download_material,
"RGBA = ADD (SRC_COLOR, 0)", "RGBA = ADD (SRC_COLOR, 0)",
NULL); NULL);
} }
prev_source = cogl_handle_ref (ctx->source_material); prev_source = cogl_handle_ref (ctx->source_material);
cogl_set_source (ctx->texture_download_material); cogl_set_source (ctx->drv.texture_download_material);
cogl_material_set_layer (ctx->texture_download_material, 0, tex); cogl_material_set_layer (ctx->drv.texture_download_material, 0, tex);
cogl_material_set_layer_combine (ctx->texture_download_material, cogl_material_set_layer_combine (ctx->drv.texture_download_material,
0, /* layer */ 0, /* layer */
"RGBA = REPLACE (TEXTURE)", "RGBA = REPLACE (TEXTURE)",
NULL); NULL);
@ -302,7 +302,7 @@ _cogl_texture_driver_download_from_gl (CoglTexture *tex,
alpha_bmp.height); alpha_bmp.height);
/* Draw alpha values into RGB channels */ /* Draw alpha values into RGB channels */
cogl_material_set_layer_combine (ctx->texture_download_material, cogl_material_set_layer_combine (ctx->drv.texture_download_material,
0, /* layer */ 0, /* layer */
"RGBA = REPLACE (TEXTURE[A])", "RGBA = REPLACE (TEXTURE[A])",
NULL); NULL);