~oem-solutions-group/unity-2d/clutter-1.0

« back to all changes in this revision

Viewing changes to clutter/cogl/cogl/cogl-types.h

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2010-03-21 13:27:56 UTC
  • mto: (2.1.3 experimental)
  • 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) 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, see <http://www.gnu.org/licenses/>.
 
20
 *
 
21
 *
 
22
 */
 
23
 
 
24
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
 
25
#error "Only <cogl/cogl.h> can be included directly."
 
26
#endif
 
27
 
 
28
#ifndef __COGL_TYPES_H__
 
29
#define __COGL_TYPES_H__
 
30
 
 
31
#include <glib-object.h>
 
32
 
 
33
G_BEGIN_DECLS
 
34
 
 
35
/**
 
36
 * CoglHandle:
 
37
 *
 
38
 * Type used for storing references to cogl objects, the CoglHandle is
 
39
 * a fully opaque type without any public data members.
 
40
 */
 
41
typedef gpointer CoglHandle;
 
42
 
 
43
/**
 
44
 * COGL_INVALID_HANDLE:
 
45
 *
 
46
 * A COGL handle that is not valid, used for unitialized handles as well as
 
47
 * error conditions.
 
48
 */
 
49
#define COGL_INVALID_HANDLE NULL
 
50
 
 
51
#define COGL_TYPE_HANDLE        (cogl_handle_get_type ())
 
52
GType
 
53
cogl_handle_get_type (void) G_GNUC_CONST;
 
54
 
 
55
/**
 
56
 * cogl_handle_ref:
 
57
 * @handle: a #CoglHandle
 
58
 *
 
59
 * Increases the reference count of @handle by 1
 
60
 *
 
61
 * Returns: the handle, with its reference count increased
 
62
 */
 
63
CoglHandle
 
64
cogl_handle_ref (CoglHandle handle);
 
65
 
 
66
/**
 
67
 * cogl_handle_unref:
 
68
 * @handle: a #CoglHandle
 
69
 *
 
70
 * Drecreases the reference count of @handle by 1; if the reference
 
71
 * count reaches 0, the resources allocated by @handle will be freed
 
72
 */
 
73
void
 
74
cogl_handle_unref (CoglHandle Handle);
 
75
 
 
76
/**
 
77
 * CoglFuncPtr:
 
78
 *
 
79
 * The type used by cogl for function pointers, note that this type
 
80
 * is used as a generic catch-all cast for function pointers and the
 
81
 * actual arguments and return type may be different.
 
82
 */
 
83
typedef void (* CoglFuncPtr) (void);
 
84
 
 
85
/**
 
86
 * CoglFixed:
 
87
 *
 
88
 * Fixed point number using a (16.16) notation.
 
89
 */
 
90
typedef gint32 CoglFixed;
 
91
 
 
92
#define COGL_TYPE_FIXED         (cogl_fixed_get_type ())
 
93
GType
 
94
cogl_fixed_get_type (void) G_GNUC_CONST;
 
95
 
 
96
/**
 
97
 * CoglAngle:
 
98
 *
 
99
 * Integer representation of an angle such that 1024 corresponds to
 
100
 * full circle (i.e., 2 * pi).
 
101
 *
 
102
 * Since: 1.0
 
103
 */
 
104
typedef gint32 CoglAngle;
 
105
 
 
106
typedef struct _CoglColor               CoglColor;
 
107
typedef struct _CoglTextureVertex       CoglTextureVertex;
 
108
 
 
109
/* Enum declarations */
 
110
 
 
111
#define COGL_PIXEL_FORMAT_24    2
 
112
#define COGL_PIXEL_FORMAT_32    3
 
113
#define COGL_A_BIT              (1 << 4)
 
114
#define COGL_BGR_BIT            (1 << 5)
 
115
#define COGL_AFIRST_BIT         (1 << 6)
 
116
#define COGL_PREMULT_BIT        (1 << 7)
 
117
#define COGL_UNORDERED_MASK     0x0F
 
118
#define COGL_UNPREMULT_MASK     0x7F
 
119
 
 
120
/**
 
121
 * CoglPixelFormat:
 
122
 * @COGL_PIXEL_FORMAT_ANY: Any format
 
123
 * @COGL_PIXEL_FORMAT_A_8: 8 bits alpha mask
 
124
 * @COGL_PIXEL_FORMAT_RGB_565: RGB, 16 bits
 
125
 * @COGL_PIXEL_FORMAT_RGBA_4444: RGBA, 16 bits
 
126
 * @COGL_PIXEL_FORMAT_RGBA_5551: RGBA, 16 bits
 
127
 * @COGL_PIXEL_FORMAT_YUV: Not currently supported
 
128
 * @COGL_PIXEL_FORMAT_G_8: Single luminance component
 
129
 * @COGL_PIXEL_FORMAT_RGB_888: RGB, 24 bits
 
130
 * @COGL_PIXEL_FORMAT_BGR_888: BGR, 24 bits
 
131
 * @COGL_PIXEL_FORMAT_RGBA_8888: RGBA, 32 bits
 
132
 * @COGL_PIXEL_FORMAT_BGRA_8888: BGRA, 32 bits
 
133
 * @COGL_PIXEL_FORMAT_ARGB_8888: ARGB, 32 bits
 
134
 * @COGL_PIXEL_FORMAT_ABGR_8888: ABGR, 32 bits
 
135
 * @COGL_PIXEL_FORMAT_RGBA_8888_PRE: Premultiplied RGBA, 32 bits
 
136
 * @COGL_PIXEL_FORMAT_BGRA_8888_PRE: Premultiplied BGRA, 32 bits
 
137
 * @COGL_PIXEL_FORMAT_ARGB_8888_PRE: Premultiplied ARGB, 32 bits
 
138
 * @COGL_PIXEL_FORMAT_ABGR_8888_PRE: Premultiplied ABGR, 32 bits
 
139
 * @COGL_PIXEL_FORMAT_RGBA_4444_PRE: Premultiplied RGBA, 16 bits
 
140
 * @COGL_PIXEL_FORMAT_RGBA_5551_PRE: Premultiplied RGBA, 16 bits
 
141
 *
 
142
 * Pixel formats used by COGL. For the formats with a byte per
 
143
 * component, the order of the components specify the order in
 
144
 * increasing memory addresses. So for example
 
145
 * %COGL_PIXEL_FORMAT_RGB_888 would have the red component in the
 
146
 * lowest address, green in the next address and blue after that
 
147
 * regardless of the endinanness of the system.
 
148
 *
 
149
 * For the 16-bit formats the component order specifies the order
 
150
 * within a 16-bit number from most significant bit to least
 
151
 * significant. So for %COGL_PIXEL_FORMAT_RGB_565, the red component
 
152
 * would be in bits 11-15, the green component would be in 6-11 and
 
153
 * the blue component would be in 1-5. Therefore the order in memory
 
154
 * depends on the endianness of the system.
 
155
 *
 
156
 * When uploading a texture %COGL_PIXEL_FORMAT_ANY can be used as the
 
157
 * internal format. Cogl will try to pick the best format to use
 
158
 * internally and convert the texture data if necessary.
 
159
 *
 
160
 * Since: 0.8
 
161
 */
 
162
typedef enum { /*< prefix=COGL_PIXEL_FORMAT >*/
 
163
  COGL_PIXEL_FORMAT_ANY           = 0,
 
164
  COGL_PIXEL_FORMAT_A_8           = 1 | COGL_A_BIT,
 
165
 
 
166
  COGL_PIXEL_FORMAT_RGB_565       = 4,
 
167
  COGL_PIXEL_FORMAT_RGBA_4444     = 5 | COGL_A_BIT,
 
168
  COGL_PIXEL_FORMAT_RGBA_5551     = 6 | COGL_A_BIT,
 
169
  COGL_PIXEL_FORMAT_YUV           = 7,
 
170
  COGL_PIXEL_FORMAT_G_8           = 8,
 
171
 
 
172
  COGL_PIXEL_FORMAT_RGB_888       =  COGL_PIXEL_FORMAT_24,
 
173
  COGL_PIXEL_FORMAT_BGR_888       = (COGL_PIXEL_FORMAT_24 | COGL_BGR_BIT),
 
174
 
 
175
  COGL_PIXEL_FORMAT_RGBA_8888     = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT),
 
176
  COGL_PIXEL_FORMAT_BGRA_8888     = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_BGR_BIT),
 
177
  COGL_PIXEL_FORMAT_ARGB_8888     = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_AFIRST_BIT),
 
178
  COGL_PIXEL_FORMAT_ABGR_8888     = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
 
179
 
 
180
  COGL_PIXEL_FORMAT_RGBA_8888_PRE = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_PREMULT_BIT),
 
181
  COGL_PIXEL_FORMAT_BGRA_8888_PRE = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT),
 
182
  COGL_PIXEL_FORMAT_ARGB_8888_PRE = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_AFIRST_BIT),
 
183
  COGL_PIXEL_FORMAT_ABGR_8888_PRE = (COGL_PIXEL_FORMAT_32 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
 
184
  COGL_PIXEL_FORMAT_RGBA_4444_PRE = (COGL_PIXEL_FORMAT_RGBA_4444 | COGL_A_BIT | COGL_PREMULT_BIT),
 
185
  COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 | COGL_A_BIT | COGL_PREMULT_BIT),
 
186
} CoglPixelFormat;
 
187
 
 
188
/**
 
189
 * CoglFeatureFlags:
 
190
 * @COGL_FEATURE_TEXTURE_RECTANGLE: ARB_texture_rectangle support
 
191
 * @COGL_FEATURE_TEXTURE_NPOT: ARB_texture_non_power_of_two support
 
192
 * @COGL_FEATURE_TEXTURE_YUV: ycbcr conversion support
 
193
 * @COGL_FEATURE_TEXTURE_READ_PIXELS: glReadPixels() support
 
194
 * @COGL_FEATURE_SHADERS_GLSL: GLSL support
 
195
 * @COGL_FEATURE_OFFSCREEN: FBO support
 
196
 * @COGL_FEATURE_OFFSCREEN_MULTISAMPLE: Multisample support on FBOs
 
197
 * @COGL_FEATURE_OFFSCREEN_BLIT: Blit support on FBOs
 
198
 * @COGL_FEATURE_FOUR_CLIP_PLANES: At least 4 clip planes available
 
199
 * @COGL_FEATURE_STENCIL_BUFFER: Stencil buffer support
 
200
 * @COGL_FEATURE_VBOS: VBO support
 
201
 * @COGL_FEATURE_PBOS: PBO support
 
202
 * @COGL_FEATURE_UNSIGNED_INT_INDICES: Set if
 
203
 *     %COGL_INDICES_TYPE_UNSIGNED_INT is supported in
 
204
 *     cogl_vertex_buffer_indices_new().
 
205
 *
 
206
 * Flags for the supported features.
 
207
 *
 
208
 * Since: 0.8
 
209
 */
 
210
typedef enum
 
211
{
 
212
  COGL_FEATURE_TEXTURE_RECTANGLE      = (1 << 1),
 
213
  COGL_FEATURE_TEXTURE_NPOT           = (1 << 2),
 
214
  COGL_FEATURE_TEXTURE_YUV            = (1 << 3),
 
215
  COGL_FEATURE_TEXTURE_READ_PIXELS    = (1 << 4),
 
216
  COGL_FEATURE_SHADERS_GLSL           = (1 << 5),
 
217
  COGL_FEATURE_OFFSCREEN              = (1 << 6),
 
218
  COGL_FEATURE_OFFSCREEN_MULTISAMPLE  = (1 << 7),
 
219
  COGL_FEATURE_OFFSCREEN_BLIT         = (1 << 8),
 
220
  COGL_FEATURE_FOUR_CLIP_PLANES       = (1 << 9),
 
221
  COGL_FEATURE_STENCIL_BUFFER         = (1 << 10),
 
222
  COGL_FEATURE_VBOS                   = (1 << 11),
 
223
  COGL_FEATURE_PBOS                   = (1 << 12),
 
224
  COGL_FEATURE_UNSIGNED_INT_INDICES   = (1 << 13)
 
225
} CoglFeatureFlags;
 
226
 
 
227
/**
 
228
 * CoglBufferTarget:
 
229
 * @COGL_WINDOW_BUFFER: FIXME
 
230
 * @COGL_OFFSCREEN_BUFFER: FIXME
 
231
 *
 
232
 * Target flags for FBOs.
 
233
 *
 
234
 * Since: 0.8
 
235
 */
 
236
typedef enum
 
237
{
 
238
  COGL_WINDOW_BUFFER      = (1 << 1),
 
239
  COGL_OFFSCREEN_BUFFER   = (1 << 2)
 
240
} CoglBufferTarget;
 
241
 
 
242
/**
 
243
 * CoglColor:
 
244
 *
 
245
 * A structure for holding a color definition. The contents of
 
246
 * the CoglColor structure are private and should never by accessed
 
247
 * directly.
 
248
 *
 
249
 * Since: 1.0
 
250
 */
 
251
struct _CoglColor
 
252
{
 
253
  /*< private >*/
 
254
  guint8 red;
 
255
  guint8 green;
 
256
  guint8 blue;
 
257
 
 
258
  guint8 alpha;
 
259
 
 
260
  /* padding in case we want to change to floats at
 
261
   * some point */
 
262
  guint32 padding0;
 
263
  guint32 padding1;
 
264
  guint32 padding2;
 
265
};
 
266
 
 
267
/**
 
268
 * CoglTextureVertex:
 
269
 * @x: Model x-coordinate
 
270
 * @y: Model y-coordinate
 
271
 * @z: Model z-coordinate
 
272
 * @tx: Texture x-coordinate
 
273
 * @ty: Texture y-coordinate
 
274
 * @color: The color to use at this vertex. This is ignored if
 
275
 *   use_color is %FALSE when calling cogl_polygon()
 
276
 *
 
277
 * Used to specify vertex information when calling cogl_polygon()
 
278
 */
 
279
struct _CoglTextureVertex
 
280
{
 
281
  float x, y, z;
 
282
  float tx, ty;
 
283
 
 
284
  CoglColor color;
 
285
};
 
286
 
 
287
/**
 
288
 * CoglTextureFlags:
 
289
 * @COGL_TEXTURE_NONE: No flags specified
 
290
 * @COGL_TEXTURE_NO_AUTO_MIPMAP: Disables the automatic generation of
 
291
 *   the mipmap pyramid from the base level image whenever it is
 
292
 *   updated. The mipmaps are only generated when the texture is
 
293
 *   rendered with a mipmap filter so it should be free to leave out
 
294
 *   this flag when using other filtering modes
 
295
 * @COGL_TEXTURE_NO_SLICING: Disables the slicing of the texture
 
296
 * @COGL_TEXTURE_NO_ATLAS: Disables the insertion of the texture inside
 
297
 *   the texture atlas used by Cogl
 
298
 *
 
299
 * Flags to pass to the cogl_texture_new_* family of functions.
 
300
 *
 
301
 * Since: 1.0
 
302
 */
 
303
typedef enum {
 
304
  COGL_TEXTURE_NONE           = 0,
 
305
  COGL_TEXTURE_NO_AUTO_MIPMAP = 1 << 0,
 
306
  COGL_TEXTURE_NO_SLICING     = 1 << 1,
 
307
  COGL_TEXTURE_NO_ATLAS       = 1 << 2
 
308
} CoglTextureFlags;
 
309
 
 
310
/**
 
311
 * CoglFogMode:
 
312
 * @COGL_FOG_MODE_LINEAR: Calculates the fog blend factor as:
 
313
 * |[
 
314
 *   f = end - eye_distance / end - start
 
315
 * ]|
 
316
 * @COGL_FOG_MODE_EXPONENTIAL: Calculates the fog blend factor as:
 
317
 * |[
 
318
 *   f = e ^ -(density * eye_distance)
 
319
 * ]|
 
320
 * @COGL_FOG_MODE_EXPONENTIAL_SQUARED: Calculates the fog blend factor as:
 
321
 * |[
 
322
 *   f = e ^ -(density * eye_distance)^2
 
323
 * ]|
 
324
 *
 
325
 * The fog mode determines the equation used to calculate the fogging blend
 
326
 * factor while fogging is enabled. The simplest %COGL_FOG_MODE_LINEAR mode
 
327
 * determines f as:
 
328
 *
 
329
 * |[
 
330
 *   f = end - eye_distance / end - start
 
331
 * ]|
 
332
 *
 
333
 * Where eye_distance is the distance of the current fragment in eye
 
334
 * coordinates from the origin.
 
335
 *
 
336
 * Since: 1.0
 
337
 */
 
338
typedef enum {
 
339
  COGL_FOG_MODE_LINEAR,
 
340
  COGL_FOG_MODE_EXPONENTIAL,
 
341
  COGL_FOG_MODE_EXPONENTIAL_SQUARED
 
342
} CoglFogMode;
 
343
 
 
344
/**
 
345
 * COGL_BLEND_STRING_ERROR:
 
346
 *
 
347
 * #GError domain for blend string parser errors
 
348
 *
 
349
 * Since: 1.0
 
350
 */
 
351
#define COGL_BLEND_STRING_ERROR (cogl_blend_string_error_quark ())
 
352
 
 
353
/**
 
354
 * CoglBlendStringError:
 
355
 * @COGL_BLEND_STRING_ERROR_PARSE_ERROR: Generic parse error
 
356
 * @COGL_BLEND_STRING_ERROR_ARGUMENT_PARSE_ERROR: Argument parse error
 
357
 * @COGL_BLEND_STRING_ERROR_INVALID_ERROR: Internal parser error
 
358
 * @COGL_BLEND_STRING_ERROR_GPU_UNSUPPORTED_ERROR: Blend string not
 
359
 *   supported by the GPU
 
360
 *
 
361
 * Error enumeration for the blend strings parser
 
362
 *
 
363
 * Since: 1.0
 
364
 */
 
365
typedef enum { /*< prefix=COGL_BLEND_STRING_ERROR >*/
 
366
  COGL_BLEND_STRING_ERROR_PARSE_ERROR,
 
367
  COGL_BLEND_STRING_ERROR_ARGUMENT_PARSE_ERROR,
 
368
  COGL_BLEND_STRING_ERROR_INVALID_ERROR,
 
369
  COGL_BLEND_STRING_ERROR_GPU_UNSUPPORTED_ERROR
 
370
} CoglBlendStringError;
 
371
 
 
372
GQuark
 
373
cogl_blend_string_error_quark (void);
 
374
 
 
375
G_END_DECLS
 
376
 
 
377
#endif /* __COGL_TYPES_H__ */