~ubuntu-branches/ubuntu/precise/clutter-1.0/precise

« back to all changes in this revision

Viewing changes to clutter/cogl/gl/cogl-context.h

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2010-03-21 13:27:56 UTC
  • mto: (2.1.3 experimental) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100321132756-nf8yd30yxo3zzwcm
Tags: upstream-1.2.2
ImportĀ upstreamĀ versionĀ 1.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Cogl
3
 
 *
4
 
 * An object oriented GL/GLES Abstraction/Utility Layer
5
 
 *
6
 
 * Copyright (C) 2007,2008,2009 Intel Corporation.
7
 
 *
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.
12
 
 *
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.
17
 
 *
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.
22
 
 */
23
 
 
24
 
#ifndef __COGL_CONTEXT_H
25
 
#define __COGL_CONTEXT_H
26
 
 
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"
32
 
 
33
 
typedef struct
34
 
{
35
 
  GLfloat v[3];
36
 
  GLfloat t[2];
37
 
  GLubyte c[4];
38
 
} CoglTextureGLVertex;
39
 
 
40
 
typedef struct
41
 
{
42
 
  CoglBufferTarget target;
43
 
  CoglHandle offscreen;
44
 
} CoglDrawBufferState;
45
 
 
46
 
typedef struct
47
 
{
48
 
  /* Features cache */
49
 
  CoglFeatureFlags  feature_flags;
50
 
  gboolean          features_cached;
51
 
 
52
 
  /* Enable cache */
53
 
  gulong            enable_flags;
54
 
  guint8            color_alpha;
55
 
 
56
 
  gboolean          enable_backface_culling;
57
 
 
58
 
  gboolean          indirect;
59
 
 
60
 
  /* Client-side matrix stack or NULL if none */
61
 
  CoglMatrixMode    matrix_mode;
62
 
  CoglMatrixStack  *modelview_stack;
63
 
  CoglMatrixStack  *projection_stack;
64
 
 
65
 
  /* Cache of inverse projection matrix */
66
 
  float            inverse_projection[16];
67
 
 
68
 
  /* Materials */
69
 
  CoglHandle        default_material;
70
 
  CoglHandle        source_material;
71
 
 
72
 
  /* Textures */
73
 
  CoglHandle        default_gl_texture_2d_tex;
74
 
  CoglHandle        default_gl_texture_rect_tex;
75
 
 
76
 
 
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. */
81
 
  GArray           *journal;
82
 
  GArray           *logged_vertices;
83
 
 
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;
90
 
 
91
 
  /* Framebuffer objects */
92
 
  GSList           *draw_buffer_stack;
93
 
 
94
 
  /* Clip stack */
95
 
  CoglClipStackState clip;
96
 
 
97
 
  /* Primitives */
98
 
  floatVec2         path_start;
99
 
  floatVec2         path_pen;
100
 
  GArray           *path_nodes;
101
 
  guint             last_path;
102
 
  floatVec2         path_nodes_min;
103
 
  floatVec2         path_nodes_max;
104
 
  CoglHandle        stencil_material;
105
 
 
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;
111
 
 
112
 
  gboolean          in_begin_gl_block;
113
 
 
114
 
  guint             viewport_width;
115
 
  guint             viewport_height;
116
 
 
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;
131
 
 
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;
143
 
 
144
 
  COGL_PFNGLVERTEXATTRIBPOINTERARBPROC             pf_glVertexAttribPointerARB;
145
 
  COGL_PFNGLENABLEVERTEXATTRIBARRAYARBPROC         pf_glEnableVertexAttribArrayARB;
146
 
  COGL_PFNGLDISABLEVERTEXATTRIBARRAYARBPROC        pf_glDisableVertexAttribArrayARB;
147
 
 
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;
155
 
 
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;
175
 
 
176
 
  COGL_PFNGLDRAWRANGEELEMENTSPROC                  pf_glDrawRangeElements;
177
 
 
178
 
  COGL_PFNGLACTIVETEXTUREPROC                      pf_glActiveTexture;
179
 
  COGL_PFNGLCLIENTACTIVETEXTUREPROC                pf_glClientActiveTexture;
180
 
 
181
 
  COGL_PFNGLBLENDEQUATIONPROC                      pf_glBlendEquation;
182
 
  COGL_PFNGLBLENDCOLORPROC                         pf_glBlendColor;
183
 
  COGL_PFNGLBLENDFUNCSEPARATEPROC                  pf_glBlendFuncSeparate;
184
 
  COGL_PFNGLBLENDEQUATIONSEPARATEPROC              pf_glBlendEquationSeparate;
185
 
} CoglContext;
186
 
 
187
 
CoglContext *
188
 
_cogl_context_get_default ();
189
 
 
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;
194
 
 
195
 
#define NO_RETVAL
196
 
 
197
 
#endif /* __COGL_CONTEXT_H */