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

« back to all changes in this revision

Viewing changes to clutter/cogl/cogl.h.in

  • 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
 
 
10
 
 * modify it under the terms of the GNU Lesser General Public
11
 
 * License as published by the Free Software Foundation; either
12
 
 * version 2 of the License, or (at your option) any later version.
13
 
 *
14
 
 * This library is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 
 * Lesser General Public License for more details.
18
 
 *
19
 
 * You should have received a copy of the GNU Lesser General Public
20
 
 * License along with this library; if not, write to the
21
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22
 
 * Boston, MA 02111-1307, USA.
23
 
 */
24
 
 
25
 
#ifndef __COGL_H__
26
 
#define __COGL_H__
27
 
 
28
 
#include <glib.h>
29
 
 
30
 
#define __COGL_H_INSIDE__
31
 
 
32
 
#include <cogl/cogl-defines-@CLUTTER_COGL@.h>
33
 
 
34
 
#include <cogl/cogl-vertex-buffer.h>
35
 
#include <cogl/cogl-matrix.h>
36
 
#include <cogl/cogl-vertex-buffer.h>
37
 
#include <cogl/cogl-fixed.h>
38
 
#include <cogl/cogl-color.h>
39
 
#include <cogl/cogl-offscreen.h>
40
 
#include <cogl/cogl-material.h>
41
 
#include <cogl/cogl-path.h>
42
 
#include <cogl/cogl-shader.h>
43
 
#include <cogl/cogl-bitmap.h>
44
 
#include <cogl/cogl-texture.h>
45
 
#include <cogl/cogl-types.h>
46
 
#include <cogl/cogl-debug.h>
47
 
#include <cogl/cogl-deprecated.h>
48
 
#include <cogl/cogl-enum-types.h>
49
 
 
50
 
G_BEGIN_DECLS
51
 
 
52
 
/**
53
 
 * SECTION:cogl
54
 
 * @short_description: General purpose API
55
 
 *
56
 
 * General utility functions for COGL.
57
 
 */
58
 
 
59
 
/**
60
 
 * cogl_get_option_group:
61
 
 *
62
 
 * Retrieves the #GOptionGroup used by COGL to parse the command
63
 
 * line options. Clutter uses this to handle the COGL command line
64
 
 * options during its initialization process.
65
 
 *
66
 
 * Return value: a #GOptionGroup
67
 
 *
68
 
 * Since: 1.0
69
 
 */
70
 
GOptionGroup *  cogl_get_option_group         (void);
71
 
 
72
 
/* Misc */
73
 
/**
74
 
 * cogl_get_features:
75
 
 *
76
 
 * Returns all of the features supported by COGL.
77
 
 *
78
 
 * Return value: A logical OR of all the supported COGL features.
79
 
 *
80
 
 * Since: 0.8
81
 
 */
82
 
CoglFeatureFlags cogl_get_features         (void);
83
 
 
84
 
/**
85
 
 * cogl_features_available:
86
 
 * @features: A bitmask of features to check for
87
 
 *
88
 
 * Checks whether the given COGL features are available. Multiple
89
 
 * features can be checked for by or-ing them together with the '|'
90
 
 * operator. %TRUE is only returned if all of the requested features
91
 
 * are available.
92
 
 *
93
 
 * Return value: %TRUE if the features are available, %FALSE otherwise.
94
 
 */
95
 
gboolean        cogl_features_available       (CoglFeatureFlags    features);
96
 
 
97
 
/**
98
 
 * cogl_get_proc_address:
99
 
 * @name: the name of the function.
100
 
 *
101
 
 * Gets a pointer to a given GL or GL ES extension function. This acts
102
 
 * as a wrapper around glXGetProcAddress() or whatever is the
103
 
 * appropriate function for the current backend.
104
 
 *
105
 
 * Return value: a pointer to the requested function or %NULL if the
106
 
 * function is not available.
107
 
 */
108
 
CoglFuncPtr     cogl_get_proc_address         (const gchar        *name);
109
 
 
110
 
/**
111
 
 * cogl_check_extension:
112
 
 * @name: extension to check for
113
 
 * @ext: list of extensions
114
 
 *
115
 
 * Check whether @name occurs in list of extensions in @ext.
116
 
 *
117
 
 * Returns: %TRUE if the extension occurs in the list, %FALSE otherwize.
118
 
 */
119
 
gboolean        cogl_check_extension          (const gchar        *name,
120
 
                                               const gchar        *ext);
121
 
 
122
 
/**
123
 
 * cogl_get_bitmasks:
124
 
 * @red: Return location for the number of red bits or %NULL
125
 
 * @green: Return location for the number of green bits or %NULL
126
 
 * @blue: Return location for the number of blue bits or %NULL
127
 
 * @alpha: Return location for the number of alpha bits or %NULL
128
 
 *
129
 
 * Gets the number of bitplanes used for each of the color components
130
 
 * in the color buffer. Pass %NULL for any of the arguments if the
131
 
 * value is not required.
132
 
 */
133
 
void            cogl_get_bitmasks             (gint               *red,
134
 
                                               gint               *green,
135
 
                                               gint               *blue,
136
 
                                               gint               *alpha);
137
 
 
138
 
/**
139
 
 * cogl_perspective:
140
 
 * @fovy: Vertical of view angle in degrees.
141
 
 * @aspect: Aspect ratio of diesplay
142
 
 * @z_near: Nearest visible point
143
 
 * @z_far: Furthest visible point along the z-axis
144
 
 *
145
 
 * Replaces the current projection matrix with a perspective matrix
146
 
 * based on the provided values.
147
 
 */
148
 
void            cogl_perspective              (float        fovy,
149
 
                                               float        aspect,
150
 
                                               float        z_near,
151
 
                                               float        z_far);
152
 
 
153
 
/**
154
 
 * cogl_frustum:
155
 
 * @left: Left clipping plane
156
 
 * @right: Right clipping plane
157
 
 * @bottom: Bottom clipping plane
158
 
 * @top: Top clipping plane
159
 
 * @z_near: Nearest visible point
160
 
 * @z_far: Furthest visible point along the z-axis
161
 
 *
162
 
 * Replaces the current projection matrix with a perspective matrix
163
 
 * for the given viewing frustum.
164
 
 *
165
 
 * Since: 0.8.2
166
 
 */
167
 
void            cogl_frustum                  (float        left,
168
 
                                               float        right,
169
 
                                               float        bottom,
170
 
                                               float        top,
171
 
                                               float        z_near,
172
 
                                               float        z_far);
173
 
 
174
 
/**
175
 
 * cogl_ortho:
176
 
 * @left: The coordinate for the left clipping plane
177
 
 * @right: The coordinate for the right clipping plane
178
 
 * @bottom: The coordinate for the bottom clipping plane
179
 
 * @top: The coordinate for the top clipping plane
180
 
 * @near: The coordinate for the near clipping plane (may be negative if
181
 
 *        the plane is behind the viewer)
182
 
 * @far: The coordinate for the far clipping plane (may be negative if
183
 
 *       the plane is behind the viewer)
184
 
 *
185
 
 * Replaces the current projection matrix with a parallel projection
186
 
 * matrix.
187
 
 *
188
 
 * Since: 1.0
189
 
 */
190
 
void            cogl_ortho                    (float left,
191
 
                                               float right,
192
 
                                               float bottom,
193
 
                                               float top,
194
 
                                               float near,
195
 
                                               float far);
196
 
 
197
 
/*
198
 
 * _cogl_setup_viewport:
199
 
 * @width: Width of the viewport
200
 
 * @height: Height of the viewport
201
 
 * @fovy: Field of view angle in degrees
202
 
 * @aspect: Aspect ratio to determine the field of view along the x-axis
203
 
 * @z_near: Nearest visible point along the z-axis
204
 
 * @z_far: Furthest visible point along the z-axis
205
 
 *
206
 
 * Replaces the current viewport and projection matrix with the given
207
 
 * values. The viewport is placed at the top left corner of the window
208
 
 * with the given width and height. The projection matrix is replaced
209
 
 * with one that has a viewing angle of @fovy along the y-axis and a
210
 
 * view scaled according to @aspect along the x-axis. The view is
211
 
 * clipped according to @z_near and @z_far on the z-axis.
212
 
 *
213
 
 * This function is used only by Clutter.
214
 
 */
215
 
void            _cogl_setup_viewport          (guint        width,
216
 
                                               guint        height,
217
 
                                               float        fovy,
218
 
                                               float        aspect,
219
 
                                               float        z_near,
220
 
                                               float        z_far);
221
 
 
222
 
/**
223
 
 * cogl_viewport:
224
 
 * @width: Width of the viewport
225
 
 * @height: Height of the viewport
226
 
 *
227
 
 * Replace the current viewport with the given values.
228
 
 *
229
 
 * Since: 0.8.2
230
 
 */
231
 
void            cogl_viewport                 (guint               width,
232
 
                                               guint               height);
233
 
 
234
 
/**
235
 
 * cogl_push_matrix:
236
 
 *
237
 
 * Store the current model-view matrix on the matrix stack. The matrix
238
 
 * can later be restored with cogl_pop_matrix().
239
 
 */
240
 
void            cogl_push_matrix              (void);
241
 
 
242
 
/**
243
 
 * cogl_pop_matrix:
244
 
 *
245
 
 * Restore the current model-view matrix from the matrix stack.
246
 
 */
247
 
void            cogl_pop_matrix               (void);
248
 
 
249
 
/**
250
 
 * cogl_scale:
251
 
 * @x: Amount to scale along the x-axis
252
 
 * @y: Amount to scale along the y-axis
253
 
 * @z: Amount to scale along the z-axis
254
 
 *
255
 
 * Multiplies the current model-view matrix by one that scales the x,
256
 
 * y and z axes by the given values.
257
 
 */
258
 
void            cogl_scale                    (float        x,
259
 
                                               float        y,
260
 
                                               float        z);
261
 
 
262
 
/**
263
 
 * cogl_translate:
264
 
 * @x: Distance to translate along the x-axis
265
 
 * @y: Distance to translate along the y-axis
266
 
 * @z: Distance to translate along the z-axis
267
 
 *
268
 
 * Multiplies the current model-view matrix by one that translates the
269
 
 * model along all three axes according to the given values.
270
 
 */
271
 
void            cogl_translate                (float                x,
272
 
                                               float                y,
273
 
                                               float                z);
274
 
 
275
 
/**
276
 
 * cogl_rotate:
277
 
 * @angle: Angle in degrees to rotate.
278
 
 * @x: X-component of vertex to rotate around.
279
 
 * @y: Y-component of vertex to rotate around.
280
 
 * @z: Z-component of vertex to rotate around.
281
 
 *
282
 
 * Multiplies the current model-view matrix by one that rotates the
283
 
 * model around the vertex specified by @x, @y and @z. The rotation
284
 
 * follows the right-hand thumb rule so for example rotating by 10
285
 
 * degrees about the vertex (0, 0, 1) causes a small counter-clockwise
286
 
 * rotation.
287
 
 */
288
 
void            cogl_rotate                   (float                angle,
289
 
                                               float                x,
290
 
                                               float                y,
291
 
                                               float                z);
292
 
 
293
 
/**
294
 
 * cogl_get_modelview_matrix:
295
 
 * @matrix: pointer to a CoglMatrix to recieve the matrix
296
 
 *
297
 
 * Stores the current model-view matrix in @matrix.
298
 
 */
299
 
void            cogl_get_modelview_matrix     (CoglMatrix *matrix);
300
 
 
301
 
/**
302
 
 * cogl_set_modelview_matrix:
303
 
 * @matrix: pointer to a CoglMatrix to set as the new model-view matrix
304
 
 *
305
 
 * Loads matrix as the new model-view matrix.
306
 
 */
307
 
void            cogl_set_modelview_matrix     (CoglMatrix *matrix);
308
 
 
309
 
/**
310
 
 * cogl_get_projection_matrix:
311
 
 * @matrix: pointer to a CoglMatrix to recieve the matrix
312
 
 *
313
 
 * Stores the current projection matrix in @matrix.
314
 
 */
315
 
void            cogl_get_projection_matrix    (CoglMatrix *matrix);
316
 
 
317
 
/**
318
 
 * cogl_set_projection_matrix:
319
 
 * @matrix: pointer to a CoglMatrix to set as the new projection matrix
320
 
 *
321
 
 * Loads matrix as the new projection matrix.
322
 
 */
323
 
void            cogl_set_projection_matrix    (CoglMatrix *matrix);
324
 
 
325
 
/**
326
 
 * cogl_get_viewport:
327
 
 * @v: pointer to a 4 element array of #float<!-- -->s to
328
 
 * receive the viewport dimensions.
329
 
 *
330
 
 * Stores the current viewport in @v. @v[0] and @v[1] get the x and y
331
 
 * position of the viewport and @v[2] and @v[3] get the width and
332
 
 * height.
333
 
 */
334
 
void            cogl_get_viewport             (float        v[4]);
335
 
 
336
 
/**
337
 
 * cogl_set_depth_test_enabled:
338
 
 * @setting: %TRUE to enable depth testing or %FALSE to disable.
339
 
 *
340
 
 * Sets whether depth testing is enabled. If it is disabled then the
341
 
 * order that actors are layered on the screen depends solely on the
342
 
 * order specified using clutter_actor_raise() and
343
 
 * clutter_actor_lower(), otherwise it will also take into account the
344
 
 * actor's depth. Depth testing is disabled by default.
345
 
 */
346
 
void            cogl_set_depth_test_enabled   (gboolean setting);
347
 
 
348
 
/**
349
 
 * cogl_get_depth_test_enabled:
350
 
 *
351
 
 * Queries if depth testing has been enabled via cogl_set_depth_test_enable()
352
 
 *
353
 
 * Returns: %TRUE if depth testing is enabled, and %FALSE otherwise
354
 
 */
355
 
gboolean        cogl_get_depth_test_enabled   (void);
356
 
 
357
 
/**
358
 
 * cogl_set_backface_culling_enabled:
359
 
 * @setting: %TRUE to enable backface culling or %FALSE to disable.
360
 
 *
361
 
 * Sets whether textures positioned so that their backface is showing
362
 
 * should be hidden. This can be used to efficiently draw two-sided
363
 
 * textures or fully closed cubes without enabling depth testing. This
364
 
 * only affects calls to the cogl_rectangle* family of functions and
365
 
 * cogl_vertex_buffer_draw*. Backface culling is disabled by default.
366
 
 */
367
 
void            cogl_set_backface_culling_enabled (gboolean setting);
368
 
 
369
 
/**
370
 
 * cogl_get_backface_culling_enabled:
371
 
 *
372
 
 * Queries if backface culling has been enabled via
373
 
 * cogl_set_backface_culling_enabled()
374
 
 *
375
 
 * Returns: %TRUE if backface culling is enabled, and %FALSE otherwise
376
 
 */
377
 
gboolean        cogl_get_backface_culling_enabled (void);
378
 
 
379
 
/**
380
 
 * cogl_set_fog:
381
 
 * @fog_color: The color of the fog
382
 
 * @mode: A CoglFogMode that determines the equation used to calculate the
383
 
 *        fogging blend factor.
384
 
 * @density: Used by the EXPONENTIAL and EXPONENTIAL_SQUARED CoglFogMode
385
 
 *           equations.
386
 
 * @z_near: Position along z-axis where no fogging should be applied
387
 
 * @z_far: Position along z-axes where full fogging should be applied
388
 
 *
389
 
 * Enables fogging. Fogging causes vertices that are further away from the eye
390
 
 * to be rendered with a different color. The color is determined according to
391
 
 * the chosen fog mode; at it's simplest the color is linearly interpolated so
392
 
 * that vertices at @z_near are drawn fully with their original color and
393
 
 * vertices at @z_far are drawn fully with @fog_color. Fogging will remain
394
 
 * enabled until you call cogl_disable_fog().
395
 
 *
396
 
 * <note>The fogging functions only work correctly when primitives use
397
 
 * unmultiplied alpha colors. By default Cogl will premultiply textures
398
 
 * and cogl_set_source_color() will premultiply colors, so unless you
399
 
 * explicitly load your textures requesting an unmultiplied internal format
400
 
 * and use cogl_material_set_color() you can only use fogging with fully
401
 
 * opaque primitives. This might improve in the future when we can depend
402
 
 * on fragment shaders.</note>
403
 
 */
404
 
void            cogl_set_fog                  (const CoglColor *fog_color,
405
 
                                               CoglFogMode      mode,
406
 
                                               float            density,
407
 
                                               float            z_near,
408
 
                                               float            z_far);
409
 
 
410
 
/**
411
 
 * cogl_disable_fog:
412
 
 *
413
 
 * This function disables fogging, so primitives drawn afterwards will not be
414
 
 * blended with any previously set fog color.
415
 
 */
416
 
void            cogl_disable_fog              (void);
417
 
 
418
 
/**
419
 
 * CoglBufferBit:
420
 
 * @COGL_BUFFER_BIT_COLOR: Selects the primary color buffer
421
 
 * @COGL_BUFFER_BIT_DEPTH: Selects the depth buffer
422
 
 * @COGL_BUFFER_BIT_STENCIL: Selects the stencil buffer
423
 
 *
424
 
 * Types of auxiliary buffers
425
 
 *
426
 
 * Since: 1.0
427
 
 */
428
 
typedef enum {
429
 
  COGL_BUFFER_BIT_COLOR   = 1L<<0,
430
 
  COGL_BUFFER_BIT_DEPTH   = 1L<<1,
431
 
  COGL_BUFFER_BIT_STENCIL = 1L<<2
432
 
} CoglBufferBit;
433
 
 
434
 
/**
435
 
 * cogl_clear:
436
 
 * @color: Background color to clear to
437
 
 * @buffers: A mask of #CoglBufferBit<!-- -->'s identifying which auxiliary
438
 
 *   buffers to clear
439
 
 *
440
 
 * Clears all the auxiliary buffers identified in the @buffers mask, and if
441
 
 * that includes the color buffer then the specified @color is used.
442
 
 */
443
 
void            cogl_clear                    (const CoglColor *color,
444
 
                                               gulong           buffers);
445
 
 
446
 
/**
447
 
 * cogl_set_source:
448
 
 * @material: A CoglMaterial object
449
 
 *
450
 
 * This function sets the source material that will be used to fill subsequent
451
 
 * geometry emitted via the cogl API.
452
 
 *
453
 
 * Note: in the future we may add the ability to set a front facing material,
454
 
 * and a back facing material, in which case this function will set both to the
455
 
 * same.
456
 
 *
457
 
 * Since 1.0
458
 
 */
459
 
void            cogl_set_source               (CoglHandle material);
460
 
 
461
 
/**
462
 
 * cogl_set_source_color:
463
 
 * @color: a #CoglColor
464
 
 *
465
 
 * This is a convenience function for creating a solid fill source material
466
 
 * from the given color. This color will be used for any subsequent drawing
467
 
 * operation.
468
 
 *
469
 
 * The color will be premultiplied by Cogl, so the color should be
470
 
 * non-premultiplied. For example: use (1.0, 0.0, 0.0, 0.5) for
471
 
 * semi-transparent red.
472
 
 *
473
 
 * See also cogl_set_source_color4ub() and cogl_set_source_color4f()
474
 
 * if you already have the color components.
475
 
 *
476
 
 * Since: 1.0
477
 
 */
478
 
void            cogl_set_source_color         (const CoglColor *color);
479
 
 
480
 
/**
481
 
 * cogl_set_source_color4ub:
482
 
 * @red: value of the red channel, between 0 and 255
483
 
 * @green: value of the green channel, between 0 and 255
484
 
 * @blue: value of the blue channel, between 0 and 255
485
 
 * @alpha: value of the alpha channel, between 0 and 255
486
 
 *
487
 
 * This is a convenience function for creating a solid fill source material
488
 
 * from the given color using unsigned bytes for each component. This
489
 
 * color will be used for any subsequent drawing operation.
490
 
 *
491
 
 * The value for each component is an unsigned byte in the range
492
 
 * between 0 and 255.
493
 
 *
494
 
 * Since: 1.0
495
 
 */
496
 
void            cogl_set_source_color4ub      (guint8 red,
497
 
                                               guint8 green,
498
 
                                               guint8 blue,
499
 
                                               guint8 alpha);
500
 
 
501
 
/**
502
 
 * cogl_set_source_color4f:
503
 
 * @red: value of the red channel, between 0 and %1.0
504
 
 * @green: value of the green channel, between 0 and %1.0
505
 
 * @blue: value of the blue channel, between 0 and %1.0
506
 
 * @alpha: value of the alpha channel, between 0 and %1.0
507
 
 *
508
 
 * This is a convenience function for creating a solid fill source material
509
 
 * from the given color using normalized values for each component. This color
510
 
 * will be used for any subsequent drawing operation.
511
 
 *
512
 
 * The value for each component is a fixed point number in the range
513
 
 * between 0 and %1.0. If the values passed in are outside that
514
 
 * range, they will be clamped.
515
 
 *
516
 
 * Since: 1.0
517
 
 */
518
 
void            cogl_set_source_color4f       (float red,
519
 
                                               float green,
520
 
                                               float blue,
521
 
                                               float alpha);
522
 
 
523
 
/**
524
 
 * cogl_set_source_texture:
525
 
 * @texture_handle: The Cogl texture you want as your source
526
 
 *
527
 
 * This is a convenience function for creating a material with the first
528
 
 * layer set to #texture_handle and setting that material as the source with
529
 
 * cogl_set_source.
530
 
 *
531
 
 * Note: There is no interaction between calls to cogl_set_source_color
532
 
 * and cogl_set_source_texture. If you need to blend a texture with a color then
533
 
 * you can create a simple material like this:
534
 
 * <programlisting>
535
 
 * material = cogl_material_new ();
536
 
 * cogl_material_set_color4ub (material, 0xff, 0x00, 0x00, 0x80);
537
 
 * cogl_material_set_layer (material, 0, tex_handle);
538
 
 * cogl_set_source (material);
539
 
 * </programlisting>
540
 
 *
541
 
 * Since 1.0
542
 
 */
543
 
void            cogl_set_source_texture       (CoglHandle texture_handle);
544
 
 
545
 
/**
546
 
 * SECTION:cogl-clipping
547
 
 * @short_description: Fuctions for manipulating a stack of clipping regions
548
 
 *
549
 
 * To support clipping your geometry to rectangles or paths Cogl exposes a
550
 
 * stack based API whereby each clip region you push onto the stack is
551
 
 * intersected with the previous region.
552
 
 */
553
 
 
554
 
/**
555
 
 * cogl_clip_push_window_rect:
556
 
 * @x_offset: left edge of the clip rectangle in window coordinates
557
 
 * @y_offset: top edge of the clip rectangle in window coordinates
558
 
 * @width: width of the clip rectangle
559
 
 * @height: height of the clip rectangle
560
 
 *
561
 
 * Specifies a rectangular clipping area for all subsequent drawing
562
 
 * operations. Any drawing commands that extend outside the rectangle
563
 
 * will be clipped so that only the portion inside the rectangle will
564
 
 * be displayed. The rectangle dimensions are not transformed by the
565
 
 * current model-view matrix.
566
 
 *
567
 
 * The rectangle is intersected with the current clip region. To undo
568
 
 * the effect of this function, call cogl_clip_pop().
569
 
 */
570
 
void            cogl_clip_push_window_rect    (float x_offset,
571
 
                                               float y_offset,
572
 
                                               float width,
573
 
                                               float height);
574
 
 
575
 
/**
576
 
 * cogl_clip_push:
577
 
 * @x_offset: left edge of the clip rectangle
578
 
 * @y_offset: top edge of the clip rectangle
579
 
 * @width: width of the clip rectangle
580
 
 * @height: height of the clip rectangle
581
 
 *
582
 
 * Specifies a rectangular clipping area for all subsequent drawing
583
 
 * operations. Any drawing commands that extend outside the rectangle
584
 
 * will be clipped so that only the portion inside the rectangle will
585
 
 * be displayed. The rectangle dimensions are transformed by the
586
 
 * current model-view matrix.
587
 
 *
588
 
 * The rectangle is intersected with the current clip region. To undo
589
 
 * the effect of this function, call cogl_clip_pop().
590
 
 */
591
 
void            cogl_clip_push                (float        x_offset,
592
 
                                               float        y_offset,
593
 
                                               float        width,
594
 
                                               float        height);
595
 
 
596
 
/**
597
 
 * cogl_clip_push_from_path:
598
 
 *
599
 
 * Sets a new clipping area using the current path. The current path
600
 
 * is then cleared. The clipping area is intersected with the previous
601
 
 * clipping area. To restore the previous clipping area, call
602
 
 * cogl_clip_pop().
603
 
 *
604
 
 * Since: 1.0
605
 
 */
606
 
void            cogl_clip_push_from_path       (void);
607
 
 
608
 
/**
609
 
 * cogl_clip_push_from_path_preserve:
610
 
 *
611
 
 * Sets a new clipping area using the current path. The current path
612
 
 * is then cleared. The clipping area is intersected with the previous
613
 
 * clipping area. To restore the previous clipping area, call
614
 
 * cogl_clip_pop().
615
 
 *
616
 
 * Since: 1.0
617
 
 */
618
 
void            cogl_clip_push_from_path_preserve (void);
619
 
 
620
 
/**
621
 
 * cogl_clip_pop:
622
 
 *
623
 
 * Reverts the clipping region to the state before the last call to
624
 
 * cogl_clip_push().
625
 
 */
626
 
void            cogl_clip_pop               (void);
627
 
 
628
 
/**
629
 
 * cogl_clip_ensure:
630
 
 *
631
 
 * Ensures that the current clipping region has been set in GL. This
632
 
 * will automatically be called before any Cogl primitives but it
633
 
 * maybe be neccessary to call if you are using raw GL calls with
634
 
 * clipping.
635
 
 *
636
 
 * Since: 1.0
637
 
 */
638
 
void            cogl_clip_ensure              (void);
639
 
 
640
 
/**
641
 
 * cogl_clip_stack_save:
642
 
 *
643
 
 * Save the entire state of the clipping stack and then clear all
644
 
 * clipping. The previous state can be returned to with
645
 
 * cogl_clip_stack_restore(). Each call to cogl_clip_push() after this
646
 
 * must be matched by a call to cogl_clip_pop() before calling
647
 
 * cogl_clip_stack_restore().
648
 
 *
649
 
 * Since: 0.8.2
650
 
 */
651
 
void            cogl_clip_stack_save          (void);
652
 
 
653
 
/**
654
 
 * cogl_clip_stack_restore:
655
 
 *
656
 
 * Restore the state of the clipping stack that was previously saved
657
 
 * by cogl_clip_stack_save().
658
 
 *
659
 
 * Since: 0.8.2
660
 
 */
661
 
void            cogl_clip_stack_restore       (void);
662
 
 
663
 
/**
664
 
 * cogl_set_draw_buffer:
665
 
 * @target: A #CoglBufferTarget that specifies what kind of draw buffer you
666
 
 *          are setting as the render target.
667
 
 * @offscreen: If you are setting a draw buffer of type COGL_OFFSCREEN_BUFFER
668
 
 *             then this is a CoglHandle for the offscreen buffer.
669
 
 *
670
 
 * This redirects all subsequent drawing to the specified draw buffer. This
671
 
 * can either be an offscreen buffer created with
672
 
 * cogl_offscreen_new_to_texture () or you can revert to your original
673
 
 * on screen window buffer.
674
 
 */
675
 
void            cogl_set_draw_buffer          (CoglBufferTarget    target,
676
 
                                               CoglHandle          offscreen);
677
 
 
678
 
/**
679
 
 * cogl_push_draw_buffer:
680
 
 *
681
 
 * Save cogl_set_draw_buffer() state.
682
 
 */
683
 
void            cogl_push_draw_buffer         (void);
684
 
 
685
 
/**
686
 
 * cogl_pop_draw_buffer:
687
 
 *
688
 
 * Restore cogl_set_draw_buffer() state.
689
 
 */
690
 
void            cogl_pop_draw_buffer          (void);
691
 
 
692
 
/**
693
 
 * CoglReadPixelsFlags:
694
 
 * @COGL_READ_PIXELS_COLOR_BUFFER: Read from the color buffer
695
 
 *
696
 
 * Flags for cogl_read_pixels()
697
 
 *
698
 
 * Since: 1.0
699
 
 */
700
 
typedef enum { /*< prefix=COGL_READ_PIXELS >*/
701
 
  COGL_READ_PIXELS_COLOR_BUFFER = 1L << 0
702
 
} CoglReadPixelsFlags;
703
 
 
704
 
/**
705
 
 * cogl_read_pixels:
706
 
 * @x: The window x position to start reading from
707
 
 * @y: The window y position to start reading from
708
 
 * @width: The width of the rectangle you want to read
709
 
 * @height: The height of the rectangle you want to read
710
 
 * @source: Identifies which auxillary buffer you want to read
711
 
 *          (only COGL_READ_PIXELS_COLOR_BUFFER supported currently)
712
 
 * @format: The pixel format you want the result in
713
 
 *          (only COGL_PIXEL_FORMAT_RGBA_8888 supported currently)
714
 
 * @pixels: The location to write the pixel data.
715
 
 *
716
 
 * This reads a rectangle of pixels from the current draw buffer where
717
 
 * position (0, 0) is the top left. The pixel at (x, y) is the first
718
 
 * read, and the data is returned with a rowstride of (width * 4)
719
 
 */
720
 
void            cogl_read_pixels (int x,
721
 
                                  int y,
722
 
                                  int width,
723
 
                                  int height,
724
 
                                  CoglReadPixelsFlags source,
725
 
                                  CoglPixelFormat format,
726
 
                                  guint8 *pixels);
727
 
 
728
 
/**
729
 
 * cogl_flush:
730
 
 *
731
 
 * This function should only need to be called in exceptional circumstances.
732
 
 *
733
 
 * As an optimization Cogl drawing functions may batch up primitives
734
 
 * internally, so if you are trying to use raw GL outside of Cogl you stand a
735
 
 * better chance of being successful if you ask Cogl to flush any batched
736
 
 * geometry before making your state changes.
737
 
 *
738
 
 * It only ensure that the underlying driver is issued all the commands
739
 
 * necessary to draw the batched primitives. It provides no guarantees about
740
 
 * when the driver will complete the rendering.
741
 
 *
742
 
 * This provides no guarantees about the GL state upon returning and to avoid
743
 
 * confusing Cogl you should aim to restore any changes you make before
744
 
 * resuming use of Cogl.
745
 
 *
746
 
 * If you are making state changes with the intention of affecting Cogl drawing
747
 
 * primitives you are 100% on your own since you stand a good chance of
748
 
 * conflicting with Cogl internals. For example clutter-gst which currently
749
 
 * uses direct GL calls to bind ARBfp programs will very likely break when Cogl
750
 
 * starts to use ARBfb programs itself for the material API.
751
 
 *
752
 
 * Since: 1.0
753
 
 */
754
 
void            cogl_flush (void);
755
 
 
756
 
/**
757
 
 * cogl_begin_gl:
758
 
 *
759
 
 * We do not advise nor reliably support the interleaving of raw GL drawing and
760
 
 * Cogl drawing functions, but if you insist, cogl_begin_gl() and cogl_end_gl()
761
 
 * provide a simple mechanism that may at least give you a fighting chance of
762
 
 * succeeding.
763
 
 *
764
 
 * Note: this doesn't help you modify the behaviour of Cogl drawing functions
765
 
 * through the modification of GL state; that will never be reliably supported,
766
 
 * but if you are trying to do something like:
767
 
 * <programlisting>
768
 
 * {
769
 
 *    - setup some OpenGL state.
770
 
 *    - draw using OpenGL (e.g. glDrawArrays() )
771
 
 *    - reset modified OpenGL state.
772
 
 *    - continue using Cogl to draw
773
 
 * }
774
 
 * </programlisting>
775
 
 * You should surround blocks of drawing using raw GL with cogl_begin_gl()
776
 
 * and cogl_end_gl():
777
 
 * <programlisting>
778
 
 * {
779
 
 *    cogl_begin_gl ();
780
 
 *    - setup some OpenGL state.
781
 
 *    - draw using OpenGL (e.g. glDrawArrays() )
782
 
 *    - reset modified OpenGL state.
783
 
 *    cogl_end_gl ();
784
 
 *    - continue using Cogl to draw
785
 
 * }
786
 
 * </programlisting>
787
 
 *
788
 
 * Don't ever try and do:
789
 
 * <programlisting>
790
 
 * {
791
 
 *    - setup some OpenGL state.
792
 
 *    - use Cogl to draw
793
 
 *    - reset modified OpenGL state.
794
 
 * }
795
 
 * </programlisting>
796
 
 * When the internals of Cogl evolves, this is very liable to break.
797
 
 *
798
 
 * This function will flush all batched primitives, and subsequently flush
799
 
 * all internal Cogl state to OpenGL as if it were going to draw something
800
 
 * itself.
801
 
 *
802
 
 * The result is that the OpenGL modelview matrix will be setup; the state
803
 
 * corresponding to the current source material will be set up and other world
804
 
 * state such as backface culling, depth and fogging enabledness will be sent
805
 
 * to OpenGL.
806
 
 *
807
 
 * Note: no special material state is flushed, so if you want Cogl to setup a
808
 
 * simplified material state it is your responsibility to set a simple source
809
 
 * material before calling cogl_begin_gl. E.g. by calling
810
 
 * cogl_set_source_color4ub().
811
 
 *
812
 
 * Note: It is your responsibility to restore any OpenGL state that you modify
813
 
 * to how it was after calling cogl_begin_gl() if you don't do this then the
814
 
 * result of further Cogl calls is undefined.
815
 
 *
816
 
 * Note: You can not nest begin/end blocks.
817
 
 *
818
 
 * Again we would like to stress, we do not advise the use of this API and if
819
 
 * possible we would prefer to improve Cogl than have developers require raw
820
 
 * OpenGL.
821
 
 *
822
 
 * Since: 1.0
823
 
 */
824
 
void            cogl_begin_gl (void);
825
 
 
826
 
/**
827
 
 * cogl_end_gl:
828
 
 *
829
 
 * This is the counterpart to cogl_begin_gl() used to delimit blocks of drawing
830
 
 * code using raw OpenGL. Please refer to cogl_begin_gl() for full details.
831
 
 *
832
 
 * Since: 1.0
833
 
 */
834
 
void            cogl_end_gl (void);
835
 
 
836
 
/*
837
 
 * Internal API available only to Clutter.
838
 
 *
839
 
 * These are typically only to deal with the poor seperation of
840
 
 * responsabilities that currently exists between Clutter and Cogl.
841
 
 * Eventually a lot of the backend code currently in Clutter will
842
 
 * move down into Cogl and these functions will be removed.
843
 
 */
844
 
 
845
 
void            _cogl_destroy_context          (void);
846
 
 
847
 
/* XXX: Removed before we release Clutter 1.0 since the implementation
848
 
 * wasn't complete, and so we assume no one is using this yet. Util we
849
 
 * have some one with a good usecase, we can't pretend to support breaking
850
 
 * out into raw OpenGL. */
851
 
#if 0
852
 
/*
853
 
 * cogl_flush_gl_state:
854
 
 * @flags: flags controlling what is flushed; currently unused, pass in 0
855
 
 *
856
 
 * As an optimization, COGL functions may not immediately modify GL's
857
 
 * state, instead batching up changes and applying them "just in
858
 
 * time."  Unapplied state could include glEnable() flags and the
859
 
 * current transformation matrix among other examples. If you want to
860
 
 * use GL directly, you need to flush any state COGL may have kept
861
 
 * around. cogl_flush_gl_state() syncs all of COGL's state to GL.
862
 
 *
863
 
 * Since: 1.0
864
 
 */
865
 
void            cogl_flush_gl_state         (int      flags);
866
 
#endif
867
 
 
868
 
/* private */
869
 
void            _cogl_set_indirect_context  (gboolean indirect);
870
 
 
871
 
G_END_DECLS
872
 
 
873
 
#undef __COGL_H_INSIDE__
874
 
 
875
 
#endif /* __COGL_H__ */