2008-04-25 09:37:36 -04:00
|
|
|
/*
|
|
|
|
* 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_CONTEXT_H
|
|
|
|
#define __COGL_CONTEXT_H
|
|
|
|
|
|
|
|
#include "cogl-primitives.h"
|
2008-12-04 08:45:09 -05:00
|
|
|
#include "cogl-clip-stack.h"
|
2008-04-25 09:37:36 -04:00
|
|
|
|
2008-11-18 11:24:09 -05:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GLfloat v[3];
|
|
|
|
GLfloat t[2];
|
|
|
|
GLubyte c[4];
|
|
|
|
} CoglTextureGLVertex;
|
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* Features cache */
|
|
|
|
CoglFeatureFlags feature_flags;
|
|
|
|
gboolean features_cached;
|
2008-12-23 11:29:29 -05:00
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
/* Enable cache */
|
|
|
|
gulong enable_flags;
|
|
|
|
guint8 color_alpha;
|
2008-05-19 11:02:27 -04:00
|
|
|
COGLenum blend_src_factor;
|
|
|
|
COGLenum blend_dst_factor;
|
2008-10-27 10:36:52 -04:00
|
|
|
|
|
|
|
gboolean enable_backface_culling;
|
2008-12-23 11:29:29 -05:00
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
/* Primitives */
|
2009-01-20 11:20:54 -05:00
|
|
|
floatVec2 path_start;
|
|
|
|
floatVec2 path_pen;
|
2008-12-04 08:45:09 -05:00
|
|
|
GArray *path_nodes;
|
|
|
|
guint last_path;
|
2009-01-20 11:20:54 -05:00
|
|
|
floatVec2 path_nodes_min;
|
|
|
|
floatVec2 path_nodes_max;
|
2008-06-02 08:34:10 -04:00
|
|
|
|
|
|
|
/* Cache of inverse projection matrix */
|
|
|
|
GLfloat inverse_projection[16];
|
2008-12-23 11:29:29 -05:00
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
/* Textures */
|
2008-11-18 11:24:09 -05:00
|
|
|
GArray *texture_handles;
|
2008-11-27 11:44:39 -05:00
|
|
|
GArray *texture_vertices;
|
2008-12-09 08:02:28 -05:00
|
|
|
GArray *texture_indices;
|
2008-11-28 07:33:19 -05:00
|
|
|
/* The gl texture number that the above vertices apply to. This to
|
|
|
|
detect when a different slice is encountered so that the vertices
|
|
|
|
can be flushed */
|
|
|
|
GLuint texture_current;
|
|
|
|
GLenum texture_target;
|
2008-12-04 13:08:40 -05:00
|
|
|
GLenum texture_wrap_mode;
|
2008-12-23 11:29:29 -05:00
|
|
|
|
Adds a CoglMaterial abstraction, which includes support for multi-texturing
My previous work to provide muti-texturing support has been extended into
a CoglMaterial abstraction that adds control over the texture combine
functions (controlling how multiple texture layers are blended together),
the gl blend function (used for blending the final primitive with the
framebuffer), the alpha function (used to discard fragments based on
their alpha channel), describing attributes such as a diffuse, ambient and
specular color (for use with the standard OpenGL lighting model), and
per layer rotations. (utilizing the new CoglMatrix utility API)
For now the only way this abstraction is exposed is via a new
cogl_material_rectangle function, that is similar to cogl_texture_rectangle
but doesn't take a texture handle (the source material is pulled from
the context), and the array of texture coordinates is extended to be able
to supply coordinates for each layer.
Note: this function doesn't support sliced textures; supporting sliced
textures is a non trivial problem, considering the ability to rotate layers.
Note: cogl_material_rectangle, has quite a few workarounds, for a number of
other limitations within Cogl a.t.m.
Note: The GLES1/2 multi-texturing support has yet to be updated to use
the material abstraction.
2008-12-11 15:11:30 -05:00
|
|
|
/* Materials */
|
|
|
|
GArray *material_handles;
|
|
|
|
GArray *material_layer_handles;
|
|
|
|
CoglHandle source_material;
|
2008-12-23 18:22:40 -05:00
|
|
|
CoglHandle current_material;
|
2008-12-11 10:33:38 -05:00
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
/* Framebuffer objects */
|
|
|
|
GArray *fbo_handles;
|
|
|
|
CoglBufferTarget draw_buffer;
|
2008-04-29 12:10:37 -04:00
|
|
|
|
|
|
|
/* Shaders */
|
|
|
|
GArray *shader_handles;
|
|
|
|
|
|
|
|
/* Programs */
|
|
|
|
GArray *program_handles;
|
2008-12-04 08:45:09 -05:00
|
|
|
|
|
|
|
/* Clip stack */
|
|
|
|
CoglClipStackState clip;
|
2008-12-23 11:29:29 -05:00
|
|
|
|
2009-01-20 16:12:44 -05:00
|
|
|
/* Vertex buffers */
|
|
|
|
GArray *vertex_buffer_handles;
|
2008-12-23 11:29:29 -05:00
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
/* Relying on glext.h to define these */
|
2008-05-12 13:20:22 -04:00
|
|
|
COGL_PFNGLGENRENDERBUFFERSEXTPROC pf_glGenRenderbuffersEXT;
|
2008-08-01 08:23:57 -04:00
|
|
|
COGL_PFNGLDELETERENDERBUFFERSEXTPROC pf_glDeleteRenderbuffersEXT;
|
2008-05-12 13:20:22 -04:00
|
|
|
COGL_PFNGLBINDRENDERBUFFEREXTPROC pf_glBindRenderbufferEXT;
|
|
|
|
COGL_PFNGLRENDERBUFFERSTORAGEEXTPROC pf_glRenderbufferStorageEXT;
|
|
|
|
COGL_PFNGLGENFRAMEBUFFERSEXTPROC pf_glGenFramebuffersEXT;
|
|
|
|
COGL_PFNGLBINDFRAMEBUFFEREXTPROC pf_glBindFramebufferEXT;
|
|
|
|
COGL_PFNGLFRAMEBUFFERTEXTURE2DEXTPROC pf_glFramebufferTexture2DEXT;
|
|
|
|
COGL_PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC pf_glFramebufferRenderbufferEXT;
|
|
|
|
COGL_PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC pf_glCheckFramebufferStatusEXT;
|
|
|
|
COGL_PFNGLDELETEFRAMEBUFFERSEXTPROC pf_glDeleteFramebuffersEXT;
|
|
|
|
COGL_PFNGLBLITFRAMEBUFFEREXTPROC pf_glBlitFramebufferEXT;
|
|
|
|
COGL_PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC pf_glRenderbufferStorageMultisampleEXT;
|
2008-12-23 11:29:29 -05:00
|
|
|
|
2008-05-12 13:20:22 -04:00
|
|
|
COGL_PFNGLCREATEPROGRAMOBJECTARBPROC pf_glCreateProgramObjectARB;
|
|
|
|
COGL_PFNGLCREATESHADEROBJECTARBPROC pf_glCreateShaderObjectARB;
|
|
|
|
COGL_PFNGLSHADERSOURCEARBPROC pf_glShaderSourceARB;
|
|
|
|
COGL_PFNGLCOMPILESHADERARBPROC pf_glCompileShaderARB;
|
|
|
|
COGL_PFNGLATTACHOBJECTARBPROC pf_glAttachObjectARB;
|
|
|
|
COGL_PFNGLLINKPROGRAMARBPROC pf_glLinkProgramARB;
|
|
|
|
COGL_PFNGLUSEPROGRAMOBJECTARBPROC pf_glUseProgramObjectARB;
|
|
|
|
COGL_PFNGLGETUNIFORMLOCATIONARBPROC pf_glGetUniformLocationARB;
|
|
|
|
COGL_PFNGLDELETEOBJECTARBPROC pf_glDeleteObjectARB;
|
|
|
|
COGL_PFNGLGETINFOLOGARBPROC pf_glGetInfoLogARB;
|
|
|
|
COGL_PFNGLGETOBJECTPARAMETERIVARBPROC pf_glGetObjectParameterivARB;
|
2008-11-18 10:08:40 -05:00
|
|
|
|
2008-11-10 13:53:14 -05:00
|
|
|
COGL_PFNGLVERTEXATTRIBPOINTERARBPROC pf_glVertexAttribPointerARB;
|
|
|
|
COGL_PFNGLENABLEVERTEXATTRIBARRAYARBPROC pf_glEnableVertexAttribArrayARB;
|
|
|
|
COGL_PFNGLDISABLEVERTEXATTRIBARRAYARBPROC pf_glDisableVertexAttribArrayARB;
|
|
|
|
|
|
|
|
COGL_PFNGLGENBUFFERSARBPROC pf_glGenBuffersARB;
|
|
|
|
COGL_PFNGLBINDBUFFERARBPROC pf_glBindBufferARB;
|
|
|
|
COGL_PFNGLBUFFERDATAARBPROC pf_glBufferDataARB;
|
2008-12-10 07:13:20 -05:00
|
|
|
COGL_PFNGLBUFFERSUBDATAARBPROC pf_glBufferSubDataARB;
|
2008-11-10 13:53:14 -05:00
|
|
|
COGL_PFNGLMAPBUFFERARBPROC pf_glMapBufferARB;
|
|
|
|
COGL_PFNGLUNMAPBUFFERARBPROC pf_glUnmapBufferARB;
|
|
|
|
COGL_PFNGLDELETEBUFFERSARBPROC pf_glDeleteBuffersARB;
|
|
|
|
|
2008-11-18 10:08:40 -05:00
|
|
|
COGL_PFNGLUNIFORM1FARBPROC pf_glUniform1fARB;
|
|
|
|
COGL_PFNGLUNIFORM2FARBPROC pf_glUniform2fARB;
|
|
|
|
COGL_PFNGLUNIFORM3FARBPROC pf_glUniform3fARB;
|
|
|
|
COGL_PFNGLUNIFORM4FARBPROC pf_glUniform4fARB;
|
|
|
|
COGL_PFNGLUNIFORM1FVARBPROC pf_glUniform1fvARB;
|
|
|
|
COGL_PFNGLUNIFORM2FVARBPROC pf_glUniform2fvARB;
|
|
|
|
COGL_PFNGLUNIFORM3FVARBPROC pf_glUniform3fvARB;
|
|
|
|
COGL_PFNGLUNIFORM4FVARBPROC pf_glUniform4fvARB;
|
|
|
|
COGL_PFNGLUNIFORM1IARBPROC pf_glUniform1iARB;
|
|
|
|
COGL_PFNGLUNIFORM2IARBPROC pf_glUniform2iARB;
|
|
|
|
COGL_PFNGLUNIFORM3IARBPROC pf_glUniform3iARB;
|
|
|
|
COGL_PFNGLUNIFORM4IARBPROC pf_glUniform4iARB;
|
|
|
|
COGL_PFNGLUNIFORM1IVARBPROC pf_glUniform1ivARB;
|
|
|
|
COGL_PFNGLUNIFORM2IVARBPROC pf_glUniform2ivARB;
|
|
|
|
COGL_PFNGLUNIFORM3IVARBPROC pf_glUniform3ivARB;
|
|
|
|
COGL_PFNGLUNIFORM4IVARBPROC pf_glUniform4ivARB;
|
|
|
|
COGL_PFNGLUNIFORMMATRIX2FVARBPROC pf_glUniformMatrix2fvARB;
|
|
|
|
COGL_PFNGLUNIFORMMATRIX3FVARBPROC pf_glUniformMatrix3fvARB;
|
|
|
|
COGL_PFNGLUNIFORMMATRIX4FVARBPROC pf_glUniformMatrix4fvARB;
|
2008-11-21 11:18:58 -05:00
|
|
|
|
|
|
|
COGL_PFNGLDRAWRANGEELEMENTSPROC pf_glDrawRangeElements;
|
2008-04-25 09:37:36 -04:00
|
|
|
} CoglContext;
|
|
|
|
|
|
|
|
CoglContext *
|
|
|
|
_cogl_context_get_default ();
|
|
|
|
|
|
|
|
/* Obtains the context and returns retval if NULL */
|
|
|
|
#define _COGL_GET_CONTEXT(ctxvar, retval) \
|
|
|
|
CoglContext *ctxvar = _cogl_context_get_default (); \
|
|
|
|
if (ctxvar == NULL) return retval;
|
|
|
|
|
2008-12-23 11:29:29 -05:00
|
|
|
#define NO_RETVAL
|
2008-04-25 09:37:36 -04:00
|
|
|
|
|
|
|
#endif /* __COGL_CONTEXT_H */
|