2007-04-27 Matthew Allum <mallum@openedhand.com>

* clutter/Makefile.am:
        * clutter/clutter-actor.c:
        * clutter/clutter-clone-texture.c:
        * clutter/clutter-rectangle.c:
        * clutter/clutter-stage.c:
        * clutter/clutter-texture.c:
        * clutter/cogl/cogl.h:
        * clutter/cogl/gl/Makefile.am:
        * clutter/cogl/gl/cogl-defines.h:
        * clutter/cogl/gl/cogl.c:
        * clutter/cogl/gles/Makefile.am:
        * clutter/cogl/gles/cogl-defines.h:
        * clutter/cogl/gles/cogl.c:
        * clutter/glx/Makefile.am:
        * clutter/glx/clutter-stage-glx.c:
        * clutter/pango/Makefile.am:
        * clutter/pango/pangoclutter-render.c:
        * configure.ac:
        Add initial 'cogl' implementation. 'cogl' is a simple abstration
        layer over GL and GL/ES used by clutter internally. It should
        eventually allow clutter applications to be run on both GL and GL/ES
        with just a recompile as well as provide more debugging and potentially
        profiling information for GL and GL/ES usage.

        This commit contains the initial GL implementation.
This commit is contained in:
Matthew Allum 2007-04-27 21:13:06 +00:00
parent 04ea1a98df
commit 79469940bc
19 changed files with 2150 additions and 536 deletions

View File

@ -1,3 +1,31 @@
2007-04-27 Matthew Allum <mallum@openedhand.com>
* clutter/Makefile.am:
* clutter/clutter-actor.c:
* clutter/clutter-clone-texture.c:
* clutter/clutter-rectangle.c:
* clutter/clutter-stage.c:
* clutter/clutter-texture.c:
* clutter/cogl/cogl.h:
* clutter/cogl/gl/Makefile.am:
* clutter/cogl/gl/cogl-defines.h:
* clutter/cogl/gl/cogl.c:
* clutter/cogl/gles/Makefile.am:
* clutter/cogl/gles/cogl-defines.h:
* clutter/cogl/gles/cogl.c:
* clutter/glx/Makefile.am:
* clutter/glx/clutter-stage-glx.c:
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-render.c:
* configure.ac:
Add initial 'cogl' implementation. 'cogl' is a simple abstration
layer over GL and GL/ES used by clutter internally. It should
eventually allow clutter applications to be run on both GL and GL/ES
with just a recompile as well as provide more debugging and potentially
profiling information for GL and GL/ES usage.
This commit contains the initial GL implementation.
2007-04-26 Emmanuele Bassi <ebassi@openedhand.com>
Merge from clutter-0-2
@ -119,7 +147,12 @@
* examples/bspline.c:
* examples/Makefile.am:
An example of using bspline path.
2007-04-07 Matthew Allum <mallum@openedhand.com>
* clutter/glx/clutter-backend-glx.c:
Fix version check.
2007-03-29 Tomas Frydrych <tf@openedhand.com>
* clutter/clutter-stage.c:

View File

@ -15,7 +15,8 @@ GLIB_MKENUMS=`pkg-config --variable=glib_mkenums glib-2.0`
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/clutter/pango \
-I$(top_srcdir)/cogl \
-I$(top_srcdir)/clutter/cogl \
-I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@ \
-DPREFIX=\""$(prefix)"\" \
-DLIBDIR=\""$(libdir)"\" \
-DDATADIR=\""$(datadir)"\" \

View File

@ -39,6 +39,7 @@
#include "clutter-marshal.h"
#include "clutter-private.h"
#include "clutter-debug.h"
#include "cogl.h"
#include <GL/gl.h>
@ -55,23 +56,16 @@ static guint32 __id = 0;
struct _ClutterActorPrivate
{
ClutterActorBox coords;
ClutterGeometry clip;
guint has_clip : 1;
gfloat rxang, ryang, rzang; /* Rotation foo. */
gint rzx, rzy, rxy, rxz, ryx, ryz;
gint z; /* to actor box ? */
guint8 opacity;
ClutterActor *parent_actor; /* This should always be a group */
gchar *name;
ClutterFixed scale_x, scale_y;
guint32 id; /* Unique ID */
guint has_clip : 1;
ClutterFixed rxang, ryang, rzang; /* Rotation*/
gint rzx, rzy, rxy, rxz, ryx, ryz;
gint z;
guint8 opacity;
ClutterActor *parent_actor;
gchar *name;
ClutterFixed scale_x, scale_y;
guint32 id; /* Unique ID */
};
enum
@ -303,54 +297,56 @@ clutter_actor_paint (ClutterActor *self)
klass = CLUTTER_ACTOR_GET_CLASS (self);
glPushMatrix();
cogl_push_matrix();
#if CLUTTER_COGL_GL
glLoadName (clutter_actor_get_id (self));
#endif
if (clutter_actor_get_parent (self) != NULL)
{
glTranslatef((float) (priv->coords.x1),
(float) (priv->coords.y1),
0.0);
cogl_translate ((priv->coords.x1),
(priv->coords.y1),
0);
}
if (self->priv->rzang)
{
glTranslatef (priv->rzx,
priv->rzy,
0.0);
cogl_translatex (priv->rzx,
priv->rzy,
0);
glRotatef (priv->rzang, 0.0f, 0.0f, 1.0f);
cogl_rotatex (priv->rzang, 0, 0, CFX_ONE);
glTranslatef (-1. * priv->rzx,
-1. * priv->rzy,
0.0);
cogl_translatex (-1. * priv->rzx,
-1. * priv->rzy,
0);
}
if (self->priv->ryang)
{
glTranslatef (priv->ryx,
0.0,
(float) (priv->z) + priv->ryz);
cogl_translatex (priv->ryx,
0,
CLUTTER_INT_TO_FIXED (priv->z) + priv->ryz);
glRotatef (priv->ryang, 0.0f, 1.0f, 0.0f);
cogl_rotatex (priv->ryang, 0, CFX_ONE, 0);
glTranslatef ((float) - priv->ryx,
0.0,
(float) (-1. * priv->z) - priv->ryz);
cogl_translatex (- priv->ryx,
0.0,
CLUTTER_INT_TO_FIXED(-priv->z) - priv->ryz);
}
if (self->priv->rxang)
{
glTranslatef (0.0,
(float) priv->rxy,
(float) (priv->z) + priv->rxz);
cogl_translatex (0,
priv->rxy,
CLUTTER_INT_TO_FIXED(priv->z) + priv->rxz);
glRotatef (priv->rxang, 1.0f, 0.0f, 0.0f);
cogl_rotatex (priv->rxang, CFX_ONE, 0, CFX_ONE);
glTranslatef (0.0,
-1. * priv->rxy,
-1. * priv->z - priv->rxz);
cogl_translatex (0,
- priv->rxy,
CLUTTER_INT_TO_FIXED(-priv->z) - priv->rxz);
}
if (self->priv->z)
@ -359,15 +355,15 @@ clutter_actor_paint (ClutterActor *self)
if (self->priv->scale_x != CFX_ONE ||
self->priv->scale_y != CFX_ONE)
{
glScaled (CLUTTER_FIXED_TO_DOUBLE (priv->scale_x),
CLUTTER_FIXED_TO_DOUBLE (priv->scale_y),
1.0);
cogl_scale (priv->scale_x, priv->scale_y);
}
#if CLUTTER_COGL_GL
if (priv->has_clip)
{
ClutterGeometry *clip = &(priv->clip);
/* FIXME: ES ... */
glEnable (GL_STENCIL_TEST);
glClearStencil (0.0f);
@ -386,17 +382,20 @@ clutter_actor_paint (ClutterActor *self)
glStencilFunc (GL_EQUAL, 0x1, 0x1);
glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
}
#endif
if (klass->paint)
(klass->paint) (self);
#if CLUTTER_COGL_GL
if (priv->has_clip)
glDisable (GL_STENCIL_TEST);
#endif
if (priv->scale_x != CFX_ONE || priv->scale_y != CFX_ONE)
glScaled (1.0, 1.0, 1.0);
cogl_scale (CFX_ONE, CFX_ONE);
glPopMatrix();
cogl_pop_matrix();
}
/**
@ -1569,9 +1568,10 @@ clutter_actor_rotate_z (ClutterActor *self,
gint x,
gint y)
{
/* FIXME: FIXED VERSION */
g_return_if_fail (CLUTTER_IS_ACTOR (self));
self->priv->rzang = angle;
self->priv->rzang = CLUTTER_FLOAT_TO_FIXED (angle);
self->priv->rzx = x;
self->priv->rzy = y;
@ -1596,7 +1596,9 @@ clutter_actor_rotate_x (ClutterActor *self,
{
g_return_if_fail (CLUTTER_IS_ACTOR (self));
self->priv->rxang = angle;
/* FIXME: FIXED API Version */
self->priv->rxang = CLUTTER_FLOAT_TO_FIXED(angle);
self->priv->rxy = y;
self->priv->rxz = z;
@ -1620,8 +1622,11 @@ clutter_actor_rotate_y (ClutterActor *self,
gint z)
{
g_return_if_fail (CLUTTER_IS_ACTOR (self));
/* FIXME: FIXED API VERSION */
self->priv->ryang = angle;
self->priv->ryang = CLUTTER_FLOAT_TO_FIXED(angle);
self->priv->ryx = x;
self->priv->ryz = z;

View File

@ -41,7 +41,7 @@
#include "clutter-private.h"
#include "clutter-debug.h"
#include <GL/gl.h>
#include "cogl.h"
enum
{
@ -109,16 +109,11 @@ clone_texture_render_to_gl_quad (ClutterCloneTexture *ctexture,
ty = (float) pheight / clutter_util_next_p2 (pheight);
}
qx1 = x1; qx2 = x2;
qy1 = y1; qy2 = y2;
glBegin (GL_QUADS);
glTexCoord2f (tx, ty); glVertex2i (qx2, qy2);
glTexCoord2f (0, ty); glVertex2i (qx1, qy2);
glTexCoord2f (0, 0); glVertex2i (qx1, qy1);
glTexCoord2f (tx, 0); glVertex2i (qx2, qy1);
glEnd ();
cogl_texture_quad (x1, x2, y1, y2,
0,
0,
CLUTTER_FLOAT_TO_FIXED (tx),
CLUTTER_FLOAT_TO_FIXED (ty));
return;
}
@ -158,12 +153,11 @@ clone_texture_render_to_gl_quad (ClutterCloneTexture *ctexture,
x, y,
actual_w, actual_h);
glBegin (GL_QUADS);
glTexCoord2f (tx, ty); glVertex2i (qx2, qy2);
glTexCoord2f (0, ty); glVertex2i (qx1, qy2);
glTexCoord2f (0, 0); glVertex2i (qx1, qy1);
glTexCoord2f (tx, 0); glVertex2i (qx2, qy1);
glEnd ();
cogl_texture_quad (qx1, qx2, qy1, qy2,
0,
0,
CLUTTER_FLOAT_TO_FIXED (tx),
CLUTTER_FLOAT_TO_FIXED (ty));
lasty += qy2 - qy1;
@ -180,6 +174,7 @@ clutter_clone_texture_paint (ClutterActor *self)
ClutterActor *parent_texture;
gint x1, y1, x2, y2;
GLenum target_type;
ClutterColor col = { 0xff, 0xff, 0xff, 0xff };
priv = CLUTTER_CLONE_TEXTURE (self)->priv;
@ -187,6 +182,11 @@ clutter_clone_texture_paint (ClutterActor *self)
if (!priv->parent_texture)
return;
CLUTTER_NOTE (PAINT,
"painting clone texture '%s'",
clutter_actor_get_name (self) ? clutter_actor_get_name (self)
: "unknown");
/* parent texture may have been hidden, there for need to make sure its
* realised with resources available.
*/
@ -194,19 +194,24 @@ clutter_clone_texture_paint (ClutterActor *self)
if (!CLUTTER_ACTOR_IS_REALIZED (parent_texture))
clutter_actor_realize (parent_texture);
cogl_push_matrix ();
/* FIXME: figure out nicer way of getting at this info...
*/
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE) &&
clutter_texture_is_tiled (CLUTTER_TEXTURE (parent_texture)) == FALSE)
target_type = GL_TEXTURE_RECTANGLE_ARB;
{
target_type = CGL_TEXTURE_RECTANGLE_ARB;
cogl_enable (CGL_ENABLE_TEXTURE_RECT|CGL_ENABLE_BLEND);
}
else
target_type = GL_TEXTURE_2D;
{
target_type = CGL_TEXTURE_2D;
cogl_enable (CGL_ENABLE_TEXTURE_2D|CGL_ENABLE_BLEND);
}
glEnable (GL_BLEND);
glEnable (target_type);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4ub (255, 255, 255, clutter_actor_get_opacity (self));
col.alpha = clutter_actor_get_opacity (self);
cogl_color (&col);
clutter_actor_get_coords (self, &x1, &y1, &x2, &y2);
@ -218,8 +223,8 @@ clutter_clone_texture_paint (ClutterActor *self)
/* Parent paint translated us into position */
clone_texture_render_to_gl_quad (CLUTTER_CLONE_TEXTURE (self),
0, 0, x2 - x1, y2 - y1);
glDisable (target_type);
glDisable (GL_BLEND);
cogl_pop_matrix ();
}
static void

View File

@ -32,10 +32,10 @@
#include "clutter-rectangle.h"
#include "clutter-main.h"
#include "clutter-private.h" /* for DBG */
#include "clutter-private.h"
#include "clutter-debug.h"
#include <GL/glx.h>
#include <GL/gl.h>
#include "cogl.h"
G_DEFINE_TYPE (ClutterRectangle, clutter_rectangle, CLUTTER_TYPE_ACTOR);
@ -70,14 +70,18 @@ clutter_rectangle_paint (ClutterActor *self)
ClutterRectangle *rectangle = CLUTTER_RECTANGLE(self);
ClutterRectanglePrivate *priv;
ClutterGeometry geom;
ClutterColor tmp_col;
rectangle = CLUTTER_RECTANGLE(self);
priv = rectangle->priv;
glPushMatrix();
CLUTTER_NOTE (PAINT,
"painting rect '%s'",
clutter_actor_get_name (self) ? clutter_actor_get_name (self)
: "unknown");
cogl_push_matrix();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
cogl_enable (CGL_BLEND);
clutter_actor_get_geometry (self, &geom);
@ -86,44 +90,47 @@ clutter_rectangle_paint (ClutterActor *self)
*/
if (priv->has_border)
{
glColor4ub (priv->border_color.red,
priv->border_color.green,
priv->border_color.blue,
clutter_actor_get_opacity (self));
tmp_col.red = priv->border_color.red;
tmp_col.green = priv->border_color.green;
tmp_col.blue = priv->border_color.blue;
tmp_col.alpha = clutter_actor_get_opacity (self);
cogl_color (&tmp_col);
/* this sucks, but it's the only way to make a border */
glRecti (0, 0,
geom.width, priv->border_width);
glRecti (geom.width - priv->border_width, priv->border_width,
geom.width, geom.height - priv->border_width);
glRecti (0, geom.height - priv->border_width,
geom.width, geom.height);
glRecti (0, priv->border_width,
priv->border_width, geom.height - priv->border_width);
glColor4ub (priv->color.red,
priv->color.green,
priv->color.blue,
clutter_actor_get_opacity (self));
cogl_rectangle (0, 0,
geom.width, priv->border_width);
cogl_rectangle (geom.width - priv->border_width, priv->border_width,
geom.width, geom.height - priv->border_width);
cogl_rectangle (0, geom.height - priv->border_width,
geom.width, geom.height);
cogl_rectangle (0, priv->border_width,
priv->border_width, geom.height - priv->border_width);
glRecti (priv->border_width,
priv->border_width,
geom.width - priv->border_width,
geom.height - priv->border_width);
tmp_col.red = priv->color.red;
tmp_col.green = priv->color.green;
tmp_col.blue = priv->color.blue;
cogl_color (&tmp_col);
cogl_rectangle (priv->border_width,
priv->border_width,
geom.width - priv->border_width,
geom.height - priv->border_width);
}
else
{
glColor4ub (priv->color.red,
priv->color.green,
priv->color.blue,
clutter_actor_get_opacity (self));
glRecti (0, 0, geom.width, geom.height);
tmp_col.red = priv->color.red;
tmp_col.green = priv->color.green;
tmp_col.blue = priv->color.blue;
tmp_col.alpha = clutter_actor_get_opacity (self);
cogl_color (&tmp_col);
cogl_rectangle (0, 0, geom.width, geom.height);
}
glDisable(GL_BLEND);
glPopMatrix();
cogl_push_matrix();
}
static void

View File

@ -44,7 +44,7 @@
#include "clutter-debug.h"
#include "clutter-version.h" /* For flavour */
#include <GL/gl.h>
#include "cogl.h"
#include <gdk-pixbuf-xlib/gdk-pixbuf-xlib.h>
@ -616,123 +616,14 @@ clutter_stage_snapshot (ClutterStage *stage,
return NULL;
}
#ifndef FIXED_PERSPECTIVE
/*
* Original floating point implementaiton of the perspective function,
* retained for reference purposes
*/
static inline void
frustum (GLfloat left,
GLfloat right,
GLfloat bottom,
GLfloat top,
GLfloat nearval,
GLfloat farval)
{
GLfloat x, y, a, b, c, d;
GLfloat m[16];
x = (2.0 * nearval) / (right - left);
y = (2.0 * nearval) / (top - bottom);
a = (right + left) / (right - left);
b = (top + bottom) / (top - bottom);
c = -(farval + nearval) / ( farval - nearval);
d = -(2.0 * farval * nearval) / (farval - nearval);
#define M(row,col) m[col*4+row]
M(0,0) = x; M(0,1) = 0.0F; M(0,2) = a; M(0,3) = 0.0F;
M(1,0) = 0.0F; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0F;
M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = c; M(2,3) = d;
M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = -1.0F; M(3,3) = 0.0F;
#undef M
glMultMatrixf (m);
}
static inline void
perspective (GLfloat fovy,
GLfloat aspect,
GLfloat zNear,
GLfloat zFar)
{
GLfloat xmin, xmax, ymin, ymax;
ymax = zNear * tan (fovy * M_PI / 360.0);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;
printf ("%f, %f, %f, %f\n", xmin, xmax, ymin, ymax);
frustum (xmin, xmax, ymin, ymax, zNear, zFar);
}
#else
/*
* Fixed point implementation of the perspective function
*/
static inline void
perspectivex (ClutterAngle fovy,
ClutterFixed aspect,
ClutterFixed zNear,
ClutterFixed zFar)
{
ClutterFixed xmax, ymax;
ClutterFixed x, y, c, d;
#ifndef USING_GLES
GLfloat m[16];
#else
GLfixed m[16];
#endif
memset (&m[0], 0, sizeof (m));
/*
* Based on the original algorithm in perspective():
*
* 1) xmin = -xmax => xmax + xmin == 0 && xmax - xmin == 2 * xmax
* same true for y, hence: a == 0 && b == 0;
*
* 2) When working with small numbers, we can are loosing significant
* precision, hence we use clutter_qmulx() here, not the fast macro.
*/
ymax = clutter_qmulx (zNear, clutter_tani (fovy >> 1));
xmax = clutter_qmulx (ymax, aspect);
x = CFX_DIV (zNear, xmax);
y = CFX_DIV (zNear, ymax);
c = CFX_DIV (-(zFar + zNear), ( zFar - zNear));
d = CFX_DIV (-(clutter_qmulx (2*zFar, zNear)), (zFar - zNear));
#define M(row,col) m[col*4+row]
#ifndef USING_GLES
M(0,0) = CLUTTER_FIXED_TO_FLOAT (x);
M(1,1) = CLUTTER_FIXED_TO_FLOAT (y);
M(2,2) = CLUTTER_FIXED_TO_FLOAT (c);
M(2,3) = CLUTTER_FIXED_TO_FLOAT (d);
M(3,2) = -1.0F;
glMultMatrixf (m);
#else
M(0,0) = x;
M(1,1) = y;
M(2,2) = c;
M(2,3) = d;
M(3,2) = 1 + ~CFX_ONE;
glMultMatrixx (m);
#endif
#undef M
}
#endif
void
_clutter_stage_sync_viewport (ClutterStage *stage)
{
ClutterActor *actor;
gint width, height;
/* FIXME: SHould be able to completely overide this func.. */
g_return_if_fail (CLUTTER_IS_STAGE (stage));
actor = CLUTTER_ACTOR (stage);
@ -740,33 +631,12 @@ _clutter_stage_sync_viewport (ClutterStage *stage)
width = clutter_actor_get_width (actor);
height = clutter_actor_get_height (actor);
glViewport (0, 0, width, height);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
#ifndef FIXED_PERSPECTIVE
perspective (60.0f, 1.0f, 0.1f, 100.0f);
#else
perspectivex (171, /* 60 degrees */
CFX_ONE,
CLUTTER_FLOAT_TO_FIXED (0.1),
CLUTTER_FLOAT_TO_FIXED (100.0));
#endif
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
/* Then for 2D like transform */
/* camera distance from screen, 0.5 * tan (FOV) */
#define DEFAULT_Z_CAMERA 0.866025404f
glTranslatef (-0.5f, -0.5f, -DEFAULT_Z_CAMERA);
glScalef ( 1.0f / width,
-1.0f / height,
1.0f / width);
glTranslatef (0.0f, -1.0 * height, 0.0f);
cogl_setup_viewport (width,
height,
171, /* 60 degrees */
CFX_ONE,
CLUTTER_FLOAT_TO_FIXED (0.1),
CLUTTER_FLOAT_TO_FIXED (100.0));
}
/**
@ -784,6 +654,12 @@ clutter_stage_get_actor_at_pos (ClutterStage *stage,
gint x,
gint y)
{
#if HAVE_COGL_GL
/* FIXME: Add a clutter feature flag for this or figure out
* for gles.
*/
ClutterActor *found = NULL;
GLuint buff[64] = { 0 };
GLint hits;
@ -808,14 +684,10 @@ clutter_stage_get_actor_at_pos (ClutterStage *stage,
(view[3] - 2 * (y - view[1])), 0);
glScalef (view[2], -view[3], 1.0);
#ifndef FIXED_PERSPECTIVE
perspective (60.0f, 1.0f, 0.1f, 100.0f);
#else
perspectivex (171, /* 60 degrees */
CFX_ONE,
CLUTTER_FLOAT_TO_FIXED (0.1),
CLUTTER_FLOAT_TO_FIXED (100.0));
#endif
cogl_perspective (171, /* 60 degrees */
CFX_ONE,
CLUTTER_FLOAT_TO_FIXED (0.1),
CLUTTER_FLOAT_TO_FIXED (100.0));
glMatrixMode (GL_MODELVIEW);
@ -841,6 +713,10 @@ clutter_stage_get_actor_at_pos (ClutterStage *stage,
_clutter_stage_sync_viewport (stage);
return found;
#else
/* GL/ES cannot do this yet.. */
return NULL;
#endif
}
/**

View File

@ -38,6 +38,8 @@
* memory.
*/
#include "config.h"
#include "clutter-texture.h"
#include "clutter-main.h"
#include "clutter-marshal.h"
@ -45,15 +47,16 @@
#include "clutter-util.h"
#include "clutter-private.h"
#include "clutter-debug.h"
#include "clutter-fixed.h"
#include <GL/gl.h>
#include "cogl.h"
G_DEFINE_TYPE (ClutterTexture, clutter_texture, CLUTTER_TYPE_ACTOR);
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define PIXEL_TYPE GL_UNSIGNED_BYTE
#define PIXEL_TYPE CGL_UNSIGNED_BYTE
#else
#define PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
#define PIXEL_TYPE CGL_UNSIGNED_INT_8_8_8_8_REV
#endif
typedef struct {
@ -64,28 +67,23 @@ typedef struct {
struct _ClutterTexturePrivate
{
gint width;
gint height;
GLenum pixel_format;
GLenum pixel_type;
GLenum target_type;
GdkPixbuf *local_pixbuf; /* non video memory copy */
guint sync_actor_size : 1;
gint max_tile_waste;
guint filter_quality;
guint repeat_x : 1; /* non working */
guint repeat_y : 1; /* non working */
guint is_tiled : 1;
gint width;
gint height;
COGLenum pixel_format;
COGLenum pixel_type;
COGLenum target_type;
GdkPixbuf *local_pixbuf; /* non video memory copy */
guint sync_actor_size : 1;
gint max_tile_waste;
guint filter_quality;
guint repeat_x : 1; /* non working */
guint repeat_y : 1; /* non working */
guint is_tiled : 1;
ClutterTextureTileDimension *x_tiles;
ClutterTextureTileDimension *y_tiles;
gint n_x_tiles;
gint n_y_tiles;
GLuint *tiles;
gint n_x_tiles;
gint n_y_tiles;
guint *tiles;
};
enum
@ -111,27 +109,6 @@ enum
static int texture_signals[LAST_SIGNAL] = { 0 };
static gboolean
can_create (int width,
int height,
GLenum pixel_format,
GLenum pixel_type)
{
GLint new_width = 0;
CLUTTER_NOTE (TEXTURE, "checking %ix%i", width, height);
glTexImage2D (GL_PROXY_TEXTURE_2D, 0, GL_RGBA,
width, height, 0 /* border */,
pixel_format, pixel_type, NULL);
CLUTTER_GLERR();
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0,
GL_TEXTURE_WIDTH, &new_width);
return new_width != 0;
}
static gboolean
can_create_rect_arb (int width,
@ -195,7 +172,8 @@ texture_init_tiles (ClutterTexture *texture)
x_pot = clutter_util_next_p2 (priv->width);
y_pot = clutter_util_next_p2 (priv->height);
while (!(can_create (x_pot, y_pot, priv->pixel_format, priv->pixel_type)
while (!(cogl_texture_can_size (x_pot, y_pot,
priv->pixel_format, priv->pixel_type)
&& (x_pot - priv->width < priv->max_tile_waste)
&& (y_pot - priv->height < priv->max_tile_waste)))
{
@ -272,9 +250,11 @@ texture_render_to_gl_quad (ClutterTexture *texture,
if (!priv->is_tiled)
{
glBindTexture(priv->target_type, priv->tiles[0]);
cogl_texture_bind (priv->target_type, priv->tiles[0]);
if (priv->target_type == GL_TEXTURE_2D) /* POT */
/* FIXME: FIXED */
if (priv->target_type == CGL_TEXTURE_2D) /* POT */
{
tx = (float) priv->width / clutter_util_next_p2 (priv->width);
ty = (float) priv->height / clutter_util_next_p2 (priv->height);
@ -288,13 +268,12 @@ texture_render_to_gl_quad (ClutterTexture *texture,
qx1 = x1; qx2 = x2;
qy1 = y1; qy2 = y2;
glBegin (GL_QUADS);
glTexCoord2f (tx, ty); glVertex2i (qx2, qy2);
glTexCoord2f (0, ty); glVertex2i (qx1, qy2);
glTexCoord2f (0, 0); glVertex2i (qx1, qy1);
glTexCoord2f (tx, 0); glVertex2i (qx2, qy1);
glEnd ();
cogl_texture_quad (x1, x2, y1, y2,
0,
0,
CLUTTER_FLOAT_TO_FIXED (tx),
CLUTTER_FLOAT_TO_FIXED (ty));
return;
}
@ -307,7 +286,7 @@ texture_render_to_gl_quad (ClutterTexture *texture,
{
int actual_w, actual_h;
glBindTexture(priv->target_type, priv->tiles[i]);
cogl_texture_bind (priv->target_type, priv->tiles[i]);
actual_w = priv->x_tiles[x].size - priv->x_tiles[x].waste;
actual_h = priv->y_tiles[y].size - priv->y_tiles[y].waste;
@ -325,12 +304,11 @@ texture_render_to_gl_quad (ClutterTexture *texture,
qy1 = y1 + lasty;
qy2 = qy1 + ((qheight * actual_h) / priv->height );
glBegin (GL_QUADS);
glTexCoord2f (tx, ty); glVertex2i (qx2, qy2);
glTexCoord2f (0, ty); glVertex2i (qx1, qy2);
glTexCoord2f (0, 0); glVertex2i (qx1, qy1);
glTexCoord2f (tx, 0); glVertex2i (qx2, qy1);
glEnd ();
cogl_texture_quad (qx1, qx2, qy1, qy2,
0,
0,
CLUTTER_FLOAT_TO_FIXED (tx),
CLUTTER_FLOAT_TO_FIXED (ty));
lasty += (qy2 - qy1) ;
@ -352,9 +330,9 @@ texture_free_gl_resources (ClutterTexture *texture)
if (priv->tiles)
{
if (!priv->is_tiled)
glDeleteTextures(1, priv->tiles);
cogl_textures_destroy (1, priv->tiles);
else
glDeleteTextures(priv->n_x_tiles * priv->n_y_tiles, priv->tiles);
cogl_textures_destroy (priv->n_x_tiles * priv->n_y_tiles, priv->tiles);
g_free(priv->tiles);
priv->tiles = NULL;
@ -399,33 +377,27 @@ texture_upload_data (ClutterTexture *texture,
/* Single Texture */
if (!priv->tiles)
{
priv->tiles = g_new (GLuint, 1);
priv->tiles = g_new (guint, 1);
glGenTextures (1, priv->tiles);
create_textures = TRUE;
}
CLUTTER_NOTE (TEXTURE, "syncing for single tile");
glBindTexture(priv->target_type, priv->tiles[0]);
cogl_texture_bind (priv->target_type, priv->tiles[0]);
glTexParameteri(priv->target_type,
GL_TEXTURE_WRAP_S,
priv->repeat_x ? GL_REPEAT : GL_CLAMP_TO_EDGE);
cogl_texture_set_alignment (priv->target_type, 4, priv->width);
glTexParameteri(priv->target_type,
GL_TEXTURE_WRAP_T,
priv->repeat_y ? GL_REPEAT : GL_CLAMP_TO_EDGE);
cogl_texture_set_filters
(priv->target_type,
priv->filter_quality ? CGL_LINEAR : CGL_NEAREST,
priv->filter_quality ? CGL_LINEAR : CGL_NEAREST);
cogl_texture_set_wrap (priv->target_type,
priv->repeat_x ? CGL_REPEAT : CGL_CLAMP_TO_EDGE,
priv->repeat_y ? CGL_REPEAT : CGL_CLAMP_TO_EDGE);
priv->filter_quality = 1;
glTexParameteri(priv->target_type, GL_TEXTURE_MAG_FILTER,
priv->filter_quality ? GL_LINEAR : GL_NEAREST);
glTexParameteri(priv->target_type, GL_TEXTURE_MIN_FILTER,
priv->filter_quality ? GL_LINEAR : GL_NEAREST);
glPixelStorei (GL_UNPACK_ROW_LENGTH, priv->width);
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
if (create_textures)
{
@ -434,30 +406,29 @@ texture_upload_data (ClutterTexture *texture,
width = priv->width;
height = priv->height;
if (priv->target_type == GL_TEXTURE_2D) /* POT */
if (priv->target_type == CGL_TEXTURE_2D) /* POT */
{
width = clutter_util_next_p2(priv->width);
height = clutter_util_next_p2(priv->height);
}
glTexImage2D(priv->target_type,
0,
/* (has_alpha) ? GL_RGBA : GL_RGB, */
GL_RGBA,
width,
height,
0,
priv->pixel_format,
priv->pixel_type,
NULL);
cogl_texture_image_2d (priv->target_type,
CGL_RGBA,
width,
height,
priv->pixel_format,
priv->pixel_type,
NULL);
}
glTexSubImage2D (priv->target_type, 0, 0, 0,
priv->width,
priv->height,
priv->pixel_format,
priv->pixel_type,
data);
cogl_texture_sub_image_2d (priv->target_type,
0,
0,
width,
height,
priv->pixel_format,
priv->pixel_type,
data);
return;
}
@ -478,7 +449,7 @@ texture_upload_data (ClutterTexture *texture,
if (priv->tiles == NULL)
{
priv->tiles = g_new (GLuint, priv->n_x_tiles * priv->n_y_tiles);
priv->tiles = g_new (guint, priv->n_x_tiles * priv->n_y_tiles);
glGenTextures (priv->n_x_tiles * priv->n_y_tiles, priv->tiles);
create_textures = TRUE;
}
@ -524,48 +495,40 @@ texture_upload_data (ClutterTexture *texture,
}
#endif
glBindTexture(priv->target_type, priv->tiles[i]);
glTexParameteri(priv->target_type,
GL_TEXTURE_WRAP_S,
priv->repeat_x ? GL_REPEAT : GL_CLAMP_TO_EDGE);
glTexParameteri(priv->target_type,
GL_TEXTURE_WRAP_T,
priv->repeat_y ? GL_REPEAT : GL_CLAMP_TO_EDGE);
glTexParameteri(priv->target_type, GL_TEXTURE_MAG_FILTER,
priv->filter_quality ? GL_LINEAR : GL_NEAREST);
glTexParameteri(priv->target_type, GL_TEXTURE_MIN_FILTER,
priv->filter_quality ? GL_LINEAR : GL_NEAREST);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glPixelStorei (GL_UNPACK_ROW_LENGTH, src_w);
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
cogl_texture_bind (priv->target_type, priv->tiles[0]);
cogl_texture_set_alignment (priv->target_type, 4, priv->width);
cogl_texture_set_filters
(priv->target_type,
priv->filter_quality ? CGL_LINEAR : CGL_NEAREST,
priv->filter_quality ? CGL_LINEAR : CGL_NEAREST);
cogl_texture_set_wrap (priv->target_type,
priv->repeat_x ? CGL_REPEAT : CGL_CLAMP_TO_EDGE,
priv->repeat_y ? CGL_REPEAT : CGL_CLAMP_TO_EDGE);
if (create_textures)
{
glTexImage2D (priv->target_type, 0, GL_RGBA,
gdk_pixbuf_get_width (pixtmp),
gdk_pixbuf_get_height (pixtmp),
0,
priv->pixel_format,
priv->pixel_type,
gdk_pixbuf_get_pixels (pixtmp));
cogl_texture_image_2d (priv->target_type,
CGL_RGBA,
gdk_pixbuf_get_width (pixtmp),
gdk_pixbuf_get_height (pixtmp),
priv->pixel_format,
priv->pixel_type,
gdk_pixbuf_get_pixels (pixtmp));
}
else
{
/* Textures already created, so just update whats inside
*/
glTexSubImage2D (priv->target_type, 0,
0, 0,
gdk_pixbuf_get_width (pixtmp),
gdk_pixbuf_get_height (pixtmp),
priv->pixel_format,
priv->pixel_type,
gdk_pixbuf_get_pixels (pixtmp));
cogl_texture_sub_image_2d (priv->target_type,
0,
0,
gdk_pixbuf_get_width (pixtmp),
gdk_pixbuf_get_height (pixtmp),
priv->pixel_format,
priv->pixel_type,
gdk_pixbuf_get_pixels (pixtmp));
}
g_object_unref (pixtmp);
@ -668,31 +631,41 @@ clutter_texture_paint (ClutterActor *self)
{
ClutterTexture *texture = CLUTTER_TEXTURE (self);
gint x1, y1, x2, y2;
guint8 opacity;
ClutterColor col = { 0xff, 0xff, 0xff, 0xff };
CLUTTER_NOTE (PAINT,
"@@@ for '%s' @@@",
"painting texture '%s'",
clutter_actor_get_name (self) ? clutter_actor_get_name (self)
: "unknown");
glPushMatrix ();
cogl_push_matrix ();
glEnable (GL_BLEND);
glEnable (texture->priv->target_type);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
switch (texture->priv->target_type)
{
case CGL_TEXTURE_2D:
cogl_enable (CGL_ENABLE_TEXTURE_2D|CGL_ENABLE_BLEND);
break;
case CGL_TEXTURE_RECTANGLE_ARB:
cogl_enable (CGL_ENABLE_TEXTURE_RECT|CGL_ENABLE_BLEND);
break;
default:
break;
}
opacity = clutter_actor_get_opacity (self);
col.alpha = clutter_actor_get_opacity (self);
CLUTTER_NOTE (PAINT, "setting opacity to %i\n", opacity);
glColor4ub (255, 255, 255, opacity);
cogl_color (&col);
clutter_actor_get_coords (self, &x1, &y1, &x2, &y2);
CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i "
"opacity: %i",
x1, y1, x2, y2,
clutter_actor_get_opacity (self));
/* Paint will of translated us */
texture_render_to_gl_quad (texture, 0, 0, x2 - x1, y2 - y1);
glDisable (texture->priv->target_type);
glDisable (GL_BLEND);
glPopMatrix ();
cogl_pop_matrix ();
}
static void
@ -752,8 +725,8 @@ clutter_texture_set_property (GObject *object,
case PROP_USE_TILES:
priv->is_tiled = g_value_get_boolean (value);
if (priv->target_type == GL_TEXTURE_RECTANGLE_ARB && priv->is_tiled)
priv->target_type = GL_TEXTURE_2D;
if (priv->target_type == CGL_TEXTURE_RECTANGLE_ARB && priv->is_tiled)
priv->target_type = CGL_TEXTURE_2D;
CLUTTER_NOTE (TEXTURE, "Texture is tiled ? %s",
priv->is_tiled ? "yes" : "no");
@ -950,7 +923,7 @@ clutter_texture_class_init (ClutterTextureClass *klass)
"GL texture pixel format used",
0,
G_MAXINT,
GL_RGBA,
CGL_RGBA,
G_PARAM_CONSTRUCT_ONLY | CLUTTER_PARAM_READWRITE));
/**
@ -1001,17 +974,17 @@ clutter_texture_init (ClutterTexture *self)
priv->filter_quality = 0;
priv->is_tiled = TRUE;
priv->pixel_type = PIXEL_TYPE;
priv->pixel_format = GL_RGBA;
priv->pixel_format = CGL_RGBA;
priv->repeat_x = FALSE;
priv->repeat_y = FALSE;
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
{
priv->target_type = GL_TEXTURE_RECTANGLE_ARB;
priv->target_type = CGL_TEXTURE_RECTANGLE_ARB;
priv->is_tiled = FALSE;
}
else
priv->target_type = GL_TEXTURE_2D;
priv->target_type = CGL_TEXTURE_2D;
self->priv = priv;
}
@ -1034,6 +1007,7 @@ pixbuf_destroy_notify (guchar *pixels, gpointer data)
GdkPixbuf*
clutter_texture_get_pixbuf (ClutterTexture* texture)
{
#if CLUTTER_COGL_GL
ClutterTexturePrivate *priv;
GdkPixbuf *pixbuf = NULL;
guchar *pixels = NULL;
@ -1044,7 +1018,7 @@ clutter_texture_get_pixbuf (ClutterTexture* texture)
if (priv->tiles == NULL)
return NULL;
if (priv->pixel_format == GL_RGB)
if (priv->pixel_format == CGL_RGB)
bpp = 3;
if (!priv->is_tiled)
@ -1054,12 +1028,15 @@ clutter_texture_get_pixbuf (ClutterTexture* texture)
if (!pixels)
return NULL;
/* FIXME: cogl */
glBindTexture(priv->target_type, priv->tiles[0]);
glPixelStorei (GL_UNPACK_ROW_LENGTH, priv->width);
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
/* read data from gl text and return as pixbuf */
/* No such func in gles... */
glGetTexImage (priv->target_type,
0,
priv->pixel_format,
@ -1145,6 +1122,13 @@ clutter_texture_get_pixbuf (ClutterTexture* texture)
}
return pixbuf;
#else
/* FIXME: func call wont work for GLES...
* features need to reflect this.
*/
return NULL;
#endif
}
/**
@ -1185,9 +1169,9 @@ clutter_texture_set_from_data (ClutterTexture *texture,
priv->height = height;
if (has_alpha)
priv->pixel_format = GL_RGBA;
priv->pixel_format = CGL_RGBA;
else
priv->pixel_format = GL_RGB;
priv->pixel_format = CGL_RGB;
if (texture_dirty)
{
@ -1195,7 +1179,7 @@ clutter_texture_set_from_data (ClutterTexture *texture,
if (priv->is_tiled == FALSE)
{
if (priv->target_type == GL_TEXTURE_RECTANGLE_ARB
if (priv->target_type == CGL_TEXTURE_RECTANGLE_ARB
&& !can_create_rect_arb (priv->width,
priv->height,
priv->pixel_format,
@ -1203,10 +1187,11 @@ clutter_texture_set_from_data (ClutterTexture *texture,
{
/* If we cant create NPOT tex of this size fall back to tiles */
priv->is_tiled = TRUE;
priv->target_type = GL_TEXTURE_2D;
priv->target_type = CGL_TEXTURE_2D;
}
else if (priv->target_type == GL_TEXTURE_2D
&& !can_create(clutter_util_next_p2(priv->width),
else if (priv->target_type == CGL_TEXTURE_2D
&& !cogl_texture_can_size
(clutter_util_next_p2(priv->width),
clutter_util_next_p2(priv->height),
priv->pixel_format,
priv->pixel_type))
@ -1352,7 +1337,7 @@ clutter_texture_bind_tile (ClutterTexture *texture, gint index)
ClutterTexturePrivate *priv;
priv = texture->priv;
glBindTexture(priv->target_type, priv->tiles[index]);
cogl_texture_bind (priv->target_type, priv->tiles[index]);
}
/**

View File

@ -23,14 +23,37 @@
* Boston, MA 02111-1307, USA.
*/
/*
* COGL
* ====
*
* 'cogl' is a very simple abstraction layer which wraps GL and GLES.
*
*
* !!!! DO NOT USE THIS API YET OUTSIDE OF CLUTTER CORE !!!!
* THE API WILL FLUCTUATE WILDLY
*
* TODO:
* - Use ClutterReal for fixed/float params.
* - Add Perspective/viewport setup
* - Add Features..
*/
#ifndef __COGL_H__
#define __COGL_H__
#include <glib.h>
#include <clutter/clutter.h>
#include "cogl-defines.h"
G_BEGIN_DECLS
#define CGL_ENABLE_BLEND (1<<1)
#define CGL_ENABLE_TEXTURE_2D (1<<2)
#define CGL_ENABLE_ALPHA_TEST (1<<3)
#define CGL_ENABLE_TEXTURE_RECT (1<<4)
typedef void (*CoglFuncPtr) (void);
CoglFuncPtr
@ -39,6 +62,20 @@ cogl_get_proc_address (const gchar* name);
gboolean
cogl_check_extension (const gchar *name, const gchar *ext);
void
cogl_perspective (ClutterAngle fovy,
ClutterFixed aspect,
ClutterFixed zNear,
ClutterFixed zFar);
void
cogl_setup_viewport (guint width,
guint height,
ClutterAngle fovy,
ClutterFixed aspect,
ClutterFixed z_near,
ClutterFixed z_far);
void
cogl_paint_init (ClutterColor *color);
@ -49,7 +86,7 @@ void
cogl_pop_matrix (void);
void
cogl_scaled (ClutterFixed x, ClutterFixed z);
cogl_scale (ClutterFixed x, ClutterFixed z);
void
cogl_translatex (ClutterFixed x, ClutterFixed y, ClutterFixed z);
@ -66,29 +103,81 @@ cogl_rotate (gint angle, gint x, gint y, gint z);
void
cogl_color (ClutterColor *color);
#if 0
void
cogl_enable (gulong flags);
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glColor3f'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glColor4ub'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glGetTexLevelParameteriv'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glSelectBuffer'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glScaled'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glPushName'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glRecti'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glBegin'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glInitNames'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glVertex2i'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glGetTexImage'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glTexCoord2f'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glRenderMode'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glTranslated'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glRotated'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glLoadName'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glTexEnvi'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glVertex2d'
../clutter/.libs/libclutter-egl-0.3.so: undefined reference to `glEnd'
gboolean
cogl_texture_can_size (COGLenum pixel_format,
COGLenum pixel_type,
int width,
int height);
void
cogl_texture_quad (gint x1,
gint x2,
gint y1,
gint y2,
ClutterFixed tx1,
ClutterFixed ty1,
ClutterFixed tx2,
ClutterFixed ty2);
void
cogl_textures_create (guint num, guint *textures);
void
cogl_textures_destroy (guint num, const guint *textures);
void
cogl_texture_bind (COGLenum target, guint texture);
void
cogl_texture_set_alignment (COGLenum target,
guint alignment,
guint row_length);
void
cogl_texture_set_filters (COGLenum target,
COGLenum min_filter,
COGLenum max_filter);
void
cogl_texture_set_wrap (COGLenum target,
COGLenum wrap_s,
COGLenum wrap_t);
void
cogl_texture_image_2d (COGLenum target,
COGLint internal_format,
gint width,
gint height,
COGLenum format,
COGLenum type,
const guchar* pixels);
void
cogl_texture_sub_image_2d (COGLenum target,
gint xoff,
gint yoff,
gint width,
gint height,
COGLenum format,
COGLenum type,
const guchar* pixels);
void
cogl_rectangle (gint x, gint y, guint width, guint height);
void
cogl_trapezoid (gint y1,
gint x11,
gint x21,
gint y2,
gint x12,
gint x22);
void
cogl_alpha_func (COGLenum func,
ClutterFixed ref);
#endif
G_END_DECLS

View File

@ -1,5 +1,6 @@
libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/clutter
libclutterinclude_HEADERS = $(top_srcdir)/clutter/cogl/cogl.h
libclutterinclude_HEADERS = $(top_srcdir)/clutter/cogl/cogl.h \
$(top_srcdir)/clutter/cogl/gl/cogl-defines.h
INCLUDES = \
-I$(top_srcdir) \
@ -12,6 +13,7 @@ LDADD = $(CLUTTER_LIBS)
noinst_LTLIBRARIES = libclutter-cogl.la
libclutter_cogl_la_SOURCES = \
$(top_srcdir)/clutter/cogl/cogl.h \
libclutter_cogl_la_SOURCES = \
$(top_srcdir)/clutter/cogl/cogl.h \
$(top_srcdir)/clutter/cogl/gl/cogl-defines.h \
cogl.c

View File

@ -0,0 +1,677 @@
/*
* Clutter COGL
*
* A basic GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
*
* 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_DEFINES_H__
#define __COGL_DEFINES_H__
#include <GL/gl.h>
G_BEGIN_DECLS
typedef GLenum COGLenum;
typedef GLint COGLint;
/* FIXME + DOCUMENT */
#define COPENSTEP OPENSTEP
#define CGLAPI GLAPI
#define CGLAPI GLAPI
#define CGLAPI GLAPI
#define CGLAPIENTRY GLAPIENTRY
#define CGLAPI GLAPI
#define CGLAPIENTRY GLAPIENTRY
#define CGLAPI GLAPI
#define CGLAPIENTRY GLAPIENTRY
#define CPRAGMA_EXPORT_SUPPORTED PRAGMA_EXPORT_SUPPORTED
#define CGLAPI GLAPI
#define CGLAPIENTRY GLAPIENTRY
#define CAPIENTRY APIENTRY
#define CAPIENTRYP APIENTRYP
#define CGLAPIENTRYP GLAPIENTRYP
#define CGL_FALSE GL_FALSE
#define CGL_TRUE GL_TRUE
#define CGL_BYTE GL_BYTE
#define CGL_UNSIGNED_BYTE GL_UNSIGNED_BYTE
#define CGL_SHORT GL_SHORT
#define CGL_UNSIGNED_SHORT GL_UNSIGNED_SHORT
#define CGL_INT GL_INT
#define CGL_UNSIGNED_INT GL_UNSIGNED_INT
#define CGL_FLOAT GL_FLOAT
#define CGL_DOUBLE GL_DOUBLE
#define CGL_POINTS GL_POINTS
#define CGL_LINES GL_LINES
#define CGL_LINE_LOOP GL_LINE_LOOP
#define CGL_LINE_STRIP GL_LINE_STRIP
#define CGL_TRIANGLES GL_TRIANGLES
#define CGL_TRIANGLE_STRIP GL_TRIANGLE_STRIP
#define CGL_TRIANGLE_FAN GL_TRIANGLE_FAN
#define CGL_QUADS GL_QUADS
#define CGL_QUAD_STRIP GL_QUAD_STRIP
#define CGL_POLYGON GL_POLYGON
#define CGL_VERTEX_ARRAY GL_VERTEX_ARRAY
#define CGL_NORMAL_ARRAY GL_NORMAL_ARRAY
#define CGL_COLOR_ARRAY GL_COLOR_ARRAY
#define CGL_INDEX_ARRAY GL_INDEX_ARRAY
#define CGL_TEXTURE_COORD_ARRAY GL_TEXTURE_COORD_ARRAY
#define CGL_EDGE_FLAG_ARRAY GL_EDGE_FLAG_ARRAY
#define CGL_VERTEX_ARRAY_SIZE GL_VERTEX_ARRAY_SIZE
#define CGL_VERTEX_ARRAY_TYPE GL_VERTEX_ARRAY_TYPE
#define CGL_VERTEX_ARRAY_STRIDE GL_VERTEX_ARRAY_STRIDE
#define CGL_NORMAL_ARRAY_TYPE GL_NORMAL_ARRAY_TYPE
#define CGL_NORMAL_ARRAY_STRIDE GL_NORMAL_ARRAY_STRIDE
#define CGL_COLOR_ARRAY_SIZE GL_COLOR_ARRAY_SIZE
#define CGL_COLOR_ARRAY_TYPE GL_COLOR_ARRAY_TYPE
#define CGL_COLOR_ARRAY_STRIDE GL_COLOR_ARRAY_STRIDE
#define CGL_INDEX_ARRAY_TYPE GL_INDEX_ARRAY_TYPE
#define CGL_INDEX_ARRAY_STRIDE GL_INDEX_ARRAY_STRIDE
#define CGL_TEXTURE_COORD_ARRAY_SIZE GL_TEXTURE_COORD_ARRAY_SIZE
#define CGL_TEXTURE_COORD_ARRAY_TYPE GL_TEXTURE_COORD_ARRAY_TYPE
#define CGL_TEXTURE_COORD_ARRAY_STRIDE GL_TEXTURE_COORD_ARRAY_STRIDE
#define CGL_EDGE_FLAG_ARRAY_STRIDE GL_EDGE_FLAG_ARRAY_STRIDE
#define CGL_VERTEX_ARRAY_POINTER GL_VERTEX_ARRAY_POINTER
#define CGL_NORMAL_ARRAY_POINTER GL_NORMAL_ARRAY_POINTER
#define CGL_COLOR_ARRAY_POINTER GL_COLOR_ARRAY_POINTER
#define CGL_INDEX_ARRAY_POINTER GL_INDEX_ARRAY_POINTER
#define CGL_TEXTURE_COORD_ARRAY_POINTER GL_TEXTURE_COORD_ARRAY_POINTER
#define CGL_EDGE_FLAG_ARRAY_POINTER GL_EDGE_FLAG_ARRAY_POINTER
#define CGL_MATRIX_MODE GL_MATRIX_MODE
#define CGL_MODELVIEW GL_MODELVIEW
#define CGL_PROJECTION GL_PROJECTION
#define CGL_TEXTURE GL_TEXTURE
#define CGL_POINT_SMOOTH GL_POINT_SMOOTH
#define CGL_POINT_SIZE GL_POINT_SIZE
#define CGL_POINT_SIZE_GRANULARITY GL_POINT_SIZE_GRANULARITY
#define CGL_POINT_SIZE_RANGE GL_POINT_SIZE_RANGE
#define CGL_LINE_SMOOTH GL_LINE_SMOOTH
#define CGL_LINE_STIPPLE GL_LINE_STIPPLE
#define CGL_LINE_STIPPLE_PATTERN GL_LINE_STIPPLE_PATTERN
#define CGL_LINE_STIPPLE_REPEAT GL_LINE_STIPPLE_REPEAT
#define CGL_LINE_WIDTH GL_LINE_WIDTH
#define CGL_LINE_WIDTH_GRANULARITY GL_LINE_WIDTH_GRANULARITY
#define CGL_LINE_WIDTH_RANGE GL_LINE_WIDTH_RANGE
#define CGL_POINT GL_POINT
#define CGL_LINE GL_LINE
#define CGL_FILL GL_FILL
#define CGL_CW GL_CW
#define CGL_CCW GL_CCW
#define CGL_FRONT GL_FRONT
#define CGL_BACK GL_BACK
#define CGL_POLYGON_MODE GL_POLYGON_MODE
#define CGL_POLYGON_SMOOTH GL_POLYGON_SMOOTH
#define CGL_POLYGON_STIPPLE GL_POLYGON_STIPPLE
#define CGL_EDGE_FLAG GL_EDGE_FLAG
#define CGL_CULL_FACE GL_CULL_FACE
#define CGL_CULL_FACE_MODE GL_CULL_FACE_MODE
#define CGL_FRONT_FACE GL_FRONT_FACE
#define CGL_POLYGON_OFFSET_FACTOR GL_POLYGON_OFFSET_FACTOR
#define CGL_POLYGON_OFFSET_UNITS GL_POLYGON_OFFSET_UNITS
#define CGL_POLYGON_OFFSET_POINT GL_POLYGON_OFFSET_POINT
#define CGL_POLYGON_OFFSET_LINE GL_POLYGON_OFFSET_LINE
#define CGL_POLYGON_OFFSET_FILL GL_POLYGON_OFFSET_FILL
#define CGL_COMPILE GL_COMPILE
#define CGL_COMPILE_AND_EXECUTE GL_COMPILE_AND_EXECUTE
#define CGL_LIST_BASE GL_LIST_BASE
#define CGL_LIST_INDEX GL_LIST_INDEX
#define CGL_LIST_MODE GL_LIST_MODE
#define CGL_NEVER GL_NEVER
#define CGL_LESS GL_LESS
#define CGL_EQUAL GL_EQUAL
#define CGL_LEQUAL GL_LEQUAL
#define CGL_GREATER GL_GREATER
#define CGL_NOTEQUAL GL_NOTEQUAL
#define CGL_GEQUAL GL_GEQUAL
#define CGL_ALWAYS GL_ALWAYS
#define CGL_DEPTH_TEST GL_DEPTH_TEST
#define CGL_DEPTH_BITS GL_DEPTH_BITS
#define CGL_DEPTH_CLEAR_VALUE GL_DEPTH_CLEAR_VALUE
#define CGL_DEPTH_FUNC GL_DEPTH_FUNC
#define CGL_DEPTH_RANGE GL_DEPTH_RANGE
#define CGL_DEPTH_WRITEMASK GL_DEPTH_WRITEMASK
#define CGL_DEPTH_COMPONENT GL_DEPTH_COMPONENT
#define CGL_LIGHTING GL_LIGHTING
#define CGL_SPOT_EXPONENT GL_SPOT_EXPONENT
#define CGL_SPOT_CUTOFF GL_SPOT_CUTOFF
#define CGL_CONSTANT_ATTENUATION GL_CONSTANT_ATTENUATION
#define CGL_LINEAR_ATTENUATION GL_LINEAR_ATTENUATION
#define CGL_QUADRATIC_ATTENUATION GL_QUADRATIC_ATTENUATION
#define CGL_AMBIENT GL_AMBIENT
#define CGL_DIFFUSE GL_DIFFUSE
#define CGL_SPECULAR GL_SPECULAR
#define CGL_SHININESS GL_SHININESS
#define CGL_EMISSION GL_EMISSION
#define CGL_POSITION GL_POSITION
#define CGL_SPOT_DIRECTION GL_SPOT_DIRECTION
#define CGL_AMBIENT_AND_DIFFUSE GL_AMBIENT_AND_DIFFUSE
#define CGL_COLOR_INDEXES GL_COLOR_INDEXES
#define CGL_LIGHT_MODEL_TWO_SIDE GL_LIGHT_MODEL_TWO_SIDE
#define CGL_LIGHT_MODEL_LOCAL_VIEWER GL_LIGHT_MODEL_LOCAL_VIEWER
#define CGL_LIGHT_MODEL_AMBIENT GL_LIGHT_MODEL_AMBIENT
#define CGL_FRONT_AND_BACK GL_FRONT_AND_BACK
#define CGL_SHADE_MODEL GL_SHADE_MODEL
#define CGL_FLAT GL_FLAT
#define CGL_SMOOTH GL_SMOOTH
#define CGL_COLOR_MATERIAL GL_COLOR_MATERIAL
#define CGL_COLOR_MATERIAL_FACE GL_COLOR_MATERIAL_FACE
#define CGL_COLOR_MATERIAL_PARAMETER GL_COLOR_MATERIAL_PARAMETER
#define CGL_NORMALIZE GL_NORMALIZE
#define CGL_ACCUM_RED_BITS GL_ACCUM_RED_BITS
#define CGL_ACCUM_GREEN_BITS GL_ACCUM_GREEN_BITS
#define CGL_ACCUM_BLUE_BITS GL_ACCUM_BLUE_BITS
#define CGL_ACCUM_ALPHA_BITS GL_ACCUM_ALPHA_BITS
#define CGL_ACCUM_CLEAR_VALUE GL_ACCUM_CLEAR_VALUE
#define CGL_ACCUM GL_ACCUM
#define CGL_ADD GL_ADD
#define CGL_LOAD GL_LOAD
#define CGL_MULT GL_MULT
#define CGL_RETURN GL_RETURN
#define CGL_ALPHA_TEST GL_ALPHA_TEST
#define CGL_ALPHA_TEST_REF GL_ALPHA_TEST_REF
#define CGL_ALPHA_TEST_FUNC GL_ALPHA_TEST_FUNC
#define CGL_BLEND GL_BLEND
#define CGL_BLEND_SRC GL_BLEND_SRC
#define CGL_BLEND_DST GL_BLEND_DST
#define CGL_ZERO GL_ZERO
#define CGL_ONE GL_ONE
#define CGL_SRC_COLOR GL_SRC_COLOR
#define CGL_ONE_MINUS_SRC_COLOR GL_ONE_MINUS_SRC_COLOR
#define CGL_SRC_ALPHA GL_SRC_ALPHA
#define CGL_ONE_MINUS_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
#define CGL_DST_ALPHA GL_DST_ALPHA
#define CGL_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_DST_ALPHA
#define CGL_DST_COLOR GL_DST_COLOR
#define CGL_ONE_MINUS_DST_COLOR GL_ONE_MINUS_DST_COLOR
#define CGL_SRC_ALPHA_SATURATE GL_SRC_ALPHA_SATURATE
#define CGL_FEEDBACK GL_FEEDBACK
#define CGL_RENDER GL_RENDER
#define CGL_SELECT GL_SELECT
#define CGL_POINT_TOKEN GL_POINT_TOKEN
#define CGL_LINE_TOKEN GL_LINE_TOKEN
#define CGL_LINE_RESET_TOKEN GL_LINE_RESET_TOKEN
#define CGL_POLYGON_TOKEN GL_POLYGON_TOKEN
#define CGL_BITMAP_TOKEN GL_BITMAP_TOKEN
#define CGL_DRAW_PIXEL_TOKEN GL_DRAW_PIXEL_TOKEN
#define CGL_COPY_PIXEL_TOKEN GL_COPY_PIXEL_TOKEN
#define CGL_PASS_THROUGH_TOKEN GL_PASS_THROUGH_TOKEN
#define CGL_FEEDBACK_BUFFER_POINTER GL_FEEDBACK_BUFFER_POINTER
#define CGL_FEEDBACK_BUFFER_SIZE GL_FEEDBACK_BUFFER_SIZE
#define CGL_FEEDBACK_BUFFER_TYPE GL_FEEDBACK_BUFFER_TYPE
#define CGL_SELECTION_BUFFER_POINTER GL_SELECTION_BUFFER_POINTER
#define CGL_SELECTION_BUFFER_SIZE GL_SELECTION_BUFFER_SIZE
#define CGL_FOG GL_FOG
#define CGL_FOG_MODE GL_FOG_MODE
#define CGL_FOG_DENSITY GL_FOG_DENSITY
#define CGL_FOG_COLOR GL_FOG_COLOR
#define CGL_FOG_INDEX GL_FOG_INDEX
#define CGL_FOG_START GL_FOG_START
#define CGL_FOG_END GL_FOG_END
#define CGL_LINEAR GL_LINEAR
#define CGL_EXP GL_EXP
#define CGL_LOGIC_OP GL_LOGIC_OP
#define CGL_INDEX_LOGIC_OP GL_INDEX_LOGIC_OP
#define CGL_COLOR_LOGIC_OP GL_COLOR_LOGIC_OP
#define CGL_LOGIC_OP_MODE GL_LOGIC_OP_MODE
#define CGL_CLEAR GL_CLEAR
#define CGL_SET GL_SET
#define CGL_COPY GL_COPY
#define CGL_COPY_INVERTED GL_COPY_INVERTED
#define CGL_NOOP GL_NOOP
#define CGL_INVERT GL_INVERT
#define CGL_AND GL_AND
#define CGL_NAND GL_NAND
#define CGL_OR GL_OR
#define CGL_NOR GL_NOR
#define CGL_XOR GL_XOR
#define CGL_EQUIV GL_EQUIV
#define CGL_AND_REVERSE GL_AND_REVERSE
#define CGL_AND_INVERTED GL_AND_INVERTED
#define CGL_OR_REVERSE GL_OR_REVERSE
#define CGL_OR_INVERTED GL_OR_INVERTED
#define CGL_STENCIL_BITS GL_STENCIL_BITS
#define CGL_STENCIL_TEST GL_STENCIL_TEST
#define CGL_STENCIL_CLEAR_VALUE GL_STENCIL_CLEAR_VALUE
#define CGL_STENCIL_FUNC GL_STENCIL_FUNC
#define CGL_STENCIL_VALUE_MASK GL_STENCIL_VALUE_MASK
#define CGL_STENCIL_FAIL GL_STENCIL_FAIL
#define CGL_STENCIL_PASS_DEPTH_FAIL GL_STENCIL_PASS_DEPTH_FAIL
#define CGL_STENCIL_PASS_DEPTH_PASS GL_STENCIL_PASS_DEPTH_PASS
#define CGL_STENCIL_REF GL_STENCIL_REF
#define CGL_STENCIL_WRITEMASK GL_STENCIL_WRITEMASK
#define CGL_STENCIL_INDEX GL_STENCIL_INDEX
#define CGL_KEEP GL_KEEP
#define CGL_REPLACE GL_REPLACE
#define CGL_INCR GL_INCR
#define CGL_DECR GL_DECR
#define CGL_NONE GL_NONE
#define CGL_LEFT GL_LEFT
#define CGL_RIGHT GL_RIGHT
#define CGL_FRONT_LEFT GL_FRONT_LEFT
#define CGL_FRONT_RIGHT GL_FRONT_RIGHT
#define CGL_BACK_LEFT GL_BACK_LEFT
#define CGL_BACK_RIGHT GL_BACK_RIGHT
#define CGL_COLOR_INDEX GL_COLOR_INDEX
#define CGL_RED GL_RED
#define CGL_GREEN GL_GREEN
#define CGL_BLUE GL_BLUE
#define CGL_ALPHA GL_ALPHA
#define CGL_LUMINANCE GL_LUMINANCE
#define CGL_LUMINANCE_ALPHA GL_LUMINANCE_ALPHA
#define CGL_ALPHA_BITS GL_ALPHA_BITS
#define CGL_RED_BITS GL_RED_BITS
#define CGL_GREEN_BITS GL_GREEN_BITS
#define CGL_BLUE_BITS GL_BLUE_BITS
#define CGL_INDEX_BITS GL_INDEX_BITS
#define CGL_SUBPIXEL_BITS GL_SUBPIXEL_BITS
#define CGL_AUX_BUFFERS GL_AUX_BUFFERS
#define CGL_READ_BUFFER GL_READ_BUFFER
#define CGL_DRAW_BUFFER GL_DRAW_BUFFER
#define CGL_DOUBLEBUFFER GL_DOUBLEBUFFER
#define CGL_STEREO GL_STEREO
#define CGL_BITMAP GL_BITMAP
#define CGL_COLOR GL_COLOR
#define CGL_DEPTH GL_DEPTH
#define CGL_STENCIL GL_STENCIL
#define CGL_DITHER GL_DITHER
#define CGL_RGB GL_RGB
#define CGL_RGBA GL_RGBA
#define CGL_MAX_LIST_NESTING GL_MAX_LIST_NESTING
#define CGL_MAX_EVAL_ORDER GL_MAX_EVAL_ORDER
#define CGL_MAX_LIGHTS GL_MAX_LIGHTS
#define CGL_MAX_CLIP_PLANES GL_MAX_CLIP_PLANES
#define CGL_MAX_TEXTURE_SIZE GL_MAX_TEXTURE_SIZE
#define CGL_MAX_PIXEL_MAP_TABLE GL_MAX_PIXEL_MAP_TABLE
#define CGL_MAX_ATTRIB_STACK_DEPTH GL_MAX_ATTRIB_STACK_DEPTH
#define CGL_MAX_MODELVIEW_STACK_DEPTH GL_MAX_MODELVIEW_STACK_DEPTH
#define CGL_MAX_NAME_STACK_DEPTH GL_MAX_NAME_STACK_DEPTH
#define CGL_MAX_PROJECTION_STACK_DEPTH GL_MAX_PROJECTION_STACK_DEPTH
#define CGL_MAX_TEXTURE_STACK_DEPTH GL_MAX_TEXTURE_STACK_DEPTH
#define CGL_MAX_VIEWPORT_DIMS GL_MAX_VIEWPORT_DIMS
#define CGL_MAX_CLIENT_ATTRIB_STACK_DEPTH GL_MAX_CLIENT_ATTRIB_STACK_DEPTH
#define CGL_ATTRIB_STACK_DEPTH GL_ATTRIB_STACK_DEPTH
#define CGL_CLIENT_ATTRIB_STACK_DEPTH GL_CLIENT_ATTRIB_STACK_DEPTH
#define CGL_COLOR_CLEAR_VALUE GL_COLOR_CLEAR_VALUE
#define CGL_COLOR_WRITEMASK GL_COLOR_WRITEMASK
#define CGL_CURRENT_INDEX GL_CURRENT_INDEX
#define CGL_CURRENT_COLOR GL_CURRENT_COLOR
#define CGL_CURRENT_NORMAL GL_CURRENT_NORMAL
#define CGL_CURRENT_RASTER_COLOR GL_CURRENT_RASTER_COLOR
#define CGL_CURRENT_RASTER_DISTANCE GL_CURRENT_RASTER_DISTANCE
#define CGL_CURRENT_RASTER_INDEX GL_CURRENT_RASTER_INDEX
#define CGL_CURRENT_RASTER_POSITION GL_CURRENT_RASTER_POSITION
#define CGL_CURRENT_RASTER_TEXTURE_COORDS GL_CURRENT_RASTER_TEXTURE_COORDS
#define CGL_CURRENT_RASTER_POSITION_VALID GL_CURRENT_RASTER_POSITION_VALID
#define CGL_CURRENT_TEXTURE_COORDS GL_CURRENT_TEXTURE_COORDS
#define CGL_INDEX_CLEAR_VALUE GL_INDEX_CLEAR_VALUE
#define CGL_INDEX_MODE GL_INDEX_MODE
#define CGL_INDEX_WRITEMASK GL_INDEX_WRITEMASK
#define CGL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX
#define CGL_MODELVIEW_STACK_DEPTH GL_MODELVIEW_STACK_DEPTH
#define CGL_NAME_STACK_DEPTH GL_NAME_STACK_DEPTH
#define CGL_PROJECTION_MATRIX GL_PROJECTION_MATRIX
#define CGL_PROJECTION_STACK_DEPTH GL_PROJECTION_STACK_DEPTH
#define CGL_RENDER_MODE GL_RENDER_MODE
#define CGL_RGBA_MODE GL_RGBA_MODE
#define CGL_TEXTURE_MATRIX GL_TEXTURE_MATRIX
#define CGL_TEXTURE_STACK_DEPTH GL_TEXTURE_STACK_DEPTH
#define CGL_VIEWPORT GL_VIEWPORT
#define CGL_AUTO_NORMAL GL_AUTO_NORMAL
#define CGL_COEFF GL_COEFF
#define CGL_ORDER GL_ORDER
#define CGL_DOMAIN GL_DOMAIN
#define CGL_PERSPECTIVE_CORRECTION_HINT GL_PERSPECTIVE_CORRECTION_HINT
#define CGL_POINT_SMOOTH_HINT GL_POINT_SMOOTH_HINT
#define CGL_LINE_SMOOTH_HINT GL_LINE_SMOOTH_HINT
#define CGL_POLYGON_SMOOTH_HINT GL_POLYGON_SMOOTH_HINT
#define CGL_FOG_HINT GL_FOG_HINT
#define CGL_DONT_CARE GL_DONT_CARE
#define CGL_FASTEST GL_FASTEST
#define CGL_NICEST GL_NICEST
#define CGL_SCISSOR_BOX GL_SCISSOR_BOX
#define CGL_SCISSOR_TEST GL_SCISSOR_TEST
#define CGL_MAP_COLOR GL_MAP_COLOR
#define CGL_MAP_STENCIL GL_MAP_STENCIL
#define CGL_INDEX_SHIFT GL_INDEX_SHIFT
#define CGL_INDEX_OFFSET GL_INDEX_OFFSET
#define CGL_RED_SCALE GL_RED_SCALE
#define CGL_RED_BIAS GL_RED_BIAS
#define CGL_GREEN_SCALE GL_GREEN_SCALE
#define CGL_GREEN_BIAS GL_GREEN_BIAS
#define CGL_BLUE_SCALE GL_BLUE_SCALE
#define CGL_BLUE_BIAS GL_BLUE_BIAS
#define CGL_ALPHA_SCALE GL_ALPHA_SCALE
#define CGL_ALPHA_BIAS GL_ALPHA_BIAS
#define CGL_DEPTH_SCALE GL_DEPTH_SCALE
#define CGL_DEPTH_BIAS GL_DEPTH_BIAS
#define CGL_PIXEL_MAP_S_TO_S_SIZE GL_PIXEL_MAP_S_TO_S_SIZE
#define CGL_PIXEL_MAP_I_TO_I_SIZE GL_PIXEL_MAP_I_TO_I_SIZE
#define CGL_PIXEL_MAP_I_TO_R_SIZE GL_PIXEL_MAP_I_TO_R_SIZE
#define CGL_PIXEL_MAP_I_TO_G_SIZE GL_PIXEL_MAP_I_TO_G_SIZE
#define CGL_PIXEL_MAP_I_TO_B_SIZE GL_PIXEL_MAP_I_TO_B_SIZE
#define CGL_PIXEL_MAP_I_TO_A_SIZE GL_PIXEL_MAP_I_TO_A_SIZE
#define CGL_PIXEL_MAP_R_TO_R_SIZE GL_PIXEL_MAP_R_TO_R_SIZE
#define CGL_PIXEL_MAP_G_TO_G_SIZE GL_PIXEL_MAP_G_TO_G_SIZE
#define CGL_PIXEL_MAP_B_TO_B_SIZE GL_PIXEL_MAP_B_TO_B_SIZE
#define CGL_PIXEL_MAP_A_TO_A_SIZE GL_PIXEL_MAP_A_TO_A_SIZE
#define CGL_PIXEL_MAP_S_TO_S GL_PIXEL_MAP_S_TO_S
#define CGL_PIXEL_MAP_I_TO_I GL_PIXEL_MAP_I_TO_I
#define CGL_PIXEL_MAP_I_TO_R GL_PIXEL_MAP_I_TO_R
#define CGL_PIXEL_MAP_I_TO_G GL_PIXEL_MAP_I_TO_G
#define CGL_PIXEL_MAP_I_TO_B GL_PIXEL_MAP_I_TO_B
#define CGL_PIXEL_MAP_I_TO_A GL_PIXEL_MAP_I_TO_A
#define CGL_PIXEL_MAP_R_TO_R GL_PIXEL_MAP_R_TO_R
#define CGL_PIXEL_MAP_G_TO_G GL_PIXEL_MAP_G_TO_G
#define CGL_PIXEL_MAP_B_TO_B GL_PIXEL_MAP_B_TO_B
#define CGL_PIXEL_MAP_A_TO_A GL_PIXEL_MAP_A_TO_A
#define CGL_PACK_ALIGNMENT GL_PACK_ALIGNMENT
#define CGL_PACK_LSB_FIRST GL_PACK_LSB_FIRST
#define CGL_PACK_ROW_LENGTH GL_PACK_ROW_LENGTH
#define CGL_PACK_SKIP_PIXELS GL_PACK_SKIP_PIXELS
#define CGL_PACK_SKIP_ROWS GL_PACK_SKIP_ROWS
#define CGL_PACK_SWAP_BYTES GL_PACK_SWAP_BYTES
#define CGL_UNPACK_ALIGNMENT GL_UNPACK_ALIGNMENT
#define CGL_UNPACK_LSB_FIRST GL_UNPACK_LSB_FIRST
#define CGL_UNPACK_ROW_LENGTH GL_UNPACK_ROW_LENGTH
#define CGL_UNPACK_SKIP_PIXELS GL_UNPACK_SKIP_PIXELS
#define CGL_UNPACK_SKIP_ROWS GL_UNPACK_SKIP_ROWS
#define CGL_UNPACK_SWAP_BYTES GL_UNPACK_SWAP_BYTES
#define CGL_ZOOM_X GL_ZOOM_X
#define CGL_ZOOM_Y GL_ZOOM_Y
#define CGL_TEXTURE_ENV GL_TEXTURE_ENV
#define CGL_TEXTURE_ENV_MODE GL_TEXTURE_ENV_MODE
#define CGL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_S
#define CGL_TEXTURE_WRAP_T GL_TEXTURE_WRAP_T
#define CGL_TEXTURE_MAG_FILTER GL_TEXTURE_MAG_FILTER
#define CGL_TEXTURE_MIN_FILTER GL_TEXTURE_MIN_FILTER
#define CGL_TEXTURE_ENV_COLOR GL_TEXTURE_ENV_COLOR
#define CGL_TEXTURE_GEN_S GL_TEXTURE_GEN_S
#define CGL_TEXTURE_GEN_T GL_TEXTURE_GEN_T
#define CGL_TEXTURE_GEN_MODE GL_TEXTURE_GEN_MODE
#define CGL_TEXTURE_BORDER_COLOR GL_TEXTURE_BORDER_COLOR
#define CGL_TEXTURE_WIDTH GL_TEXTURE_WIDTH
#define CGL_TEXTURE_HEIGHT GL_TEXTURE_HEIGHT
#define CGL_TEXTURE_BORDER GL_TEXTURE_BORDER
#define CGL_TEXTURE_COMPONENTS GL_TEXTURE_COMPONENTS
#define CGL_TEXTURE_RED_SIZE GL_TEXTURE_RED_SIZE
#define CGL_TEXTURE_GREEN_SIZE GL_TEXTURE_GREEN_SIZE
#define CGL_TEXTURE_BLUE_SIZE GL_TEXTURE_BLUE_SIZE
#define CGL_TEXTURE_ALPHA_SIZE GL_TEXTURE_ALPHA_SIZE
#define CGL_TEXTURE_LUMINANCE_SIZE GL_TEXTURE_LUMINANCE_SIZE
#define CGL_TEXTURE_INTENSITY_SIZE GL_TEXTURE_INTENSITY_SIZE
#define CGL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_NEAREST
#define CGL_NEAREST_MIPMAP_LINEAR GL_NEAREST_MIPMAP_LINEAR
#define CGL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_NEAREST
#define CGL_LINEAR_MIPMAP_LINEAR GL_LINEAR_MIPMAP_LINEAR
#define CGL_OBJECT_LINEAR GL_OBJECT_LINEAR
#define CGL_OBJECT_PLANE GL_OBJECT_PLANE
#define CGL_EYE_LINEAR GL_EYE_LINEAR
#define CGL_EYE_PLANE GL_EYE_PLANE
#define CGL_SPHERE_MAP GL_SPHERE_MAP
#define CGL_DECAL GL_DECAL
#define CGL_MODULATE GL_MODULATE
#define CGL_NEAREST GL_NEAREST
#define CGL_REPEAT GL_REPEAT
#define CGL_CLAMP GL_CLAMP
#define CGL_S GL_S
#define CGL_T GL_T
#define CGL_R GL_R
#define CGL_Q GL_Q
#define CGL_TEXTURE_GEN_R GL_TEXTURE_GEN_R
#define CGL_TEXTURE_GEN_Q GL_TEXTURE_GEN_Q
#define CGL_VENDOR GL_VENDOR
#define CGL_RENDERER GL_RENDERER
#define CGL_VERSION GL_VERSION
#define CGL_EXTENSIONS GL_EXTENSIONS
#define CGL_NO_ERROR GL_NO_ERROR
#define CGL_INVALID_ENUM GL_INVALID_ENUM
#define CGL_INVALID_VALUE GL_INVALID_VALUE
#define CGL_INVALID_OPERATION GL_INVALID_OPERATION
#define CGL_STACK_OVERFLOW GL_STACK_OVERFLOW
#define CGL_STACK_UNDERFLOW GL_STACK_UNDERFLOW
#define CGL_OUT_OF_MEMORY GL_OUT_OF_MEMORY
#define CGL_CURRENT_BIT GL_CURRENT_BIT
#define CGL_POINT_BIT GL_POINT_BIT
#define CGL_LINE_BIT GL_LINE_BIT
#define CGL_POLYGON_BIT GL_POLYGON_BIT
#define CGL_POLYGON_STIPPLE_BIT GL_POLYGON_STIPPLE_BIT
#define CGL_PIXEL_MODE_BIT GL_PIXEL_MODE_BIT
#define CGL_LIGHTING_BIT GL_LIGHTING_BIT
#define CGL_FOG_BIT GL_FOG_BIT
#define CGL_DEPTH_BUFFER_BIT GL_DEPTH_BUFFER_BIT
#define CGL_ACCUM_BUFFER_BIT GL_ACCUM_BUFFER_BIT
#define CGL_STENCIL_BUFFER_BIT GL_STENCIL_BUFFER_BIT
#define CGL_VIEWPORT_BIT GL_VIEWPORT_BIT
#define CGL_TRANSFORM_BIT GL_TRANSFORM_BIT
#define CGL_ENABLE_BIT GL_ENABLE_BIT
#define CGL_COLOR_BUFFER_BIT GL_COLOR_BUFFER_BIT
#define CGL_HINT_BIT GL_HINT_BIT
#define CGL_EVAL_BIT GL_EVAL_BIT
#define CGL_LIST_BIT GL_LIST_BIT
#define CGL_TEXTURE_BIT GL_TEXTURE_BIT
#define CGL_SCISSOR_BIT GL_SCISSOR_BIT
#define CGL_ALL_ATTRIB_BITS GL_ALL_ATTRIB_BITS
#define CGL_TEXTURE_PRIORITY GL_TEXTURE_PRIORITY
#define CGL_TEXTURE_RESIDENT GL_TEXTURE_RESIDENT
#define CGL_TEXTURE_INTERNAL_FORMAT GL_TEXTURE_INTERNAL_FORMAT
#define CGL_INTENSITY GL_INTENSITY
#define CGL_CLIENT_PIXEL_STORE_BIT GL_CLIENT_PIXEL_STORE_BIT
#define CGL_CLIENT_VERTEX_ARRAY_BIT GL_CLIENT_VERTEX_ARRAY_BIT
#define CGL_ALL_CLIENT_ATTRIB_BITS GL_ALL_CLIENT_ATTRIB_BITS
#define CGL_CLIENT_ALL_ATTRIB_BITS GL_CLIENT_ALL_ATTRIB_BITS
#define CGL_RESCALE_NORMAL GL_RESCALE_NORMAL
#define CGL_CLAMP_TO_EDGE GL_CLAMP_TO_EDGE
#define CGL_MAX_ELEMENTS_VERTICES GL_MAX_ELEMENTS_VERTICES
#define CGL_MAX_ELEMENTS_INDICES GL_MAX_ELEMENTS_INDICES
#define CGL_BGR GL_BGR
#define CGL_BGRA GL_BGRA
#define CGL_LIGHT_MODEL_COLOR_CONTROL GL_LIGHT_MODEL_COLOR_CONTROL
#define CGL_SINGLE_COLOR GL_SINGLE_COLOR
#define CGL_SEPARATE_SPECULAR_COLOR GL_SEPARATE_SPECULAR_COLOR
#define CGL_TEXTURE_MIN_LOD GL_TEXTURE_MIN_LOD
#define CGL_TEXTURE_MAX_LOD GL_TEXTURE_MAX_LOD
#define CGL_TEXTURE_BASE_LEVEL GL_TEXTURE_BASE_LEVEL
#define CGL_TEXTURE_MAX_LEVEL GL_TEXTURE_MAX_LEVEL
#define CGL_SMOOTH_POINT_SIZE_RANGE GL_SMOOTH_POINT_SIZE_RANGE
#define CGL_SMOOTH_POINT_SIZE_GRANULARITY GL_SMOOTH_POINT_SIZE_GRANULARITY
#define CGL_SMOOTH_LINE_WIDTH_RANGE GL_SMOOTH_LINE_WIDTH_RANGE
#define CGL_SMOOTH_LINE_WIDTH_GRANULARITY GL_SMOOTH_LINE_WIDTH_GRANULARITY
#define CGL_ALIASED_POINT_SIZE_RANGE GL_ALIASED_POINT_SIZE_RANGE
#define CGL_ALIASED_LINE_WIDTH_RANGE GL_ALIASED_LINE_WIDTH_RANGE
#define CGL_PACK_SKIP_IMAGES GL_PACK_SKIP_IMAGES
#define CGL_PACK_IMAGE_HEIGHT GL_PACK_IMAGE_HEIGHT
#define CGL_UNPACK_SKIP_IMAGES GL_UNPACK_SKIP_IMAGES
#define CGL_UNPACK_IMAGE_HEIGHT GL_UNPACK_IMAGE_HEIGHT
#define CGL_TEXTURE_DEPTH GL_TEXTURE_DEPTH
#define CGL_TEXTURE_WRAP_R GL_TEXTURE_WRAP_R
#define CGL_CONSTANT_COLOR GL_CONSTANT_COLOR
#define CGL_ONE_MINUS_CONSTANT_COLOR GL_ONE_MINUS_CONSTANT_COLOR
#define CGL_CONSTANT_ALPHA GL_CONSTANT_ALPHA
#define CGL_ONE_MINUS_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA
#define CGL_COLOR_TABLE GL_COLOR_TABLE
#define CGL_POST_CONVOLUTION_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE
#define CGL_POST_COLOR_MATRIX_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE
#define CGL_PROXY_COLOR_TABLE GL_PROXY_COLOR_TABLE
#define CGL_PROXY_POST_CONVOLUTION_COLOR_TABLE GL_PROXY_POST_CONVOLUTION_COLOR_TABLE
#define CGL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE
#define CGL_COLOR_TABLE_SCALE GL_COLOR_TABLE_SCALE
#define CGL_COLOR_TABLE_BIAS GL_COLOR_TABLE_BIAS
#define CGL_COLOR_TABLE_FORMAT GL_COLOR_TABLE_FORMAT
#define CGL_COLOR_TABLE_WIDTH GL_COLOR_TABLE_WIDTH
#define CGL_COLOR_TABLE_RED_SIZE GL_COLOR_TABLE_RED_SIZE
#define CGL_COLOR_TABLE_GREEN_SIZE GL_COLOR_TABLE_GREEN_SIZE
#define CGL_COLOR_TABLE_BLUE_SIZE GL_COLOR_TABLE_BLUE_SIZE
#define CGL_COLOR_TABLE_ALPHA_SIZE GL_COLOR_TABLE_ALPHA_SIZE
#define CGL_COLOR_TABLE_LUMINANCE_SIZE GL_COLOR_TABLE_LUMINANCE_SIZE
#define CGL_COLOR_TABLE_INTENSITY_SIZE GL_COLOR_TABLE_INTENSITY_SIZE
#define CGL_CONVOLUTION_BORDER_MODE GL_CONVOLUTION_BORDER_MODE
#define CGL_CONVOLUTION_FILTER_SCALE GL_CONVOLUTION_FILTER_SCALE
#define CGL_CONVOLUTION_FILTER_BIAS GL_CONVOLUTION_FILTER_BIAS
#define CGL_REDUCE GL_REDUCE
#define CGL_CONVOLUTION_FORMAT GL_CONVOLUTION_FORMAT
#define CGL_CONVOLUTION_WIDTH GL_CONVOLUTION_WIDTH
#define CGL_CONVOLUTION_HEIGHT GL_CONVOLUTION_HEIGHT
#define CGL_MAX_CONVOLUTION_WIDTH GL_MAX_CONVOLUTION_WIDTH
#define CGL_MAX_CONVOLUTION_HEIGHT GL_MAX_CONVOLUTION_HEIGHT
#define CGL_POST_CONVOLUTION_RED_SCALE GL_POST_CONVOLUTION_RED_SCALE
#define CGL_POST_CONVOLUTION_GREEN_SCALE GL_POST_CONVOLUTION_GREEN_SCALE
#define CGL_POST_CONVOLUTION_BLUE_SCALE GL_POST_CONVOLUTION_BLUE_SCALE
#define CGL_POST_CONVOLUTION_ALPHA_SCALE GL_POST_CONVOLUTION_ALPHA_SCALE
#define CGL_POST_CONVOLUTION_RED_BIAS GL_POST_CONVOLUTION_RED_BIAS
#define CGL_POST_CONVOLUTION_GREEN_BIAS GL_POST_CONVOLUTION_GREEN_BIAS
#define CGL_POST_CONVOLUTION_BLUE_BIAS GL_POST_CONVOLUTION_BLUE_BIAS
#define CGL_POST_CONVOLUTION_ALPHA_BIAS GL_POST_CONVOLUTION_ALPHA_BIAS
#define CGL_CONSTANT_BORDER GL_CONSTANT_BORDER
#define CGL_REPLICATE_BORDER GL_REPLICATE_BORDER
#define CGL_CONVOLUTION_BORDER_COLOR GL_CONVOLUTION_BORDER_COLOR
#define CGL_COLOR_MATRIX GL_COLOR_MATRIX
#define CGL_COLOR_MATRIX_STACK_DEPTH GL_COLOR_MATRIX_STACK_DEPTH
#define CGL_MAX_COLOR_MATRIX_STACK_DEPTH GL_MAX_COLOR_MATRIX_STACK_DEPTH
#define CGL_POST_COLOR_MATRIX_RED_SCALE GL_POST_COLOR_MATRIX_RED_SCALE
#define CGL_POST_COLOR_MATRIX_GREEN_SCALE GL_POST_COLOR_MATRIX_GREEN_SCALE
#define CGL_POST_COLOR_MATRIX_BLUE_SCALE GL_POST_COLOR_MATRIX_BLUE_SCALE
#define CGL_POST_COLOR_MATRIX_ALPHA_SCALE GL_POST_COLOR_MATRIX_ALPHA_SCALE
#define CGL_POST_COLOR_MATRIX_RED_BIAS GL_POST_COLOR_MATRIX_RED_BIAS
#define CGL_POST_COLOR_MATRIX_GREEN_BIAS GL_POST_COLOR_MATRIX_GREEN_BIAS
#define CGL_POST_COLOR_MATRIX_BLUE_BIAS GL_POST_COLOR_MATRIX_BLUE_BIAS
#define CGL_POST_COLOR_MATRIX_ALPHA_BIAS GL_POST_COLOR_MATRIX_ALPHA_BIAS
#define CGL_HISTOGRAM GL_HISTOGRAM
#define CGL_PROXY_HISTOGRAM GL_PROXY_HISTOGRAM
#define CGL_HISTOGRAM_WIDTH GL_HISTOGRAM_WIDTH
#define CGL_HISTOGRAM_FORMAT GL_HISTOGRAM_FORMAT
#define CGL_HISTOGRAM_RED_SIZE GL_HISTOGRAM_RED_SIZE
#define CGL_HISTOGRAM_GREEN_SIZE GL_HISTOGRAM_GREEN_SIZE
#define CGL_HISTOGRAM_BLUE_SIZE GL_HISTOGRAM_BLUE_SIZE
#define CGL_HISTOGRAM_ALPHA_SIZE GL_HISTOGRAM_ALPHA_SIZE
#define CGL_HISTOGRAM_LUMINANCE_SIZE GL_HISTOGRAM_LUMINANCE_SIZE
#define CGL_HISTOGRAM_SINK GL_HISTOGRAM_SINK
#define CGL_MINMAX GL_MINMAX
#define CGL_MINMAX_FORMAT GL_MINMAX_FORMAT
#define CGL_MINMAX_SINK GL_MINMAX_SINK
#define CGL_TABLE_TOO_LARGE GL_TABLE_TOO_LARGE
#define CGL_BLEND_EQUATION GL_BLEND_EQUATION
#define CGL_MIN GL_MIN
#define CGL_MAX GL_MAX
#define CGL_FUNC_ADD GL_FUNC_ADD
#define CGL_FUNC_SUBTRACT GL_FUNC_SUBTRACT
#define CGL_FUNC_REVERSE_SUBTRACT GL_FUNC_REVERSE_SUBTRACT
#define CGL_BLEND_COLOR GL_BLEND_COLOR
#define CGL_ACTIVE_TEXTURE GL_ACTIVE_TEXTURE
#define CGL_CLIENT_ACTIVE_TEXTURE GL_CLIENT_ACTIVE_TEXTURE
#define CGL_MAX_TEXTURE_UNITS GL_MAX_TEXTURE_UNITS
#define CGL_NORMAL_MAP GL_NORMAL_MAP
#define CGL_REFLECTION_MAP GL_REFLECTION_MAP
#define CGL_TEXTURE_CUBE_MAP GL_TEXTURE_CUBE_MAP
#define CGL_TEXTURE_BINDING_CUBE_MAP GL_TEXTURE_BINDING_CUBE_MAP
#define CGL_TEXTURE_CUBE_MAP_POSITIVE_X GL_TEXTURE_CUBE_MAP_POSITIVE_X
#define CGL_TEXTURE_CUBE_MAP_NEGATIVE_X GL_TEXTURE_CUBE_MAP_NEGATIVE_X
#define CGL_TEXTURE_CUBE_MAP_POSITIVE_Y GL_TEXTURE_CUBE_MAP_POSITIVE_Y
#define CGL_TEXTURE_CUBE_MAP_NEGATIVE_Y GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
#define CGL_TEXTURE_CUBE_MAP_POSITIVE_Z GL_TEXTURE_CUBE_MAP_POSITIVE_Z
#define CGL_TEXTURE_CUBE_MAP_NEGATIVE_Z GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
#define CGL_PROXY_TEXTURE_CUBE_MAP GL_PROXY_TEXTURE_CUBE_MAP
#define CGL_MAX_CUBE_MAP_TEXTURE_SIZE GL_MAX_CUBE_MAP_TEXTURE_SIZE
#define CGL_COMPRESSED_ALPHA GL_COMPRESSED_ALPHA
#define CGL_COMPRESSED_LUMINANCE GL_COMPRESSED_LUMINANCE
#define CGL_COMPRESSED_LUMINANCE_ALPHA GL_COMPRESSED_LUMINANCE_ALPHA
#define CGL_COMPRESSED_INTENSITY GL_COMPRESSED_INTENSITY
#define CGL_COMPRESSED_RGB GL_COMPRESSED_RGB
#define CGL_COMPRESSED_RGBA GL_COMPRESSED_RGBA
#define CGL_TEXTURE_COMPRESSION_HINT GL_TEXTURE_COMPRESSION_HINT
#define CGL_TEXTURE_COMPRESSED_IMAGE_SIZE GL_TEXTURE_COMPRESSED_IMAGE_SIZE
#define CGL_TEXTURE_COMPRESSED GL_TEXTURE_COMPRESSED
#define CGL_NUM_COMPRESSED_TEXTURE_FORMATS GL_NUM_COMPRESSED_TEXTURE_FORMATS
#define CGL_COMPRESSED_TEXTURE_FORMATS GL_COMPRESSED_TEXTURE_FORMATS
#define CGL_MULTISAMPLE GL_MULTISAMPLE
#define CGL_SAMPLE_ALPHA_TO_COVERAGE GL_SAMPLE_ALPHA_TO_COVERAGE
#define CGL_SAMPLE_ALPHA_TO_ONE GL_SAMPLE_ALPHA_TO_ONE
#define CGL_SAMPLE_COVERAGE GL_SAMPLE_COVERAGE
#define CGL_SAMPLE_BUFFERS GL_SAMPLE_BUFFERS
#define CGL_SAMPLES GL_SAMPLES
#define CGL_SAMPLE_COVERAGE_VALUE GL_SAMPLE_COVERAGE_VALUE
#define CGL_SAMPLE_COVERAGE_INVERT GL_SAMPLE_COVERAGE_INVERT
#define CGL_MULTISAMPLE_BIT GL_MULTISAMPLE_BIT
#define CGL_TRANSPOSE_MODELVIEW_MATRIX GL_TRANSPOSE_MODELVIEW_MATRIX
#define CGL_TRANSPOSE_PROJECTION_MATRIX GL_TRANSPOSE_PROJECTION_MATRIX
#define CGL_TRANSPOSE_TEXTURE_MATRIX GL_TRANSPOSE_TEXTURE_MATRIX
#define CGL_TRANSPOSE_COLOR_MATRIX GL_TRANSPOSE_COLOR_MATRIX
#define CGL_COMBINE GL_COMBINE
#define CGL_COMBINE_RGB GL_COMBINE_RGB
#define CGL_COMBINE_ALPHA GL_COMBINE_ALPHA
#define CGL_RGB_SCALE GL_RGB_SCALE
#define CGL_ADD_SIGNED GL_ADD_SIGNED
#define CGL_INTERPOLATE GL_INTERPOLATE
#define CGL_SUBTRACT GL_SUBTRACT
#define CGL_CONSTANT GL_CONSTANT
#define CGL_PRIMARY_COLOR GL_PRIMARY_COLOR
#define CGL_PREVIOUS GL_PREVIOUS
#define CGL_CLAMP_TO_BORDER GL_CLAMP_TO_BORDER
#define CGL_ACTIVE_TEXTURE_ARB GL_ACTIVE_TEXTURE_ARB
#define CGL_CLIENT_ACTIVE_TEXTURE_ARB GL_CLIENT_ACTIVE_TEXTURE_ARB
#define CGL_MAX_TEXTURE_UNITS_ARB GL_MAX_TEXTURE_UNITS_ARB
#define CGL_DEBUG_OBJECT_MESA GL_DEBUG_OBJECT_MESA
#define CGL_DEBUG_PRINT_MESA GL_DEBUG_PRINT_MESA
#define CGL_DEBUG_ASSERT_MESA GL_DEBUG_ASSERT_MESA
#define CGL_TRACE_ALL_BITS_MESA GL_TRACE_ALL_BITS_MESA
#define CGL_TRACE_OPERATIONS_BIT_MESA GL_TRACE_OPERATIONS_BIT_MESA
#define CGL_TRACE_PRIMITIVES_BIT_MESA GL_TRACE_PRIMITIVES_BIT_MESA
#define CGL_TRACE_ARRAYS_BIT_MESA GL_TRACE_ARRAYS_BIT_MESA
#define CGL_TRACE_TEXTURES_BIT_MESA GL_TRACE_TEXTURES_BIT_MESA
#define CGL_TRACE_PIXELS_BIT_MESA GL_TRACE_PIXELS_BIT_MESA
#define CGL_TRACE_ERRORS_BIT_MESA GL_TRACE_ERRORS_BIT_MESA
#define CGL_TRACE_MASK_MESA GL_TRACE_MASK_MESA
#define CGL_TRACE_NAME_MESA GL_TRACE_NAME_MESA
#define CGL_DEPTH_STENCIL_MESA GL_DEPTH_STENCIL_MESA
#define CGL_FRAGMENT_PROGRAM_POSITION_MESA GL_FRAGMENT_PROGRAM_POSITION_MESA
#define CGL_FRAGMENT_PROGRAM_CALLBACK_MESA GL_FRAGMENT_PROGRAM_CALLBACK_MESA
#define CGL_FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA GL_FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA
#define CGL_FRAGMENT_PROGRAM_CALLBACK_DATA_MESA GL_FRAGMENT_PROGRAM_CALLBACK_DATA_MESA
#define CGL_VERTEX_PROGRAM_POSITION_MESA GL_VERTEX_PROGRAM_POSITION_MESA
#define CGL_VERTEX_PROGRAM_CALLBACK_MESA GL_VERTEX_PROGRAM_CALLBACK_MESA
#define CGL_VERTEX_PROGRAM_CALLBACK_FUNC_MESA GL_VERTEX_PROGRAM_CALLBACK_FUNC_MESA
#define CGL_VERTEX_PROGRAM_CALLBACK_DATA_MESA GL_VERTEX_PROGRAM_CALLBACK_DATA_MESA
#define CGL_ALPHA_BLEND_EQUATION_ATI GL_ALPHA_BLEND_EQUATION_ATI
#define CGL_TIME_ELAPSED_EXT GL_TIME_ELAPSED_EXT
#define CGL_READ_FRAMEBUFFER_EXT GL_READ_FRAMEBUFFER_EXT
#define CGL_DRAW_FRAMEBUFFER_EXT GL_DRAW_FRAMEBUFFER_EXT
#define CGL_DRAW_FRAMEBUFFER_BINDING_EXT GL_DRAW_FRAMEBUFFER_BINDING_EXT
#define CGL_READ_FRAMEBUFFER_BINDING_EXT GL_READ_FRAMEBUFFER_BINDING_EXT
#define CGL_DEPTH_STENCIL_EXT GL_DEPTH_STENCIL_EXT
#define CGL_TEXTURE_STENCIL_SIZE_EXT GL_TEXTURE_STENCIL_SIZE_EXT
#define CGL_SRGB_EXT GL_SRGB_EXT
#define CGL_SRGB_ALPHA_EXT GL_SRGB_ALPHA_EXT
#define CGL_SLUMINANCE_ALPHA_EXT GL_SLUMINANCE_ALPHA_EXT
#define CGL_SLUMINANCE_EXT GL_SLUMINANCE_EXT
#define CGL_COMPRESSED_SRGB_EXT GL_COMPRESSED_SRGB_EXT
#define CGL_COMPRESSED_SRGB_ALPHA_EXT GL_COMPRESSED_SRGB_ALPHA_EXT
#define CGL_COMPRESSED_SLUMINANCE_EXT GL_COMPRESSED_SLUMINANCE_EXT
#define CGL_COMPRESSED_SLUMINANCE_ALPHA_EXT GL_COMPRESSED_SLUMINANCE_ALPHA_EXT
/* extras */
#define CGL_TEXTURE_2D GL_TEXTURE_2D
#define CGL_ARGB GL_ARGB
#define CGL_TEXTURE_RECTANGLE_ARB GL_TEXTURE_RECTANGLE_ARB
G_END_DECLS
#endif

View File

@ -23,8 +23,67 @@
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "cogl.h"
#include <GL/gl.h>
#include <string.h>
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define PIXEL_TYPE GL_UNSIGNED_BYTE
#else
#define PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
#endif
static gulong __enable_flags = 0;
#if COGL_DEBUG
struct token_string
{
GLuint Token;
const char *String;
};
static const struct token_string Errors[] = {
{ GL_NO_ERROR, "no error" },
{ GL_INVALID_ENUM, "invalid enumerant" },
{ GL_INVALID_VALUE, "invalid value" },
{ GL_INVALID_OPERATION, "invalid operation" },
{ GL_STACK_OVERFLOW, "stack overflow" },
{ GL_STACK_UNDERFLOW, "stack underflow" },
{ GL_OUT_OF_MEMORY, "out of memory" },
#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT
{ GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" },
#endif
{ ~0, NULL }
};
static const char*
error_string(GLenum errorCode)
{
int i;
for (i = 0; Errors[i].String; i++) {
if (Errors[i].Token == errorCode)
return Errors[i].String;
}
return "unknown";
}
#endif
#if COGL_DEBUG
#define GE(x...) G_STMT_START { \
GLenum err; \
(x); \
while ((err = glGetError()) != GL_NO_ERROR) { \
fprintf(stderr, "glError: %s caught at %s:%u\n", \
(char *)error_string(err), \
__FILE__, __LINE__); \
} \
} G_STMT_END
#else
#define GE(x) (x);
#endif
CoglFuncPtr
cogl_get_proc_address (const gchar* name)
@ -41,14 +100,18 @@ cogl_check_extension (const gchar *name, const gchar *ext)
void
cogl_paint_init (ClutterColor *color)
{
glClearColor (((float) color->red / 0xff * 1.0),
((float) color->green / 0xff * 1.0),
((float) color->blue / 0xff * 1.0),
0.0);
GE( glClearColor (((float) color->red / 0xff * 1.0),
((float) color->green / 0xff * 1.0),
((float) color->blue / 0xff * 1.0),
0.0) );
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glDisable (GL_LIGHTING);
glDisable (GL_DEPTH_TEST);
cogl_enable (CGL_ENABLE_BLEND);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
/* FIXME: inline most of these */
@ -65,7 +128,7 @@ cogl_pop_matrix (void)
}
void
cogl_scaled (ClutterFixed x, ClutterFixed y)
cogl_scale (ClutterFixed x, ClutterFixed y)
{
glScaled (CLUTTER_FIXED_TO_DOUBLE (x),
CLUTTER_FIXED_TO_DOUBLE (y),
@ -100,3 +163,367 @@ cogl_rotate (gint angle, gint x, gint y, gint z)
{
glRotatef ((float)angle, (float)x, (float)y, (float)z);
}
void
cogl_enable (gulong flags)
{
/* This function essentially caches glEnable state() in the
* hope of lessening number GL traffic.
*/
if (flags & CGL_ENABLE_BLEND)
{
if (!(__enable_flags & CGL_ENABLE_BLEND))
{
glEnable (GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
__enable_flags |= CGL_ENABLE_BLEND;
}
else if (__enable_flags & CGL_ENABLE_BLEND)
{
glDisable (GL_BLEND);
__enable_flags &= ~CGL_ENABLE_BLEND;
}
if (flags & CGL_ENABLE_TEXTURE_2D)
{
if (!(__enable_flags & CGL_ENABLE_TEXTURE_2D))
glEnable (GL_TEXTURE_2D);
__enable_flags |= CGL_ENABLE_TEXTURE_2D;
}
else if (__enable_flags & CGL_ENABLE_TEXTURE_2D)
{
glDisable (GL_TEXTURE_2D);
__enable_flags &= ~CGL_ENABLE_TEXTURE_2D;
}
if (flags & CGL_ENABLE_TEXTURE_RECT)
{
if (!(__enable_flags & CGL_ENABLE_TEXTURE_RECT))
glEnable (GL_TEXTURE_RECTANGLE_ARB);
__enable_flags |= CGL_ENABLE_TEXTURE_RECT;
}
else if (__enable_flags & CGL_ENABLE_TEXTURE_RECT)
{
glDisable (GL_TEXTURE_RECTANGLE_ARB);
__enable_flags &= ~CGL_ENABLE_TEXTURE_RECT;
}
if (flags & CGL_ENABLE_ALPHA_TEST)
{
if (!(__enable_flags & CGL_ENABLE_ALPHA_TEST))
glEnable (GL_ALPHA_TEST);
__enable_flags |= CGL_ENABLE_ALPHA_TEST;
}
else if (__enable_flags & CGL_ENABLE_ALPHA_TEST)
{
glDisable (GL_ALPHA_TEST);
__enable_flags &= ~CGL_ENABLE_ALPHA_TEST;
}
}
void
cogl_color (ClutterColor *color)
{
glColor4ub (color->red, color->green, color->blue, color->alpha);
}
gboolean
cogl_texture_can_size (COGLenum pixel_format,
COGLenum pixel_type,
int width,
int height)
{
GLint new_width = 0;
GE( glTexImage2D (GL_PROXY_TEXTURE_2D, 0, GL_RGBA,
width, height, 0 /* border */,
pixel_format, pixel_type, NULL) );
GE( glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0,
GL_TEXTURE_WIDTH, &new_width) );
return new_width != 0;
}
void
cogl_texture_quad (gint x1,
gint x2,
gint y1,
gint y2,
ClutterFixed tx1,
ClutterFixed ty1,
ClutterFixed tx2,
ClutterFixed ty2)
{
gdouble txf1, tyf1, txf2, tyf2;
txf1 = CLUTTER_FIXED_TO_DOUBLE (tx1);
tyf1 = CLUTTER_FIXED_TO_DOUBLE (ty1);
txf2 = CLUTTER_FIXED_TO_DOUBLE (tx2);
tyf2 = CLUTTER_FIXED_TO_DOUBLE (ty2);
glBegin (GL_QUADS);
glTexCoord2f (txf2, tyf2); glVertex2i (x2, y2);
glTexCoord2f (txf1, tyf2); glVertex2i (x1, y2);
glTexCoord2f (txf1, tyf1); glVertex2i (x1, y1);
glTexCoord2f (txf2, tyf1); glVertex2i (x2, y1);
glEnd ();
}
void
cogl_textures_create (guint num, guint *textures)
{
GE( glGenTextures (num, textures) );
}
void
cogl_textures_destroy (guint num, const guint *textures)
{
GE( glDeleteTextures (num, textures) );
}
void
cogl_texture_bind (COGLenum target, guint texture)
{
GE( glBindTexture (target, texture) );
}
void
cogl_texture_set_alignment (COGLenum target,
guint alignment,
guint row_length)
{
GE( glPixelStorei (GL_UNPACK_ROW_LENGTH, row_length) );
GE( glPixelStorei (GL_UNPACK_ALIGNMENT, alignment) );
}
void
cogl_texture_set_filters (COGLenum target,
COGLenum min_filter,
COGLenum max_filter)
{
GE( glTexParameteri(target, GL_TEXTURE_MAG_FILTER, max_filter) );
GE( glTexParameteri(target, GL_TEXTURE_MIN_FILTER, min_filter) );
}
void
cogl_texture_set_wrap (COGLenum target,
COGLenum wrap_s,
COGLenum wrap_t)
{
GE( glTexParameteri(target, GL_TEXTURE_WRAP_S, wrap_s) );
GE( glTexParameteri(target, GL_TEXTURE_WRAP_T, wrap_s) );
}
void
cogl_texture_image_2d (COGLenum target,
COGLint internal_format,
gint width,
gint height,
COGLenum format,
COGLenum type,
const guchar* pixels)
{
GE( glTexImage2D (target,
0, /* No mipmap support as yet */
internal_format,
width,
height,
0, /* 0 pixel border */
format,
type,
pixels) );
}
void
cogl_texture_sub_image_2d (COGLenum target,
gint xoff,
gint yoff,
gint width,
gint height,
COGLenum format,
COGLenum type,
const guchar* pixels)
{
GE( glTexSubImage2D (target,
0,
xoff,
yoff,
width,
height,
format,
type,
pixels));
}
void
cogl_rectangle (gint x, gint y, guint width, guint height)
{
GE( glRecti (x,y ,width, height) );
}
/* FIXME: Should use ClutterReal or Fixed */
void
cogl_trapezoid (gint y1,
gint x11,
gint x21,
gint y2,
gint x12,
gint x22)
{
GE( glBegin (GL_QUADS) );
GE( glVertex2i (x11, y1) );
GE( glVertex2i (x21, y1) );
GE( glVertex2i (x22, y2) );
GE( glVertex2i (x12, y2) );
GE( glEnd () );
}
void
cogl_alpha_func (COGLenum func,
ClutterFixed ref)
{
GE( glAlphaFunc (func, CLUTTER_FIXED_TO_FLOAT(ref)) );
}
#if 0
/*
* Original floating point implementaiton of the perspective function,
* retained for reference purposes
*/
static inline void
frustum (GLfloat left,
GLfloat right,
GLfloat bottom,
GLfloat top,
GLfloat nearval,
GLfloat farval)
{
GLfloat x, y, a, b, c, d;
GLfloat m[16];
x = (2.0 * nearval) / (right - left);
y = (2.0 * nearval) / (top - bottom);
a = (right + left) / (right - left);
b = (top + bottom) / (top - bottom);
c = -(farval + nearval) / ( farval - nearval);
d = -(2.0 * farval * nearval) / (farval - nearval);
#define M(row,col) m[col*4+row]
M(0,0) = x; M(0,1) = 0.0F; M(0,2) = a; M(0,3) = 0.0F;
M(1,0) = 0.0F; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0F;
M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = c; M(2,3) = d;
M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = -1.0F; M(3,3) = 0.0F;
#undef M
GE( glMultMatrixf (m) );
}
static inline void
perspective (GLfloat fovy,
GLfloat aspect,
GLfloat zNear,
GLfloat zFar)
{
GLfloat xmin, xmax, ymin, ymax;
ymax = zNear * tan (fovy * M_PI / 360.0);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;
printf ("%f, %f, %f, %f\n", xmin, xmax, ymin, ymax);
frustum (xmin, xmax, ymin, ymax, zNear, zFar);
}
#endif
/*
* Fixed point implementation of the perspective function
*/
void
cogl_perspective (ClutterAngle fovy,
ClutterFixed aspect,
ClutterFixed zNear,
ClutterFixed zFar)
{
ClutterFixed xmax, ymax;
ClutterFixed x, y, c, d;
#ifdef HAVE_COGL_GL
GLfloat m[16];
#else
GLfixed m[16];
#endif
memset (&m[0], 0, sizeof (m));
/*
* Based on the original algorithm in perspective():
*
* 1) xmin = -xmax => xmax + xmin == 0 && xmax - xmin == 2 * xmax
* same true for y, hence: a == 0 && b == 0;
*
* 2) When working with small numbers, we can are loosing significant
* precision, hence we use clutter_qmulx() here, not the fast macro.
*/
ymax = clutter_qmulx (zNear, clutter_tani (fovy >> 1));
xmax = clutter_qmulx (ymax, aspect);
x = CFX_DIV (zNear, xmax);
y = CFX_DIV (zNear, ymax);
c = CFX_DIV (-(zFar + zNear), ( zFar - zNear));
d = CFX_DIV (-(clutter_qmulx (2*zFar, zNear)), (zFar - zNear));
#define M(row,col) m[col*4+row]
#ifdef HAVE_COGL_GL
M(0,0) = CLUTTER_FIXED_TO_FLOAT (x);
M(1,1) = CLUTTER_FIXED_TO_FLOAT (y);
M(2,2) = CLUTTER_FIXED_TO_FLOAT (c);
M(2,3) = CLUTTER_FIXED_TO_FLOAT (d);
M(3,2) = -1.0F;
GE( glMultMatrixf (m) );
#else
M(0,0) = x;
M(1,1) = y;
M(2,2) = c;
M(2,3) = d;
M(3,2) = 1 + ~CFX_ONE;
GE( glMultMatrixx (m) );
#endif
#undef M
}
void
cogl_setup_viewport (guint width,
guint height,
ClutterAngle fovy,
ClutterFixed aspect,
ClutterFixed z_near,
ClutterFixed z_far)
{
GE( glViewport (0, 0, width, height) );
GE( glMatrixMode (GL_PROJECTION) );
GE( glLoadIdentity () );
cogl_perspective (fovy, aspect, z_near, z_far);
GE( glMatrixMode (GL_MODELVIEW) );
GE( glLoadIdentity () );
/* camera distance from screen, 0.5 * tan (FOV) */
#define DEFAULT_Z_CAMERA 0.866025404f
GE( glTranslatef (-0.5f, -0.5f, -DEFAULT_Z_CAMERA) );
GE( glScalef ( 1.0f / width,
-1.0f / height,
1.0f / width) );
GE( glTranslatef (0.0f, -1.0 * height, 0.0f) );
}

View File

@ -1,5 +1,6 @@
libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/clutter
libclutterinclude_HEADERS = $(top_srcdir)/clutter/cogl/cogl.h
libclutterinclude_HEADERS = $(top_srcdir)/clutter/cogl/cogl.h \
$(top_srcdir)/clutter/cogl/gles/cogl-defines.h
INCLUDES = \
-I$(top_srcdir) \

View File

@ -0,0 +1,440 @@
/*
* Clutter COGL
*
* A basic GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
*
* 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_DEFINES_H__
#define __COGL_DEFINES_H__
G_BEGIN_DECLS
/* ClearBufferMask */
#define CGL_DEPTH_BUFFER_BIT GL_DEPTH_BUFFER_BIT
#define CGL_STENCIL_BUFFER_BIT GL_STENCIL_BUFFER_BIT
#define CGL_COLOR_BUFFER_BIT GL_COLOR_BUFFER_BIT
/* Boolean */
#define CGL_FALSE GL_FALSE
#define CGL_TRUE GL_TRUE
/* BeginMode */
#define CGL_POINTS GL_POINTS
#define CGL_LINES GL_LINES
#define CGL_LINE_LOOP GL_LINE_LOOP
#define CGL_LINE_STRIP GL_LINE_STRIP
#define CGL_TRIANGLES GL_TRIANGLES
#define CGL_TRIANGLE_STRIP GL_TRIANGLE_STRIP
#define CGL_TRIANGLE_FAN GL_TRIANGLE_FAN
/* AlphaFunction */
#define CGL_NEVER GL_NEVER
#define CGL_LESS GL_LESS
#define CGL_EQUAL GL_EQUAL
#define CGL_LEQUAL GL_LEQUAL
#define CGL_GREATER GL_GREATER
#define CGL_NOTEQUAL GL_NOTEQUAL
#define CGL_GEQUAL GL_GEQUAL
#define CGL_ALWAYS GL_ALWAYS
/* BlendingFactorDest */
#define CGL_ZERO GL_ZERO
#define CGL_ONE GL_ONE
#define CGL_SRC_COLOR GL_SRC_COLOR
#define CGL_ONE_MINUS_SRC_COLOR GL_ONE_MINUS_SRC_COLOR
#define CGL_SRC_ALPHA GL_SRC_ALPHA
#define CGL_ONE_MINUS_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
#define CGL_DST_ALPHA GL_DST_ALPHA
#define CGL_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_DST_ALPHA
/* BlendingFactorSrc */
#define CGL_DST_COLOR GL_DST_COLOR
#define CGL_ONE_MINUS_DST_COLOR GL_ONE_MINUS_DST_COLOR
#define CGL_SRC_ALPHA_SATURATE GL_SRC_ALPHA_SATURATE
/* Missing; */
/* GL_ZERO */
/* GL_ONE */
/* GL_SRC_ALPHA */
/* GL_ONE_MINUS_SRC_ALPHA */
/* GL_DST_ALPHA */
/* GL_ONE_MINUS_DST_ALPHA */
/* CullFaceMode */
#define CGL_FRONT GL_FRONT
#define CGL_BACK GL_BACK
#define CGL_FRONT_AND_BACK GL_FRONT_AND_BACK
/* EnableCap */
#define CGL_FOG GL_FOG
#define CGL_LIGHTING GL_LIGHTING
#define CGL_CULL_FACE GL_CULL_FACE
#define CGL_ALPHA_TEST GL_ALPHA_TEST
#define CGL_BLEND GL_BLEND
#define CGL_COLOR_LOGIC_OP GL_COLOR_LOGIC_OP
#define CGL_DITHER GL_DITHER
#define CGL_STENCIL_TEST GL_STENCIL_TEST
#define CGL_DEPTH_TEST GL_DEPTH_TEST
#define CGL_POINT_SMOOTH GL_POINT_SMOOTH
#define CGL_LINE_SMOOTH GL_LINE_SMOOTH
#define CGL_SCISSOR_TEST GL_SCISSOR_TEST
#define CGL_COLOR_MATERIAL GL_COLOR_MATERIAL
#define CGL_NORMALIZE GL_NORMALIZE
#define CGL_RESCALE_NORMAL GL_RESCALE_NORMAL
#define CGL_POLYGON_OFFSET_FILL GL_POLYGON_OFFSET_FILL
#define CGL_VERTEX_ARRAY GL_VERTEX_ARRAY
#define CGL_NORMAL_ARRAY GL_NORMAL_ARRAY
#define CGL_COLOR_ARRAY GL_COLOR_ARRAY
#define CGL_TEXTURE_COORD_ARRAY GL_TEXTURE_COORD_ARRAY
#define CGL_MULTISAMPLE GL_MULTISAMPLE
#define CGL_SAMPLE_ALPHA_TO_COVERAGE GL_SAMPLE_ALPHA_TO_COVERAGE
#define CGL_SAMPLE_ALPHA_TO_ONE GL_SAMPLE_ALPHA_TO_ONE
#define CGL_SAMPLE_COVERAGE GL_SAMPLE_COVERAGE
/* Errors */
#define CGL_NO_ERROR GL_NO_ERROR
#define CGL_INVALID_ENUM GL_INVALID_ENUM
#define CGL_INVALID_VALUE GL_INVALID_VALUE
#define CGL_INVALID_OPERATION GL_INVALID_OPERATION
#define CGL_STACK_OVERFLOW GL_STACK_OVERFLOW
#define CGL_STACK_UNDERFLOW GL_STACK_UNDERFLOW
#define CGL_OUT_OF_MEMORY GL_OUT_OF_MEMORY
/* Fog mode */
#define CGL_EXP GL_EXP
#define CGL_EXP2 GL_EXP2
#define CGL_FOG_DENSITY GL_FOG_DENSITY
/* FogParameter */
#define CGL_FOG_START GL_FOG_START
#define CGL_FOG_END GL_FOG_END
#define CGL_FOG_MODE GL_FOG_MODE
#define CGL_FOG_COLOR GL_FOG_COLOR
#define CGL_CW GL_CW
#define CGL_CCW GL_CCW
/* GetPName */
#define CGL_CURRENT_COLOR GL_CURRENT_COLOR
#define CGL_CURRENT_NORMAL GL_CURRENT_NORMAL
#define CGL_CURRENT_TEXTURE_COORDS GL_CURRENT_TEXTURE_COORDS
#define CGL_POINT_SIZE GL_POINT_SIZE
#define CGL_POINT_SIZE_MIN GL_POINT_SIZE_MIN
#define CGL_POINT_SIZE_MAX GL_POINT_SIZE_MAX
#define CGL_POINT_FADE_THRESHOLD_SIZE GL_POINT_FADE_THRESHOLD_SIZE
#define CGL_POINT_DISTANCE_ATTENUATION GL_POINT_DISTANCE_ATTENUATION
#define CGL_SMOOTH_POINT_SIZE_RANGE GL_SMOOTH_POINT_SIZE_RANGE
#define CGL_LINE_WIDTH GL_LINE_WIDTH
#define CGL_SMOOTH_LINE_WIDTH_RANGE GL_SMOOTH_LINE_WIDTH_RANGE
#define CGL_ALIASED_POINT_SIZE_RANGE GL_ALIASED_POINT_SIZE_RANGE
#define CGL_ALIASED_LINE_WIDTH_RANGE GL_ALIASED_LINE_WIDTH_RANGE
#define CGL_CULL_FACE_MODE GL_CULL_FACE_MODE
#define CGL_FRONT_FACE GL_FRONT_FACE
#define CGL_SHADE_MODEL GL_SHADE_MODEL
#define CGL_DEPTH_RANGE GL_DEPTH_RANGE
#define CGL_DEPTH_WRITEMASK GL_DEPTH_WRITEMASK
#define CGL_DEPTH_CLEAR_VALUE GL_DEPTH_CLEAR_VALUE
#define CGL_DEPTH_FUNC GL_DEPTH_FUNC
#define CGL_STENCIL_CLEAR_VALUE GL_STENCIL_CLEAR_VALUE
#define CGL_STENCIL_FUNC GL_STENCIL_FUNC
#define CGL_STENCIL_VALUE_MASK GL_STENCIL_VALUE_MASK
#define CGL_STENCIL_FAIL GL_STENCIL_FAIL
#define CGL_STENCIL_PASS_DEPTH_FAIL GL_STENCIL_PASS_DEPTH_FAIL
#define CGL_STENCIL_PASS_DEPTH_PASS GL_STENCIL_PASS_DEPTH_PASS
#define CGL_STENCIL_REF GL_STENCIL_REF
#define CGL_STENCIL_WRITEMASK GL_STENCIL_WRITEMASK
#define CGL_MATRIX_MODE GL_MATRIX_MODE
#define CGL_VIEWPORT GL_VIEWPORT
#define CGL_MODELVIEW_STACK_DEPTH GL_MODELVIEW_STACK_DEPTH
#define CGL_PROJECTION_STACK_DEPTH GL_PROJECTION_STACK_DEPTH
#define CGL_TEXTURE_STACK_DEPTH GL_TEXTURE_STACK_DEPTH
#define CGL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX
#define CGL_PROJECTION_MATRIX GL_PROJECTION_MATRIX
#define CGL_TEXTURE_MATRIX GL_TEXTURE_MATRIX
#define CGL_ALPHA_TEST_FUNC GL_ALPHA_TEST_FUNC
#define CGL_ALPHA_TEST_REF GL_ALPHA_TEST_REF
#define CGL_BLEND_DST GL_BLEND_DST
#define CGL_BLEND_SRC GL_BLEND_SRC
#define CGL_LOGIC_OP_MODE GL_LOGIC_OP_MODE
#define CGL_SCISSOR_BOX GL_SCISSOR_BOX
#define CGL_SCISSOR_TEST GL_SCISSOR_TEST
#define CGL_COLOR_CLEAR_VALUE GL_COLOR_CLEAR_VALUE
#define CGL_COLOR_WRITEMASK GL_COLOR_WRITEMASK
#define CGL_UNPACK_ALIGNMENT GL_UNPACK_ALIGNMENT
#define CGL_PACK_ALIGNMENT GL_PACK_ALIGNMENT
#define CGL_MAX_LIGHTS GL_MAX_LIGHTS
#define CGL_MAX_CLIP_PLANES GL_MAX_CLIP_PLANES
#define CGL_MAX_TEXTURE_SIZE GL_MAX_TEXTURE_SIZE
#define CGL_MAX_MODELVIEW_STACK_DEPTH GL_MAX_MODELVIEW_STACK_DEPTH
#define CGL_MAX_PROJECTION_STACK_DEPTH GL_MAX_PROJECTION_STACK_DEPTH
#define CGL_MAX_TEXTURE_STACK_DEPTH GL_MAX_TEXTURE_STACK_DEPTH
#define CGL_MAX_VIEWPORT_DIMS GL_MAX_VIEWPORT_DIMS
#define CGL_MAX_ELEMENTS_VERTICES GL_MAX_ELEMENTS_VERTICES
#define CGL_MAX_ELEMENTS_INDICES GL_MAX_ELEMENTS_INDICES
#define CGL_MAX_TEXTURE_UNITS GL_MAX_TEXTURE_UNITS
#define CGL_SUBPIXEL_BITS GL_SUBPIXEL_BITS
#define CGL_RED_BITS GL_RED_BITS
#define CGL_GREEN_BITS GL_GREEN_BITS
#define CGL_BLUE_BITS GL_BLUE_BITS
#define CGL_ALPHA_BITS GL_ALPHA_BITS
#define CGL_DEPTH_BITS GL_DEPTH_BITS
#define CGL_STENCIL_BITS GL_STENCIL_BITS
#define CGL_POLYGON_OFFSET_UNITS GL_POLYGON_OFFSET_UNITS
#define CGL_POLYGON_OFFSET_FILL GL_POLYGON_OFFSET_FILL
#define CGL_POLYGON_OFFSET_FACTOR GL_POLYGON_OFFSET_FACTOR
#define CGL_VERTEX_ARRAY_SIZE GL_VERTEX_ARRAY_SIZE
#define CGL_VERTEX_ARRAY_TYPE GL_VERTEX_ARRAY_TYPE
#define CGL_VERTEX_ARRAY_STRIDE GL_VERTEX_ARRAY_STRIDE
#define CGL_NORMAL_ARRAY_TYPE GL_NORMAL_ARRAY_TYPE
#define CGL_NORMAL_ARRAY_STRIDE GL_NORMAL_ARRAY_STRIDE
#define CGL_COLOR_ARRAY_SIZE GL_COLOR_ARRAY_SIZE
#define CGL_COLOR_ARRAY_TYPE GL_COLOR_ARRAY_TYPE
#define CGL_COLOR_ARRAY_STRIDE GL_COLOR_ARRAY_STRIDE
#define CGL_TEXTURE_COORD_ARRAY_SIZE GL_TEXTURE_COORD_ARRAY_SIZE
#define CGL_TEXTURE_COORD_ARRAY_TYPE GL_TEXTURE_COORD_ARRAY_TYPE
#define CGL_TEXTURE_COORD_ARRAY_STRIDE GL_TEXTURE_COORD_ARRAY_STRIDE
#define CGL_VERTEX_ARRAY_POINTER GL_VERTEX_ARRAY_POINTER
#define CGL_NORMAL_ARRAY_POINTER GL_NORMAL_ARRAY_POINTER
#define CGL_COLOR_ARRAY_POINTER GL_COLOR_ARRAY_POINTER
#define CGL_TEXTURE_COORD_ARRAY_POINTER GL_TEXTURE_COORD_ARRAY_POINTER
#define CGL_SAMPLE_BUFFERS GL_SAMPLE_BUFFERS
#define CGL_SAMPLES GL_SAMPLES
#define CGL_SAMPLE_COVERAGE_VALUE GL_SAMPLE_COVERAGE_VALUE
#define CGL_SAMPLE_COVERAGE_INVERT GL_SAMPLE_COVERAGE_INVERT
/* GetTextureParameter - missing */
/* GL_TEXTURE_MAG_FILTER */
/* GL_TEXTURE_MIN_FILTER */
/* GL_TEXTURE_WRAP_S */
/* GL_TEXTURE_WRAP_T */
#define CGL_IMPLEMENTATION_COLOR_READ_TYPE_OES GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
#define CGL_IMPLEMENTATION_COLOR_READ_FORMAT_OES GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
#define CGL_NUM_COMPRESSED_TEXTURE_FORMATS GL_NUM_COMPRESSED_TEXTURE_FORMATS
#define CGL_COMPRESSED_TEXTURE_FORMATS GL_COMPRESSED_TEXTURE_FORMATS
/* OES_matrix_get */
#define CGL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS
#define CGL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS
#define CGL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS
/* HintMode */
#define CGL_DONT_CARE GL_DONT_CARE
#define CGL_FASTEST GL_FASTEST
#define CGL_NICEST GL_NICEST
/* HintTarget */
#define CGL_PERSPECTIVE_CORRECTION_HINT GL_PERSPECTIVE_CORRECTION_HINT
#define CGL_POINT_SMOOTH_HINT GL_POINT_SMOOTH_HINT
#define CGL_LINE_SMOOTH_HINT GL_LINE_SMOOTH_HINT
#define CGL_POLYGON_SMOOTH_HINT GL_POLYGON_SMOOTH_HINT
#define CGL_FOG_HINT GL_FOG_HINT
#define CGL_GENERATE_MIPMAP_HINT GL_GENERATE_MIPMAP_HINT
/* LightModelParameter */
#define CGL_LIGHT_MODEL_AMBIENT GL_LIGHT_MODEL_AMBIENT
#define CGL_LIGHT_MODEL_TWO_SIDE GL_LIGHT_MODEL_TWO_SIDE
/* LightParameter */
#define CGL_AMBIENT GL_AMBIENT
#define CGL_DIFFUSE GL_DIFFUSE
#define CGL_SPECULAR GL_SPECULAR
#define CGL_POSITION GL_POSITION
#define CGL_SPOT_DIRECTION GL_SPOT_DIRECTION
#define CGL_SPOT_EXPONENT GL_SPOT_EXPONENT
#define CGL_SPOT_CUTOFF GL_SPOT_CUTOFF
#define CGL_CONSTANT_ATTENUATION GL_CONSTANT_ATTENUATION
#define CGL_LINEAR_ATTENUATION GL_LINEAR_ATTENUATION
#define CGL_QUADRATIC_ATTENUATION GL_QUADRATIC_ATTENUATION
/* DataType */
#define CGL_BYTE GL_BYTE
#define CGL_UNSIGNED_BYTE GL_UNSIGNED_BYTE
#define CGL_SHORT GL_SHORT
#define CGL_UNSIGNED_SHORT GL_UNSIGNED_SHORT
#define CGL_FLOAT GL_FLOAT
#define CGL_FIXED GL_FIXED
/* LogicOp */
#define CGL_CLEAR GL_CLEAR
#define CGL_AND GL_AND
#define CGL_AND_REVERSE GL_AND_REVERSE
#define CGL_COPY GL_COPY
#define CGL_AND_INVERTED GL_AND_INVERTED
#define CGL_NOOP GL_NOOP
#define CGL_XOR GL_XOR
#define CGL_OR GL_OR
#define CGL_NOR GL_NOR
#define CGL_EQUIV GL_EQUIV
#define CGL_INVERT GL_INVERT
#define CGL_OR_REVERSE GL_OR_REVERSE
#define CGL_COPY_INVERTED GL_COPY_INVERTED
#define CGL_OR_INVERTED GL_OR_INVERTED
#define CGL_NAND GL_NAND
#define CGL_SET GL_SET
/* MaterialParameter */
#define CGL_EMISSION GL_EMISSION
#define CGL_SHININESS GL_SHININESS
#define CGL_AMBIENT_AND_DIFFUSE GL_AMBIENT_AND_DIFFUSE
/* MatrixMode */
#define CGL_MODELVIEW GL_MODELVIEW
#define CGL_PROJECTION GL_PROJECTION
#define CGL_TEXTURE GL_TEXTURE
/* PixelFormat */
#define CGL_ALPHA GL_ALPHA
#define CGL_RGB GL_RGB
#define CGL_RGBA GL_RGBA
#define CGL_LUMINANCE GL_LUMINANCE
#define CGL_LUMINANCE_ALPHA GL_LUMINANCE_ALPHA
/* PixelStoreParameter */
#define CGL_UNPACK_ALIGNMENT GL_UNPACK_ALIGNMENT
#define CGL_PACK_ALIGNMENT GL_PACK_ALIGNMENT
/* PixelType */
/* GL_UNSIGNED_BYTE */
#define CGL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4
#define CGL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_5_5_5_1
#define CGL_UNSIGNED_SHORT_5_6_5 CGL_UNSIGNED_SHORT_5_6_5
/* ShadingModel */
#define CGL_FLAT GL_FLAT
#define CGL_SMOOTH GL_SMOOTH
/* StencilFunction */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* StencilOp */
#define CGL_KEEP GL_KEEP
#define CGL_REPLACE GL_REPLACE
#define CGL_INCR GL_INCR
#define CGL_DECR GL_DECR
/* StringName */
#define CGL_VENDOR GL_VENDOR
#define CGL_RENDERER GL_RENDERER
#define CGL_VERSION GL_VERSION
#define CGL_EXTENSIONS GL_EXTENSIONS
/* TextureEnvMode */
#define CGL_MODULATE GL_MODULATE
#define CGL_DECAL GL_DECAL
#define CGL_ADD GL_ADD
/* GL_BLEND */
/* GL_REPLACE */
/* TextureEnvParameter */
#define CGL_TEXTURE_ENV_MODE GL_TEXTURE_ENV_MODE
#define CGL_TEXTURE_ENV_COLOR GL_TEXTURE_ENV_COLOR
/* TextureEnvTarget */
#define CGL_TEXTURE_ENV GL_TEXTURE_ENV
/* TextureMagFilter */
#define CGL_NEAREST GL_NEAREST
#define CGL_LINEAR GL_LINEAR
/* TextureMinFilter */
/* GL_NEAREST */
/* GL_LINEAR */
#define CGL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_NEAREST
#define CGL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_NEAREST
#define CGL_NEAREST_MIPMAP_LINEAR GL_NEAREST_MIPMAP_LINEAR
#define CGL_LINEAR_MIPMAP_LINEAR GL_LINEAR_MIPMAP_LINEAR
/* TextureParameterName */
#define CGL_TEXTURE_MAG_FILTER GL_TEXTURE_MAG_FILTER
#define CGL_TEXTURE_MIN_FILTER GL_TEXTURE_MIN_FILTER
#define CGL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_S
#define CGL_TEXTURE_WRAP_T GL_TEXTURE_WRAP_T
#define CGL_GENERATE_MIPMAP GL_GENERATE_MIPMAP
#define CGL_ACTIVE_TEXTURE GL_ACTIVE_TEXTURE
#define CGL_CLIENT_ACTIVE_TEXTURE GL_CLIENT_ACTIVE_TEXTURE
/* TextureWrapMode */
#define CGL_REPEAT GL_REPEAT
#define CGL_CLAMP_TO_EDGE GL_CLAMP_TO_EDGE
/* PixelInternalFormat */
/* Buffer Objects */
#define CGL_ARRAY_BUFFER GL_ARRAY_BUFFER
#define CGL_ELEMENT_ARRAY_BUFFER GL_ELEMENT_ARRAY_BUFFER
#define CGL_ARRAY_BUFFER_BINDING GL_ARRAY_BUFFER_BINDING
#define CGL_ELEMENT_ARRAY_BUFFER_BINDING GL_ELEMENT_ARRAY_BUFFER_BINDING
#define CGL_VERTEX_ARRAY_BUFFER_BINDING GL_VERTEX_ARRAY_BUFFER_BINDING
#define CGL_NORMAL_ARRAY_BUFFER_BINDING GL_NORMAL_ARRAY_BUFFER_BINDING
#define CGL_COLOR_ARRAY_BUFFER_BINDING GL_COLOR_ARRAY_BUFFER_BINDING
#define CGL_TEXTURE_COORD_ARRAY_BUFFER_BINDING GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING
#define CGL_STATIC_DRAW GL_STATIC_DRAW
#define CGL_DYNAMIC_DRAW GL_DYNAMIC_DRAW
#define CGL_WRITE_ONLY GL_WRITE_ONLY
#define CGL_BUFFER_SIZE GL_BUFFER_SIZE
#define CGL_BUFFER_USAGE GL_BUFFER_USAGE
#define CGL_BUFFER_ACCESS GL_BUFFER_ACCESS
#define CGL_SUBTRACT GL_SUBTRACT
#define CGL_COMBINE GL_COMBINE
#define CGL_COMBINE_RGB GL_COMBINE_RGB
#define CGL_COMBINE_ALPHA GL_COMBINE_ALPHA
#define CGL_RGB_SCALE GL_RGB_SCALE
#define CGL_ADD_SIGNED GL_ADD_SIGNED
#define CGL_INTERPOLATE GL_INTERPOLATE
#define CGL_CONSTANT GL_CONSTANT
#define CGL_PRIMARY_COLOR GL_PRIMARY_COLOR
#define CGL_PREVIOUS GL_PREVIOUS
#define CGL_ALPHA_SCALE GL_ALPHA_SCALE
#define CGL_POINT_SPRITE_OES GL_POINT_SPRITE_OES
#define CGL_COORD_REPLACE_OES GL_COORD_REPLACE_OES
#define CGL_POINT_SIZE_ARRAY_OES GL_POINT_SIZE_ARRAY_OES
#define CGL_POINT_SIZE_ARRAY_TYPE_OES GL_POINT_SIZE_ARRAY_TYPE_OES
#define CGL_POINT_SIZE_ARRAY_STRIDE_OES GL_POINT_SIZE_ARRAY_STRIDE_OES
#define CGL_POINT_SIZE_ARRAY_POINTER_OES GL_POINT_SIZE_ARRAY_POINTER_OES
#define CGL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
#define CGL_MAX_VERTEX_UNITS_OES GL_MAX_VERTEX_UNITS_OES
#define CGL_MAX_PALETTE_MATRICES_OES GL_MAX_PALETTE_MATRICES_OES
#define CGL_MATRIX_PALETTE_OES GL_MATRIX_PALETTE_OES
#define CGL_MATRIX_INDEX_ARRAY_OES GL_MATRIX_INDEX_ARRAY_OES
#define CGL_WEIGHT_ARRAY_OES GL_WEIGHT_ARRAY_OES
#define CGL_MATRIX_INDEX_ARRAY_SIZE_OES GL_MATRIX_INDEX_ARRAY_SIZE_OES
#define CGL_MATRIX_INDEX_ARRAY_TYPE_OES GL_MATRIX_INDEX_ARRAY_TYPE_OES
#define CGL_MATRIX_INDEX_ARRAY_STRIDE_OES GL_MATRIX_INDEX_ARRAY_STRIDE_OES
#define CGL_MATRIX_INDEX_ARRAY_POINTER_OES GL_MATRIX_INDEX_ARRAY_POINTER_OES
#define CGL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES
#define CGL_WEIGHT_ARRAY_SIZE_OES GL_WEIGHT_ARRAY_SIZE_OES
#define CGL_WEIGHT_ARRAY_TYPE_OES GL_WEIGHT_ARRAY_TYPE_OES
#define CGL_WEIGHT_ARRAY_STRIDE_OES GL_WEIGHT_ARRAY_STRIDE_OES
#define CGL_WEIGHT_ARRAY_POINTER_OES GL_WEIGHT_ARRAY_POINTER_OES
#define CGL_WEIGHT_ARRAY_BUFFER_BINDING_OES GL_WEIGHT_ARRAY_BUFFER_BINDING_OES
#define CGL_TEXTURE_CROP_RECT_OES GL_TEXTURE_CROP_RECT_OES
G_END_DECLS
#endif

View File

@ -26,6 +26,54 @@
#include "cogl.h"
#include <GLES/gl.h>
#if COGL_DEBUG
struct token_string
{
GLuint Token;
const char *String;
};
static const struct token_string Errors[] = {
{ GL_NO_ERROR, "no error" },
{ GL_INVALID_ENUM, "invalid enumerant" },
{ GL_INVALID_VALUE, "invalid value" },
{ GL_INVALID_OPERATION, "invalid operation" },
{ GL_STACK_OVERFLOW, "stack overflow" },
{ GL_STACK_UNDERFLOW, "stack underflow" },
{ GL_OUT_OF_MEMORY, "out of memory" },
#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT
{ GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" },
#endif
{ ~0, NULL }
};
static const char*
error_string(GLenum errorCode)
{
int i;
for (i = 0; Errors[i].String; i++) {
if (Errors[i].Token == errorCode)
return Errors[i].String;
}
return "unknown";
}
#endif
#if COGL_DEBUG
#define GE(x...) { \
GLenum err; \
(x); \
while ((err = glGetError()) != GL_NO_ERROR) { \
fprintf(stderr, "glError: %s caught at %s:%u\n", \
(char *)error_string(err), \
__FILE__, __LINE__); \
} \
}
#else
#define GE(x) (x);
#endif
CoglFuncPtr
cogl_get_proc_address (const gchar* name)
{
@ -67,21 +115,21 @@ cogl_pop_matrix (void)
void
cogl_scaled (ClutterFixed x, ClutterFixed y)
{
glScalex (x, y, CFX_ONE);
GE( glScalex (x, y, CFX_ONE) );
}
void
cogl_translatex (ClutterFixed x, ClutterFixed y, ClutterFixed z)
{
glTranslatex (x, y, z);
GE( glTranslatex (x, y, z) );
}
void
cogl_translate (gint x, gint y, gint z)
{
glTranslatex (CLUTTER_INT_TO_FIXED(x),
CLUTTER_INT_TO_FIXED(y),
CLUTTER_INT_TO_FIXED(z));
GE( glTranslatex (CLUTTER_INT_TO_FIXED(x),
CLUTTER_INT_TO_FIXED(y),
CLUTTER_INT_TO_FIXED(z)) );
}
void
@ -90,14 +138,14 @@ cogl_rotatex (ClutterFixed angle,
ClutterFixed y,
ClutterFixed z)
{
glRotatex (angle,x,y,z);
GE( glRotatex (angle,x,y,z) );
}
void
cogl_rotate (gint angle, gint x, gint y, gint z)
{
glRotatef (CLUTTER_INT_TO_FIXED(angle),
CLUTTER_INT_TO_FIXED(x),
CLUTTER_INT_TO_FIXED(y),
CLUTTER_INT_TO_FIXED(z));
GE( glRotatef (CLUTTER_INT_TO_FIXED(angle),
CLUTTER_INT_TO_FIXED(x),
CLUTTER_INT_TO_FIXED(y),
CLUTTER_INT_TO_FIXED(z)) );
}

View File

@ -4,6 +4,8 @@ libclutterinclude_HEADERS = clutter-glx.h
INCLUDES = \
-DG_LOG_DOMAIN=\"ClutterGLX\" \
-I$(top_srcdir) \
-I$(top_srcdir)/clutter/cogl \
-I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@ \
$(CLUTTER_CFLAGS) \
$(CLUTTER_DEBUG_CFLAGS) \
$(GCC_FLAGS)

View File

@ -36,6 +36,8 @@
#include "../clutter-private.h"
#include "../clutter-debug.h"
#include "cogl.h"
#ifdef HAVE_XFIXES
#include <X11/extensions/Xfixes.h>
#endif
@ -319,14 +321,7 @@ clutter_stage_glx_paint (ClutterActor *self)
clutter_stage_get_color (stage, &stage_color);
/* FIXME: move below into cogl_paint_start() ? */
glClearColor (((float) stage_color.red / 0xff * 1.0),
((float) stage_color.green / 0xff * 1.0),
((float) stage_color.blue / 0xff * 1.0),
0.0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glDisable (GL_LIGHTING);
glDisable (GL_DEPTH_TEST);
cogl_paint_init (&stage_color);
/* chain up to reach ClutterGroup->paint here */
CLUTTER_ACTOR_CLASS (clutter_stage_glx_parent_class)->paint (self);

View File

@ -12,7 +12,10 @@ libpangoclutter_la_SOURCES = $(source_c) \
$(source_h) \
$(source_h_priv)
INCLUDES = @GCC_FLAGS@ @CLUTTER_CFLAGS@ -I$(top_srcdir)
INCLUDES = @GCC_FLAGS@ @CLUTTER_CFLAGS@ \
-I$(top_srcdir) \
-I$(top_srcdir)/clutter/cogl \
-I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@
pangoclutterheadersdir = $(includedir)/clutter-@CLUTTER_MAJORMINOR@/clutter
pangoclutterheaders_HEADERS = $(source_h)

View File

@ -26,13 +26,14 @@
#include "config.h"
#endif
#include <GL/gl.h>
#include <math.h>
#include "pangoclutter.h"
#include "pangoclutter-private.h"
#include "../clutter-debug.h"
#include "cogl.h"
/*
* Texture cache support code
*/
@ -42,18 +43,18 @@
#define TC_ROUND 4
typedef struct {
GLuint name;
guint name;
int x, y, w, h;
} tc_area;
typedef struct tc_texture {
struct tc_texture *next;
GLuint name;
guint name;
int avail;
} tc_texture;
typedef struct tc_slice {
GLuint name;
guint name;
int avail, y;
} tc_slice;
@ -72,7 +73,7 @@ tc_clear ()
while (first_texture)
{
tc_texture *next = first_texture->next;
glDeleteTextures (1, &first_texture->name);
cogl_textures_destroy (1, &first_texture->name);
g_slice_free (tc_texture, first_texture);
first_texture = next;
}
@ -111,14 +112,21 @@ tc_get (tc_area *area, int width, int height)
match = g_slice_new (tc_texture);
match->next = first_texture;
first_texture = match;
glGenTextures (1, &match->name);
match->avail = TC_HEIGHT;
glBindTexture (GL_TEXTURE_2D, match->name);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA,
TC_WIDTH, TC_HEIGHT, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0);
cogl_textures_create (1, &match->name);
cogl_texture_bind (CGL_TEXTURE_2D, match->name);
cogl_texture_set_filters (CGL_TEXTURE_2D, CGL_NEAREST, CGL_NEAREST);
cogl_texture_image_2d (CGL_TEXTURE_2D,
CGL_ALPHA,
TC_WIDTH,
TC_HEIGHT,
CGL_ALPHA,
CGL_UNSIGNED_BYTE,
NULL);
}
match->avail -= slice_height;
@ -166,7 +174,7 @@ struct _PangoClutterRenderer
PangoRenderer parent_instance;
ClutterColor color;
int flags;
GLuint curtex; /* current texture */
guint curtex; /* current texture */
};
G_DEFINE_TYPE (PangoClutterRenderer, \
@ -341,20 +349,19 @@ draw_glyph (PangoRenderer *renderer_,
CLUTTER_NOTE (PANGO, g_message ("cache fail; subimage2d %i\n", glyph));
glBindTexture (GL_TEXTURE_2D, g->tex.name);
glPixelStorei (GL_UNPACK_ROW_LENGTH, bm.stride);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glTexSubImage2D (GL_TEXTURE_2D,
0,
g->tex.x,
g->tex.y,
bm.width,
bm.height,
GL_ALPHA,
GL_UNSIGNED_BYTE,
bm.bitmap);
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
cogl_texture_bind (CGL_TEXTURE_2D, g->tex.name);
cogl_texture_set_alignment (CGL_TEXTURE_2D, 1, bm.stride);
cogl_texture_sub_image_2d (CGL_TEXTURE_2D,
g->tex.x,
g->tex.y,
bm.width,
bm.height,
CGL_ALPHA,
CGL_UNSIGNED_BYTE,
bm.bitmap);
renderer->curtex = g->tex.name;
glBegin (GL_QUADS);
@ -371,19 +378,25 @@ draw_glyph (PangoRenderer *renderer_,
if (g->tex.name != renderer->curtex)
{
if (renderer->curtex)
glEnd ();
/*
if (renderer->curtex)
glEnd ();
*/
glBindTexture (GL_TEXTURE_2D, g->tex.name);
cogl_texture_bind (CGL_TEXTURE_2D, g->tex.name);
renderer->curtex = g->tex.name;
glBegin (GL_QUADS);
/* glBegin (GL_QUADS); */
}
glTexCoord2f (x1, y1); glVertex2i (x , y );
glTexCoord2f (x2, y1); glVertex2i (x + g->tex.w, y );
glTexCoord2f (x2, y2); glVertex2i (x + g->tex.w, y + g->tex.h);
glTexCoord2f (x1, y2); glVertex2i (x , y + g->tex.h);
cogl_texture_quad (x,
x + g->tex.w,
y,
y + g->tex.h,
CLUTTER_FLOAT_TO_FIXED(x1),
CLUTTER_FLOAT_TO_FIXED(y1),
CLUTTER_FLOAT_TO_FIXED(x2),
CLUTTER_FLOAT_TO_FIXED(y2));
}
static void
@ -400,20 +413,22 @@ draw_trapezoid (PangoRenderer *renderer_,
if (renderer->curtex)
{
glEnd ();
/* glEnd (); */
renderer->curtex = 0;
}
glDisable (GL_TEXTURE_2D);
/* Turn texturing off */
cogl_enable (CGL_ENABLE_BLEND);
glBegin (GL_QUADS);
glVertex2d (x11, y1);
glVertex2d (x21, y1);
glVertex2d (x22, y2);
glVertex2d (x12, y2);
glEnd ();
cogl_trapezoid ((gint) y1,
(gint) x11,
(gint) x21,
(gint) y2,
(gint) x12,
(gint) x22);
glEnable (GL_TEXTURE_2D);
/* Turn it back on again */
cogl_enable (CGL_ENABLE_TEXTURE_2D|CGL_ENABLE_BLEND);
}
void
@ -491,7 +506,7 @@ prepare_run (PangoRenderer *renderer, PangoLayoutRun *run)
PangoClutterRenderer *glrenderer = (PangoClutterRenderer *)renderer;
PangoColor *fg = 0;
GSList *l;
unsigned char r, g, b, a;
ClutterColor col;
renderer->underline = PANGO_UNDERLINE_NONE;
renderer->strikethrough = FALSE;
@ -520,27 +535,27 @@ prepare_run (PangoRenderer *renderer, PangoLayoutRun *run)
if (fg)
{
r = fg->red * (255.f / 65535.f);
g = fg->green * (255.f / 65535.f);
b = fg->blue * (255.f / 65535.f);
col.red = (fg->red * 255) / 65535;
col.green = (fg->green * 255) / 65535;
col.blue = (fg->blue * 255) / 65535;
}
else
{
r = glrenderer->color.red;
g = glrenderer->color.green;
b = glrenderer->color.blue;
col.red = glrenderer->color.red;
col.green = glrenderer->color.green;
col.blue = glrenderer->color.blue;
}
a = glrenderer->color.alpha;
col.alpha = glrenderer->color.alpha;
if (glrenderer->flags & FLAG_INVERSE)
{
r ^= 0xffU;
g ^= 0xffU;
b ^= 0xffU;
col.red ^= 0xffU;
col.green ^= 0xffU;
col.blue ^= 0xffU;
}
glColor4ub (r, g, b, a);
cogl_color(&col);
}
static void
@ -550,32 +565,30 @@ draw_begin (PangoRenderer *renderer_)
renderer->curtex = 0;
glEnable (GL_TEXTURE_2D);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable (GL_BLEND);
cogl_enable (CGL_ENABLE_TEXTURE_2D
|CGL_ENABLE_BLEND);
#if 0
/* How to handle in ES ? */
gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
GL_ONE , GL_ONE_MINUS_SRC_ALPHA);
#endif
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable (GL_ALPHA_TEST);
glAlphaFunc (GL_GREATER, 0.01f);
#endif
}
static void
draw_end (PangoRenderer *renderer_)
{
/*
PangoClutterRenderer *renderer = (PangoClutterRenderer *)renderer_;
if (renderer->curtex)
glEnd ();
glDisable (GL_ALPHA_TEST);
glDisable (GL_BLEND);
glDisable (GL_TEXTURE_2D);
*/
}
static void

View File

@ -106,9 +106,11 @@ case $clutterbackend in
glx)
CLUTTER_FLAVOUR="glx"
CLUTTER_COGL="gl"
AC_DEFINE([HAVE_CLUTTER_GLX], 1, [Have the GLX backend])
CLUTTER_COGL="gl"
AC_DEFINE([HAVE_COGL_GL], 1, [Have GL for rendering])
AC_CHECK_HEADERS([GL/gl.h GL/glx.h],,
[AC_MSG_ERROR([Unable to locate required GL headers])])
@ -125,9 +127,12 @@ case $clutterbackend in
egl)
CLUTTER_FLAVOUR="egl"
CLUTTER_GOGL="gles"
AC_DEFINE([HAVE_CLUTTER_EGL], 1, [Have the EGL backend])
# We currently assume having egl means also having gles..
CLUTTER_GOGL="gles"
AC_DEFINE([HAVE_COGL_GLES], 1, [Have GL/ES for rendering])
PKG_CHECK_MODULES(EGL, libvincent, HAVE_OGLES=yes, HAVE_OGLES=no)
if test "x$HAVE_OGLES" = "xno"; then
AC_MSG_ERROR([libvincent (ogles) not found and egl backend requested.]);