4
* An object oriented GL/GLES Abstraction/Utility Layer
6
* Copyright (C) 2007,2008,2009 Intel Corporation.
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library; if not, write to the
20
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21
* Boston, MA 02111-1307, USA.
24
#ifndef __COGL_CONTEXT_H
25
#define __COGL_CONTEXT_H
27
#include "cogl-primitives.h"
28
#include "cogl-clip-stack.h"
29
#include "cogl-matrix-stack.h"
30
#include "cogl-current-matrix.h"
31
#include "cogl-material-private.h"
38
} CoglTextureGLVertex;
42
CoglBufferTarget target;
44
} CoglDrawBufferState;
49
CoglFeatureFlags feature_flags;
50
gboolean features_cached;
56
gboolean enable_backface_culling;
60
/* Client-side matrix stack or NULL if none */
61
CoglMatrixMode matrix_mode;
62
CoglMatrixStack *modelview_stack;
63
CoglMatrixStack *projection_stack;
65
/* Cache of inverse projection matrix */
66
float inverse_projection[16];
69
CoglHandle default_material;
70
CoglHandle source_material;
73
CoglHandle default_gl_texture_2d_tex;
74
CoglHandle default_gl_texture_rect_tex;
77
/* Batching geometry... */
78
/* We journal the texture rectangles we want to submit to OpenGL so
79
* we have an oppertunity to optimise the final order so that we
80
* can batch things together. */
82
GArray *logged_vertices;
84
/* Some simple caching, to minimize state changes... */
85
CoglHandle current_material;
86
gulong current_material_flags;
87
CoglMaterialFlushOptions current_material_flush_options;
88
GArray *current_layers;
89
guint n_texcoord_arrays_enabled;
91
/* Framebuffer objects */
92
GSList *draw_buffer_stack;
95
CoglClipStackState clip;
102
floatVec2 path_nodes_min;
103
floatVec2 path_nodes_max;
104
CoglHandle stencil_material;
106
/* Pre-generated VBOs containing indices to generate GL_TRIANGLES
107
out of a vertex array of quads */
108
CoglHandle quad_indices_byte;
109
guint quad_indices_short_len;
110
CoglHandle quad_indices_short;
112
gboolean in_begin_gl_block;
114
guint viewport_width;
115
guint viewport_height;
117
/* Relying on glext.h to define these */
118
COGL_PFNGLGENRENDERBUFFERSEXTPROC pf_glGenRenderbuffersEXT;
119
COGL_PFNGLDELETERENDERBUFFERSEXTPROC pf_glDeleteRenderbuffersEXT;
120
COGL_PFNGLBINDRENDERBUFFEREXTPROC pf_glBindRenderbufferEXT;
121
COGL_PFNGLRENDERBUFFERSTORAGEEXTPROC pf_glRenderbufferStorageEXT;
122
COGL_PFNGLGENFRAMEBUFFERSEXTPROC pf_glGenFramebuffersEXT;
123
COGL_PFNGLBINDFRAMEBUFFEREXTPROC pf_glBindFramebufferEXT;
124
COGL_PFNGLFRAMEBUFFERTEXTURE2DEXTPROC pf_glFramebufferTexture2DEXT;
125
COGL_PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC pf_glFramebufferRenderbufferEXT;
126
COGL_PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC pf_glCheckFramebufferStatusEXT;
127
COGL_PFNGLDELETEFRAMEBUFFERSEXTPROC pf_glDeleteFramebuffersEXT;
128
COGL_PFNGLBLITFRAMEBUFFEREXTPROC pf_glBlitFramebufferEXT;
129
COGL_PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC pf_glRenderbufferStorageMultisampleEXT;
130
COGL_PFNGLGENERATEMIPMAPEXTPROC pf_glGenerateMipmapEXT;
132
COGL_PFNGLCREATEPROGRAMOBJECTARBPROC pf_glCreateProgramObjectARB;
133
COGL_PFNGLCREATESHADEROBJECTARBPROC pf_glCreateShaderObjectARB;
134
COGL_PFNGLSHADERSOURCEARBPROC pf_glShaderSourceARB;
135
COGL_PFNGLCOMPILESHADERARBPROC pf_glCompileShaderARB;
136
COGL_PFNGLATTACHOBJECTARBPROC pf_glAttachObjectARB;
137
COGL_PFNGLLINKPROGRAMARBPROC pf_glLinkProgramARB;
138
COGL_PFNGLUSEPROGRAMOBJECTARBPROC pf_glUseProgramObjectARB;
139
COGL_PFNGLGETUNIFORMLOCATIONARBPROC pf_glGetUniformLocationARB;
140
COGL_PFNGLDELETEOBJECTARBPROC pf_glDeleteObjectARB;
141
COGL_PFNGLGETINFOLOGARBPROC pf_glGetInfoLogARB;
142
COGL_PFNGLGETOBJECTPARAMETERIVARBPROC pf_glGetObjectParameterivARB;
144
COGL_PFNGLVERTEXATTRIBPOINTERARBPROC pf_glVertexAttribPointerARB;
145
COGL_PFNGLENABLEVERTEXATTRIBARRAYARBPROC pf_glEnableVertexAttribArrayARB;
146
COGL_PFNGLDISABLEVERTEXATTRIBARRAYARBPROC pf_glDisableVertexAttribArrayARB;
148
COGL_PFNGLGENBUFFERSARBPROC pf_glGenBuffersARB;
149
COGL_PFNGLBINDBUFFERARBPROC pf_glBindBufferARB;
150
COGL_PFNGLBUFFERDATAARBPROC pf_glBufferDataARB;
151
COGL_PFNGLBUFFERSUBDATAARBPROC pf_glBufferSubDataARB;
152
COGL_PFNGLMAPBUFFERARBPROC pf_glMapBufferARB;
153
COGL_PFNGLUNMAPBUFFERARBPROC pf_glUnmapBufferARB;
154
COGL_PFNGLDELETEBUFFERSARBPROC pf_glDeleteBuffersARB;
156
COGL_PFNGLUNIFORM1FARBPROC pf_glUniform1fARB;
157
COGL_PFNGLUNIFORM2FARBPROC pf_glUniform2fARB;
158
COGL_PFNGLUNIFORM3FARBPROC pf_glUniform3fARB;
159
COGL_PFNGLUNIFORM4FARBPROC pf_glUniform4fARB;
160
COGL_PFNGLUNIFORM1FVARBPROC pf_glUniform1fvARB;
161
COGL_PFNGLUNIFORM2FVARBPROC pf_glUniform2fvARB;
162
COGL_PFNGLUNIFORM3FVARBPROC pf_glUniform3fvARB;
163
COGL_PFNGLUNIFORM4FVARBPROC pf_glUniform4fvARB;
164
COGL_PFNGLUNIFORM1IARBPROC pf_glUniform1iARB;
165
COGL_PFNGLUNIFORM2IARBPROC pf_glUniform2iARB;
166
COGL_PFNGLUNIFORM3IARBPROC pf_glUniform3iARB;
167
COGL_PFNGLUNIFORM4IARBPROC pf_glUniform4iARB;
168
COGL_PFNGLUNIFORM1IVARBPROC pf_glUniform1ivARB;
169
COGL_PFNGLUNIFORM2IVARBPROC pf_glUniform2ivARB;
170
COGL_PFNGLUNIFORM3IVARBPROC pf_glUniform3ivARB;
171
COGL_PFNGLUNIFORM4IVARBPROC pf_glUniform4ivARB;
172
COGL_PFNGLUNIFORMMATRIX2FVARBPROC pf_glUniformMatrix2fvARB;
173
COGL_PFNGLUNIFORMMATRIX3FVARBPROC pf_glUniformMatrix3fvARB;
174
COGL_PFNGLUNIFORMMATRIX4FVARBPROC pf_glUniformMatrix4fvARB;
176
COGL_PFNGLDRAWRANGEELEMENTSPROC pf_glDrawRangeElements;
178
COGL_PFNGLACTIVETEXTUREPROC pf_glActiveTexture;
179
COGL_PFNGLCLIENTACTIVETEXTUREPROC pf_glClientActiveTexture;
181
COGL_PFNGLBLENDEQUATIONPROC pf_glBlendEquation;
182
COGL_PFNGLBLENDCOLORPROC pf_glBlendColor;
183
COGL_PFNGLBLENDFUNCSEPARATEPROC pf_glBlendFuncSeparate;
184
COGL_PFNGLBLENDEQUATIONSEPARATEPROC pf_glBlendEquationSeparate;
188
_cogl_context_get_default ();
190
/* Obtains the context and returns retval if NULL */
191
#define _COGL_GET_CONTEXT(ctxvar, retval) \
192
CoglContext *ctxvar = _cogl_context_get_default (); \
193
if (ctxvar == NULL) return retval;
197
#endif /* __COGL_CONTEXT_H */