~elementary-os/ubuntu-package-imports/mutter-bionic

« back to all changes in this revision

Viewing changes to cogl/cogl/cogl-primitive.h

  • Committer: RabbitBot
  • Date: 2018-04-11 14:49:36 UTC
  • Revision ID: rabbitbot@elementary.io-20180411144936-hgymqa9d8d1xfpbh
Initial import, version 3.28.0-2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Cogl
 
3
 *
 
4
 * A Low Level GPU Graphics and Utilities API
 
5
 *
 
6
 * Copyright (C) 2010 Intel Corporation.
 
7
 *
 
8
 * Permission is hereby granted, free of charge, to any person
 
9
 * obtaining a copy of this software and associated documentation
 
10
 * files (the "Software"), to deal in the Software without
 
11
 * restriction, including without limitation the rights to use, copy,
 
12
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 
13
 * of the Software, and to permit persons to whom the Software is
 
14
 * furnished to do so, subject to the following conditions:
 
15
 *
 
16
 * The above copyright notice and this permission notice shall be
 
17
 * included in all copies or substantial portions of the Software.
 
18
 *
 
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
20
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
21
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
22
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 
23
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 
24
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
25
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 
26
 * SOFTWARE.
 
27
 *
 
28
 *
 
29
 *
 
30
 * Authors:
 
31
 *   Robert Bragg <robert@linux.intel.com>
 
32
 */
 
33
 
 
34
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
 
35
#error "Only <cogl/cogl.h> can be included directly."
 
36
#endif
 
37
 
 
38
#ifndef __COGL_PRIMITIVE_H__
 
39
#define __COGL_PRIMITIVE_H__
 
40
 
 
41
/* We forward declare the CoglPrimitive type here to avoid some circular
 
42
 * dependency issues with the following headers.
 
43
 */
 
44
typedef struct _CoglPrimitive CoglPrimitive;
 
45
 
 
46
#include <cogl/cogl-types.h> /* for CoglVerticesMode */
 
47
#include <cogl/cogl-attribute.h>
 
48
#include <cogl/cogl-framebuffer.h>
 
49
 
 
50
#include <glib-object.h>
 
51
 
 
52
COGL_BEGIN_DECLS
 
53
 
 
54
/**
 
55
 * SECTION:cogl-primitive
 
56
 * @short_description: Functions for creating, manipulating and drawing
 
57
 *    primitives
 
58
 *
 
59
 * FIXME
 
60
 */
 
61
 
 
62
/**
 
63
 * CoglPrimitive: (ref-func cogl_object_ref) (unref-func cogl_object_unref)
 
64
 *     (set-value-func cogl_object_value_set_object)
 
65
 *     (get-value-func cogl_object_value_get_object)
 
66
 */
 
67
 
 
68
/**
 
69
 * cogl_primitive_get_gtype:
 
70
 *
 
71
 * Returns: a #GType that can be used with the GLib type system.
 
72
 */
 
73
GType cogl_primitive_get_gtype (void);
 
74
 
 
75
/**
 
76
 * CoglVertexP2:
 
77
 * @x: The x component of a position attribute
 
78
 * @y: The y component of a position attribute
 
79
 *
 
80
 * A convenience vertex definition that can be used with
 
81
 * cogl_primitive_new_p2().
 
82
 *
 
83
 * Since: 1.6
 
84
 * Stability: Unstable
 
85
 */
 
86
typedef struct {
 
87
   float x, y;
 
88
} CoglVertexP2;
 
89
 
 
90
/**
 
91
 * CoglVertexP3:
 
92
 * @x: The x component of a position attribute
 
93
 * @y: The y component of a position attribute
 
94
 * @z: The z component of a position attribute
 
95
 *
 
96
 * A convenience vertex definition that can be used with
 
97
 * cogl_primitive_new_p3().
 
98
 *
 
99
 * Since: 1.6
 
100
 * Stability: Unstable
 
101
 */
 
102
typedef struct {
 
103
   float x, y, z;
 
104
} CoglVertexP3;
 
105
 
 
106
/**
 
107
 * CoglVertexP2C4:
 
108
 * @x: The x component of a position attribute
 
109
 * @y: The y component of a position attribute
 
110
 * @r: The red component of a color attribute
 
111
 * @b: The green component of a color attribute
 
112
 * @g: The blue component of a color attribute
 
113
 * @a: The alpha component of a color attribute
 
114
 *
 
115
 * A convenience vertex definition that can be used with
 
116
 * cogl_primitive_new_p2c4().
 
117
 *
 
118
 * Since: 1.6
 
119
 * Stability: Unstable
 
120
 */
 
121
typedef struct {
 
122
   float x, y;
 
123
   uint8_t r, g, b, a;
 
124
} CoglVertexP2C4;
 
125
 
 
126
/**
 
127
 * CoglVertexP3C4:
 
128
 * @x: The x component of a position attribute
 
129
 * @y: The y component of a position attribute
 
130
 * @z: The z component of a position attribute
 
131
 * @r: The red component of a color attribute
 
132
 * @b: The green component of a color attribute
 
133
 * @g: The blue component of a color attribute
 
134
 * @a: The alpha component of a color attribute
 
135
 *
 
136
 * A convenience vertex definition that can be used with
 
137
 * cogl_primitive_new_p3c4().
 
138
 *
 
139
 * Since: 1.6
 
140
 * Stability: Unstable
 
141
 */
 
142
typedef struct {
 
143
   float x, y, z;
 
144
   uint8_t r, g, b, a;
 
145
} CoglVertexP3C4;
 
146
 
 
147
/**
 
148
 * CoglVertexP2T2:
 
149
 * @x: The x component of a position attribute
 
150
 * @y: The y component of a position attribute
 
151
 * @s: The s component of a texture coordinate attribute
 
152
 * @t: The t component of a texture coordinate attribute
 
153
 *
 
154
 * A convenience vertex definition that can be used with
 
155
 * cogl_primitive_new_p2t2().
 
156
 *
 
157
 * Since: 1.6
 
158
 * Stability: Unstable
 
159
 */
 
160
typedef struct {
 
161
   float x, y;
 
162
   float s, t;
 
163
} CoglVertexP2T2;
 
164
 
 
165
/**
 
166
 * CoglVertexP3T2:
 
167
 * @x: The x component of a position attribute
 
168
 * @y: The y component of a position attribute
 
169
 * @z: The z component of a position attribute
 
170
 * @s: The s component of a texture coordinate attribute
 
171
 * @t: The t component of a texture coordinate attribute
 
172
 *
 
173
 * A convenience vertex definition that can be used with
 
174
 * cogl_primitive_new_p3t2().
 
175
 *
 
176
 * Since: 1.6
 
177
 * Stability: Unstable
 
178
 */
 
179
typedef struct {
 
180
   float x, y, z;
 
181
   float s, t;
 
182
} CoglVertexP3T2;
 
183
 
 
184
 
 
185
/**
 
186
 * CoglVertexP2T2C4:
 
187
 * @x: The x component of a position attribute
 
188
 * @y: The y component of a position attribute
 
189
 * @s: The s component of a texture coordinate attribute
 
190
 * @t: The t component of a texture coordinate attribute
 
191
 * @r: The red component of a color attribute
 
192
 * @b: The green component of a color attribute
 
193
 * @g: The blue component of a color attribute
 
194
 * @a: The alpha component of a color attribute
 
195
 *
 
196
 * A convenience vertex definition that can be used with
 
197
 * cogl_primitive_new_p3t2c4().
 
198
 *
 
199
 * Since: 1.6
 
200
 * Stability: Unstable
 
201
 */
 
202
typedef struct {
 
203
   float x, y;
 
204
   float s, t;
 
205
   uint8_t r, g, b, a;
 
206
} CoglVertexP2T2C4;
 
207
 
 
208
/**
 
209
 * CoglVertexP3T2C4:
 
210
 * @x: The x component of a position attribute
 
211
 * @y: The y component of a position attribute
 
212
 * @z: The z component of a position attribute
 
213
 * @s: The s component of a texture coordinate attribute
 
214
 * @t: The t component of a texture coordinate attribute
 
215
 * @r: The red component of a color attribute
 
216
 * @b: The green component of a color attribute
 
217
 * @g: The blue component of a color attribute
 
218
 * @a: The alpha component of a color attribute
 
219
 *
 
220
 * A convenience vertex definition that can be used with
 
221
 * cogl_primitive_new_p3t2c4().
 
222
 *
 
223
 * Since: 1.6
 
224
 * Stability: Unstable
 
225
 */
 
226
typedef struct {
 
227
   float x, y, z;
 
228
   float s, t;
 
229
   uint8_t r, g, b, a;
 
230
} CoglVertexP3T2C4;
 
231
 
 
232
/**
 
233
 * cogl_primitive_new:
 
234
 * @mode: A #CoglVerticesMode defining how to draw the vertices
 
235
 * @n_vertices: The number of vertices to process when drawing
 
236
 * @...: A %NULL terminated list of attributes
 
237
 *
 
238
 * Combines a set of #CoglAttribute<!-- -->s with a specific draw @mode
 
239
 * and defines a vertex count so a #CoglPrimitive object can be retained and
 
240
 * drawn later with no addition information required.
 
241
 *
 
242
 * The value passed as @n_vertices will simply update the
 
243
 * #CoglPrimitive <structfield>n_vertices</structfield> property as if
 
244
 * cogl_primitive_set_n_vertices() were called. This property defines
 
245
 * the number of vertices to read when drawing.
 
246
 *
 
247
 * Return value: (transfer full): A newly allocated #CoglPrimitive object
 
248
 *
 
249
 * Since: 1.6
 
250
 * Stability: Unstable
 
251
 */
 
252
CoglPrimitive *
 
253
cogl_primitive_new (CoglVerticesMode mode,
 
254
                    int n_vertices,
 
255
                    ...);
 
256
 
 
257
/**
 
258
 * cogl_primitive_new_with_attributes: (skip)
 
259
 * @mode: A #CoglVerticesMode defining how to draw the vertices
 
260
 * @n_vertices: The number of vertices to process when drawing
 
261
 * @attributes: An array of CoglAttribute
 
262
 * @n_attributes: The number of attributes
 
263
 *
 
264
 * Combines a set of #CoglAttribute<!-- -->s with a specific draw @mode
 
265
 * and defines a vertex count so a #CoglPrimitive object can be retained and
 
266
 * drawn later with no addition information required.
 
267
 *
 
268
 * The value passed as @n_vertices will simply update the
 
269
 * #CoglPrimitive <structfield>n_vertices</structfield> property as if
 
270
 * cogl_primitive_set_n_vertices() were called. This property defines
 
271
 * the number of vertices to read when drawing.
 
272
 *
 
273
 * Return value: (transfer full): A newly allocated #CoglPrimitive object
 
274
 *
 
275
 * Since: 1.6
 
276
 * Stability: Unstable
 
277
 */
 
278
CoglPrimitive *
 
279
cogl_primitive_new_with_attributes (CoglVerticesMode mode,
 
280
                                    int n_vertices,
 
281
                                    CoglAttribute **attributes,
 
282
                                    int n_attributes);
 
283
 
 
284
/**
 
285
 * cogl_primitive_new_p2: (skip)
 
286
 * @context: A #CoglContext
 
287
 * @mode: A #CoglVerticesMode defining how to draw the vertices
 
288
 * @n_vertices: The number of vertices to read from @data and also
 
289
 *              the number of vertices to read when later drawing.
 
290
 * @data: (array length=n_vertices): (type Cogl.VertexP2): An array
 
291
 *        of #CoglVertexP2 vertices
 
292
 *
 
293
 * Provides a convenient way to describe a primitive, such as a single
 
294
 * triangle strip or a triangle fan, that will internally allocate the
 
295
 * necessary #CoglAttributeBuffer storage, describe the position
 
296
 * attribute with a #CoglAttribute and upload your data.
 
297
 *
 
298
 * For example to draw a convex polygon you can do:
 
299
 * |[
 
300
 * CoglVertexP2 triangle[] =
 
301
 * {
 
302
 *   { 0,   300 },
 
303
 *   { 150, 0,  },
 
304
 *   { 300, 300 }
 
305
 * };
 
306
 * prim = cogl_primitive_new_p2 (COGL_VERTICES_MODE_TRIANGLE_FAN,
 
307
 *                               3, triangle);
 
308
 * cogl_primitive_draw (prim);
 
309
 * ]|
 
310
 *
 
311
 * The value passed as @n_vertices is initially used to determine how
 
312
 * much can be read from @data but it will also be used to update the
 
313
 * #CoglPrimitive <structfield>n_vertices</structfield> property as if
 
314
 * cogl_primitive_set_n_vertices() were called. This property defines
 
315
 * the number of vertices to read when drawing.
 
316
 
 
317
 * <note>The primitive API doesn't support drawing with sliced
 
318
 * textures (since switching between slices implies changing state and
 
319
 * so that implies multiple primitives need to be submitted). You
 
320
 * should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
 
321
 * might be used while drawing with this API. If your hardware doesn't
 
322
 * support non-power of two textures (For example you are using GLES
 
323
 * 1.1) then you will need to make sure your assets are resized to a
 
324
 * power-of-two size (though they don't have to be square)</note>
 
325
 *
 
326
 * Return value: (transfer full): A newly allocated #CoglPrimitive
 
327
 * with a reference of 1. This can be freed using cogl_object_unref().
 
328
 *
 
329
 * Since: 1.6
 
330
 * Stability: Unstable
 
331
 */
 
332
CoglPrimitive *
 
333
cogl_primitive_new_p2 (CoglContext *context,
 
334
                       CoglVerticesMode mode,
 
335
                       int n_vertices,
 
336
                       const CoglVertexP2 *data);
 
337
 
 
338
/**
 
339
 * cogl_primitive_new_p3: (skip)
 
340
 * @context: A #CoglContext
 
341
 * @mode: A #CoglVerticesMode defining how to draw the vertices
 
342
 * @n_vertices: The number of vertices to read from @data and also
 
343
 *              the number of vertices to read when later drawing.
 
344
 * @data: (array length=n_vertices): (type Cogl.VertexP3): An array of
 
345
 *        #CoglVertexP3 vertices
 
346
 *
 
347
 * Provides a convenient way to describe a primitive, such as a single
 
348
 * triangle strip or a triangle fan, that will internally allocate the
 
349
 * necessary #CoglAttributeBuffer storage, describe the position
 
350
 * attribute with a #CoglAttribute and upload your data.
 
351
 *
 
352
 * For example to draw a convex polygon you can do:
 
353
 * |[
 
354
 * CoglVertexP3 triangle[] =
 
355
 * {
 
356
 *   { 0,   300, 0 },
 
357
 *   { 150, 0,   0 },
 
358
 *   { 300, 300, 0 }
 
359
 * };
 
360
 * prim = cogl_primitive_new_p3 (COGL_VERTICES_MODE_TRIANGLE_FAN,
 
361
 *                               3, triangle);
 
362
 * cogl_primitive_draw (prim);
 
363
 * ]|
 
364
 *
 
365
 * The value passed as @n_vertices is initially used to determine how
 
366
 * much can be read from @data but it will also be used to update the
 
367
 * #CoglPrimitive <structfield>n_vertices</structfield> property as if
 
368
 * cogl_primitive_set_n_vertices() were called. This property defines
 
369
 * the number of vertices to read when drawing.
 
370
 
 
371
 * <note>The primitive API doesn't support drawing with sliced
 
372
 * textures (since switching between slices implies changing state and
 
373
 * so that implies multiple primitives need to be submitted). You
 
374
 * should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
 
375
 * might be used while drawing with this API. If your hardware doesn't
 
376
 * support non-power of two textures (For example you are using GLES
 
377
 * 1.1) then you will need to make sure your assets are resized to a
 
378
 * power-of-two size (though they don't have to be square)</note>
 
379
 *
 
380
 * Return value: (transfer full): A newly allocated #CoglPrimitive
 
381
 * with a reference of 1. This can be freed using cogl_object_unref().
 
382
 *
 
383
 * Since: 1.6
 
384
 * Stability: Unstable
 
385
 */
 
386
CoglPrimitive *
 
387
cogl_primitive_new_p3 (CoglContext *context,
 
388
                       CoglVerticesMode mode,
 
389
                       int n_vertices,
 
390
                       const CoglVertexP3 *data);
 
391
 
 
392
/**
 
393
 * cogl_primitive_new_p2c4: (skip)
 
394
 * @context: A #CoglContext
 
395
 * @mode: A #CoglVerticesMode defining how to draw the vertices
 
396
 * @n_vertices: The number of vertices to read from @data and also
 
397
 *              the number of vertices to read when later drawing.
 
398
 * @data: (array length=n_vertices): (type Cogl.VertexP2C4): An array
 
399
 *        of #CoglVertexP2C4 vertices
 
400
 *
 
401
 * Provides a convenient way to describe a primitive, such as a single
 
402
 * triangle strip or a triangle fan, that will internally allocate the
 
403
 * necessary #CoglAttributeBuffer storage, describe the position
 
404
 * and color attributes with #CoglAttribute<!-- -->s and upload
 
405
 * your data.
 
406
 *
 
407
 * For example to draw a convex polygon with a linear gradient you
 
408
 * can do:
 
409
 * |[
 
410
 * CoglVertexP2C4 triangle[] =
 
411
 * {
 
412
 *   { 0,   300,  0xff, 0x00, 0x00, 0xff },
 
413
 *   { 150, 0,    0x00, 0xff, 0x00, 0xff },
 
414
 *   { 300, 300,  0xff, 0x00, 0x00, 0xff }
 
415
 * };
 
416
 * prim = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
 
417
 *                                 3, triangle);
 
418
 * cogl_primitive_draw (prim);
 
419
 * ]|
 
420
 *
 
421
 * The value passed as @n_vertices is initially used to determine how
 
422
 * much can be read from @data but it will also be used to update the
 
423
 * #CoglPrimitive <structfield>n_vertices</structfield> property as if
 
424
 * cogl_primitive_set_n_vertices() were called. This property defines
 
425
 * the number of vertices to read when drawing.
 
426
 
 
427
 * <note>The primitive API doesn't support drawing with sliced
 
428
 * textures (since switching between slices implies changing state and
 
429
 * so that implies multiple primitives need to be submitted). You
 
430
 * should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
 
431
 * might be used while drawing with this API. If your hardware doesn't
 
432
 * support non-power of two textures (For example you are using GLES
 
433
 * 1.1) then you will need to make sure your assets are resized to a
 
434
 * power-of-two size (though they don't have to be square)</note>
 
435
 *
 
436
 * Return value: (transfer full): A newly allocated #CoglPrimitive
 
437
 * with a reference of 1. This can be freed using cogl_object_unref().
 
438
 *
 
439
 * Since: 1.6
 
440
 * Stability: Unstable
 
441
 */
 
442
CoglPrimitive *
 
443
cogl_primitive_new_p2c4 (CoglContext *context,
 
444
                         CoglVerticesMode mode,
 
445
                         int n_vertices,
 
446
                         const CoglVertexP2C4 *data);
 
447
 
 
448
/**
 
449
 * cogl_primitive_new_p3c4: (skip)
 
450
 * @context: A #CoglContext
 
451
 * @mode: A #CoglVerticesMode defining how to draw the vertices
 
452
 * @n_vertices: The number of vertices to read from @data and also
 
453
 *              the number of vertices to read when later drawing.
 
454
 * @data: (array length=n_vertices): (type Cogl.VertexP3C4): An array
 
455
 *        of #CoglVertexP3C4 vertices
 
456
 *
 
457
 * Provides a convenient way to describe a primitive, such as a single
 
458
 * triangle strip or a triangle fan, that will internally allocate the
 
459
 * necessary #CoglAttributeBuffer storage, describe the position
 
460
 * and color attributes with #CoglAttribute<!-- -->s and upload
 
461
 * your data.
 
462
 *
 
463
 * For example to draw a convex polygon with a linear gradient you
 
464
 * can do:
 
465
 * |[
 
466
 * CoglVertexP3C4 triangle[] =
 
467
 * {
 
468
 *   { 0,   300, 0,  0xff, 0x00, 0x00, 0xff },
 
469
 *   { 150, 0,   0,  0x00, 0xff, 0x00, 0xff },
 
470
 *   { 300, 300, 0,  0xff, 0x00, 0x00, 0xff }
 
471
 * };
 
472
 * prim = cogl_primitive_new_p3c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
 
473
 *                                 3, triangle);
 
474
 * cogl_primitive_draw (prim);
 
475
 * ]|
 
476
 *
 
477
 * The value passed as @n_vertices is initially used to determine how
 
478
 * much can be read from @data but it will also be used to update the
 
479
 * #CoglPrimitive <structfield>n_vertices</structfield> property as if
 
480
 * cogl_primitive_set_n_vertices() were called. This property defines
 
481
 * the number of vertices to read when drawing.
 
482
 
 
483
 * <note>The primitive API doesn't support drawing with sliced
 
484
 * textures (since switching between slices implies changing state and
 
485
 * so that implies multiple primitives need to be submitted). You
 
486
 * should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
 
487
 * might be used while drawing with this API. If your hardware doesn't
 
488
 * support non-power of two textures (For example you are using GLES
 
489
 * 1.1) then you will need to make sure your assets are resized to a
 
490
 * power-of-two size (though they don't have to be square)</note>
 
491
 *
 
492
 * Return value: (transfer full): A newly allocated #CoglPrimitive
 
493
 * with a reference of 1. This can be freed using cogl_object_unref().
 
494
 *
 
495
 * Since: 1.6
 
496
 * Stability: Unstable
 
497
 */
 
498
CoglPrimitive *
 
499
cogl_primitive_new_p3c4 (CoglContext *context,
 
500
                         CoglVerticesMode mode,
 
501
                         int n_vertices,
 
502
                         const CoglVertexP3C4 *data);
 
503
 
 
504
/**
 
505
 * cogl_primitive_new_p2t2: (skip)
 
506
 * @context: A #CoglContext
 
507
 * @mode: A #CoglVerticesMode defining how to draw the vertices
 
508
 * @n_vertices: The number of vertices to read from @data and also
 
509
 *              the number of vertices to read when later drawing.
 
510
 * @data: (array length=n_vertices): (type Cogl.VertexP2T2): An array
 
511
 *        of #CoglVertexP2T2 vertices
 
512
 *
 
513
 * Provides a convenient way to describe a primitive, such as a single
 
514
 * triangle strip or a triangle fan, that will internally allocate the
 
515
 * necessary #CoglAttributeBuffer storage, describe the position and
 
516
 * texture coordinate attributes with #CoglAttribute<!-- -->s and
 
517
 * upload your data.
 
518
 *
 
519
 * For example to draw a convex polygon with texture mapping you can
 
520
 * do:
 
521
 * |[
 
522
 * CoglVertexP2T2 triangle[] =
 
523
 * {
 
524
 *   { 0,   300,  0.0, 1.0},
 
525
 *   { 150, 0,    0.5, 0.0},
 
526
 *   { 300, 300,  1.0, 1.0}
 
527
 * };
 
528
 * prim = cogl_primitive_new_p2t2 (COGL_VERTICES_MODE_TRIANGLE_FAN,
 
529
 *                                 3, triangle);
 
530
 * cogl_primitive_draw (prim);
 
531
 * ]|
 
532
 *
 
533
 * The value passed as @n_vertices is initially used to determine how
 
534
 * much can be read from @data but it will also be used to update the
 
535
 * #CoglPrimitive <structfield>n_vertices</structfield> property as if
 
536
 * cogl_primitive_set_n_vertices() were called. This property defines
 
537
 * the number of vertices to read when drawing.
 
538
 
 
539
 * <note>The primitive API doesn't support drawing with sliced
 
540
 * textures (since switching between slices implies changing state and
 
541
 * so that implies multiple primitives need to be submitted). You
 
542
 * should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
 
543
 * might be used while drawing with this API. If your hardware doesn't
 
544
 * support non-power of two textures (For example you are using GLES
 
545
 * 1.1) then you will need to make sure your assets are resized to a
 
546
 * power-of-two size (though they don't have to be square)</note>
 
547
 *
 
548
 * Return value: (transfer full): A newly allocated #CoglPrimitive
 
549
 * with a reference of 1. This can be freed using cogl_object_unref().
 
550
 *
 
551
 * Since: 1.6
 
552
 * Stability: Unstable
 
553
 */
 
554
CoglPrimitive *
 
555
cogl_primitive_new_p2t2 (CoglContext *context,
 
556
                         CoglVerticesMode mode,
 
557
                         int n_vertices,
 
558
                         const CoglVertexP2T2 *data);
 
559
 
 
560
/**
 
561
 * cogl_primitive_new_p3t2: (skip)
 
562
 * @context: A #CoglContext
 
563
 * @mode: A #CoglVerticesMode defining how to draw the vertices
 
564
 * @n_vertices: The number of vertices to read from @data and also
 
565
 *              the number of vertices to read when later drawing.
 
566
 * @data: (array length=n_vertices): (type Cogl.VertexP3T2): An array
 
567
 *        of #CoglVertexP3T2 vertices
 
568
 *
 
569
 * Provides a convenient way to describe a primitive, such as a single
 
570
 * triangle strip or a triangle fan, that will internally allocate the
 
571
 * necessary #CoglAttributeBuffer storage, describe the position and
 
572
 * texture coordinate attributes with #CoglAttribute<!-- -->s and
 
573
 * upload your data.
 
574
 *
 
575
 * For example to draw a convex polygon with texture mapping you can
 
576
 * do:
 
577
 * |[
 
578
 * CoglVertexP3T2 triangle[] =
 
579
 * {
 
580
 *   { 0,   300, 0,  0.0, 1.0},
 
581
 *   { 150, 0,   0,  0.5, 0.0},
 
582
 *   { 300, 300, 0,  1.0, 1.0}
 
583
 * };
 
584
 * prim = cogl_primitive_new_p3t2 (COGL_VERTICES_MODE_TRIANGLE_FAN,
 
585
 *                                 3, triangle);
 
586
 * cogl_primitive_draw (prim);
 
587
 * ]|
 
588
 *
 
589
 * The value passed as @n_vertices is initially used to determine how
 
590
 * much can be read from @data but it will also be used to update the
 
591
 * #CoglPrimitive <structfield>n_vertices</structfield> property as if
 
592
 * cogl_primitive_set_n_vertices() were called. This property defines
 
593
 * the number of vertices to read when drawing.
 
594
 
 
595
 * <note>The primitive API doesn't support drawing with sliced
 
596
 * textures (since switching between slices implies changing state and
 
597
 * so that implies multiple primitives need to be submitted). You
 
598
 * should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
 
599
 * might be used while drawing with this API. If your hardware doesn't
 
600
 * support non-power of two textures (For example you are using GLES
 
601
 * 1.1) then you will need to make sure your assets are resized to a
 
602
 * power-of-two size (though they don't have to be square)</note>
 
603
 *
 
604
 * Return value: (transfer full): A newly allocated #CoglPrimitive
 
605
 * with a reference of 1. This can be freed using cogl_object_unref().
 
606
 *
 
607
 * Since: 1.6
 
608
 * Stability: Unstable
 
609
 */
 
610
CoglPrimitive *
 
611
cogl_primitive_new_p3t2 (CoglContext *context,
 
612
                         CoglVerticesMode mode,
 
613
                         int n_vertices,
 
614
                         const CoglVertexP3T2 *data);
 
615
 
 
616
/**
 
617
 * cogl_primitive_new_p2t2c4: (skip)
 
618
 * @context: A #CoglContext
 
619
 * @mode: A #CoglVerticesMode defining how to draw the vertices
 
620
 * @n_vertices: The number of vertices to read from @data and also
 
621
 *              the number of vertices to read when later drawing.
 
622
 * @data: (array length=n_vertices): (type Cogl.VertexP2T2C4): An
 
623
 *        array of #CoglVertexP2T2C4 vertices
 
624
 *
 
625
 * Provides a convenient way to describe a primitive, such as a single
 
626
 * triangle strip or a triangle fan, that will internally allocate the
 
627
 * necessary #CoglAttributeBuffer storage, describe the position, texture
 
628
 * coordinate and color attributes with #CoglAttribute<!-- -->s and
 
629
 * upload your data.
 
630
 *
 
631
 * For example to draw a convex polygon with texture mapping and a
 
632
 * linear gradient you can do:
 
633
 * |[
 
634
 * CoglVertexP2T2C4 triangle[] =
 
635
 * {
 
636
 *   { 0,   300,  0.0, 1.0,  0xff, 0x00, 0x00, 0xff},
 
637
 *   { 150, 0,    0.5, 0.0,  0x00, 0xff, 0x00, 0xff},
 
638
 *   { 300, 300,  1.0, 1.0,  0xff, 0x00, 0x00, 0xff}
 
639
 * };
 
640
 * prim = cogl_primitive_new_p2t2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
 
641
 *                                   3, triangle);
 
642
 * cogl_primitive_draw (prim);
 
643
 * ]|
 
644
 *
 
645
 * The value passed as @n_vertices is initially used to determine how
 
646
 * much can be read from @data but it will also be used to update the
 
647
 * #CoglPrimitive <structfield>n_vertices</structfield> property as if
 
648
 * cogl_primitive_set_n_vertices() were called. This property defines
 
649
 * the number of vertices to read when drawing.
 
650
 
 
651
 * <note>The primitive API doesn't support drawing with sliced
 
652
 * textures (since switching between slices implies changing state and
 
653
 * so that implies multiple primitives need to be submitted). You
 
654
 * should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
 
655
 * might be used while drawing with this API. If your hardware doesn't
 
656
 * support non-power of two textures (For example you are using GLES
 
657
 * 1.1) then you will need to make sure your assets are resized to a
 
658
 * power-of-two size (though they don't have to be square)</note>
 
659
 *
 
660
 * Return value: (transfer full): A newly allocated #CoglPrimitive
 
661
 * with a reference of 1. This can be freed using cogl_object_unref().
 
662
 *
 
663
 * Since: 1.6
 
664
 * Stability: Unstable
 
665
 */
 
666
CoglPrimitive *
 
667
cogl_primitive_new_p2t2c4 (CoglContext *context,
 
668
                           CoglVerticesMode mode,
 
669
                           int n_vertices,
 
670
                           const CoglVertexP2T2C4 *data);
 
671
 
 
672
/**
 
673
 * cogl_primitive_new_p3t2c4: (skip)
 
674
 * @context: A #CoglContext
 
675
 * @mode: A #CoglVerticesMode defining how to draw the vertices
 
676
 * @n_vertices: The number of vertices to read from @data and also
 
677
 *              the number of vertices to read when later drawing.
 
678
 * @data: (array length=n_vertices): (type Cogl.VertexP3T2C4): An
 
679
 *        array of #CoglVertexP3T2C4 vertices
 
680
 *
 
681
 * Provides a convenient way to describe a primitive, such as a single
 
682
 * triangle strip or a triangle fan, that will internally allocate the
 
683
 * necessary #CoglAttributeBuffer storage, describe the position, texture
 
684
 * coordinate and color attributes with #CoglAttribute<!-- -->s and
 
685
 * upload your data.
 
686
 *
 
687
 * For example to draw a convex polygon with texture mapping and a
 
688
 * linear gradient you can do:
 
689
 * |[
 
690
 * CoglVertexP3T2C4 triangle[] =
 
691
 * {
 
692
 *   { 0,   300, 0,  0.0, 1.0,  0xff, 0x00, 0x00, 0xff},
 
693
 *   { 150, 0,   0,  0.5, 0.0,  0x00, 0xff, 0x00, 0xff},
 
694
 *   { 300, 300, 0,  1.0, 1.0,  0xff, 0x00, 0x00, 0xff}
 
695
 * };
 
696
 * prim = cogl_primitive_new_p3t2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
 
697
 *                                   3, triangle);
 
698
 * cogl_primitive_draw (prim);
 
699
 * ]|
 
700
 *
 
701
 * The value passed as @n_vertices is initially used to determine how
 
702
 * much can be read from @data but it will also be used to update the
 
703
 * #CoglPrimitive <structfield>n_vertices</structfield> property as if
 
704
 * cogl_primitive_set_n_vertices() were called. This property defines
 
705
 * the number of vertices to read when drawing.
 
706
 
 
707
 * <note>The primitive API doesn't support drawing with sliced
 
708
 * textures (since switching between slices implies changing state and
 
709
 * so that implies multiple primitives need to be submitted). You
 
710
 * should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
 
711
 * might be used while drawing with this API. If your hardware doesn't
 
712
 * support non-power of two textures (For example you are using GLES
 
713
 * 1.1) then you will need to make sure your assets are resized to a
 
714
 * power-of-two size (though they don't have to be square)</note>
 
715
 *
 
716
 * Return value: (transfer full): A newly allocated #CoglPrimitive
 
717
 * with a reference of 1. This can be freed using cogl_object_unref().
 
718
 *
 
719
 * Since: 1.6
 
720
 * Stability: Unstable
 
721
 */
 
722
CoglPrimitive *
 
723
cogl_primitive_new_p3t2c4 (CoglContext *context,
 
724
                           CoglVerticesMode mode,
 
725
                           int n_vertices,
 
726
                           const CoglVertexP3T2C4 *data);
 
727
int
 
728
cogl_primitive_get_first_vertex (CoglPrimitive *primitive);
 
729
 
 
730
void
 
731
cogl_primitive_set_first_vertex (CoglPrimitive *primitive,
 
732
                                 int first_vertex);
 
733
 
 
734
/**
 
735
 * cogl_primitive_get_n_vertices:
 
736
 * @primitive: A #CoglPrimitive object
 
737
 *
 
738
 * Queries the number of vertices to read when drawing the given
 
739
 * @primitive. Usually this value is implicitly set when associating
 
740
 * vertex data or indices with a #CoglPrimitive.
 
741
 *
 
742
 * If cogl_primitive_set_indices() has been used to associate a
 
743
 * sequence of #CoglIndices with the given @primitive then the
 
744
 * number of vertices to read can also be phrased as the number
 
745
 * of indices to read.
 
746
 *
 
747
 * <note>To be clear; it doesn't refer to the number of vertices - in
 
748
 * terms of data - associated with the primitive it's just the number
 
749
 * of vertices to read and draw.</note>
 
750
 *
 
751
 * Returns: The number of vertices to read when drawing.
 
752
 *
 
753
 * Since: 1.8
 
754
 * Stability: unstable
 
755
 */
 
756
int
 
757
cogl_primitive_get_n_vertices (CoglPrimitive *primitive);
 
758
 
 
759
/**
 
760
 * cogl_primitive_set_n_vertices:
 
761
 * @primitive: A #CoglPrimitive object
 
762
 * @n_vertices: The number of vertices to read when drawing.
 
763
 *
 
764
 * Specifies how many vertices should be read when drawing the given
 
765
 * @primitive.
 
766
 *
 
767
 * Usually this value is set implicitly when associating vertex data
 
768
 * or indices with a #CoglPrimitive.
 
769
 *
 
770
 * <note>To be clear; it doesn't refer to the number of vertices - in
 
771
 * terms of data - associated with the primitive it's just the number
 
772
 * of vertices to read and draw.</note>
 
773
 *
 
774
 * Since: 1.8
 
775
 * Stability: unstable
 
776
 */
 
777
void
 
778
cogl_primitive_set_n_vertices (CoglPrimitive *primitive,
 
779
                               int n_vertices);
 
780
 
 
781
CoglVerticesMode
 
782
cogl_primitive_get_mode (CoglPrimitive *primitive);
 
783
 
 
784
void
 
785
cogl_primitive_set_mode (CoglPrimitive *primitive,
 
786
                         CoglVerticesMode mode);
 
787
 
 
788
/**
 
789
 * cogl_primitive_set_attributes: (skip)
 
790
 * @primitive: A #CoglPrimitive object
 
791
 * @attributes: an array of #CoglAttribute pointers
 
792
 * @n_attributes: the number of elements in @attributes
 
793
 *
 
794
 * Replaces all the attributes of the given #CoglPrimitive object.
 
795
 *
 
796
 * Since: 1.6
 
797
 * Stability: Unstable
 
798
 */
 
799
void
 
800
cogl_primitive_set_attributes (CoglPrimitive *primitive,
 
801
                               CoglAttribute **attributes,
 
802
                               int n_attributes);
 
803
 
 
804
/**
 
805
 * cogl_primitive_set_indices: (skip)
 
806
 * @primitive: A #CoglPrimitive
 
807
 * @indices: A #CoglIndices array
 
808
 * @n_indices: The number of indices to reference when drawing
 
809
 *
 
810
 * Associates a sequence of #CoglIndices with the given @primitive.
 
811
 *
 
812
 * #CoglIndices provide a way to virtualize your real vertex data by
 
813
 * providing a sequence of indices that index into your real vertex
 
814
 * data. The GPU will walk though the index values to indirectly
 
815
 * lookup the data for each vertex instead of sequentially walking
 
816
 * through the data directly. This lets you save memory by indexing
 
817
 * shared data multiple times instead of duplicating the data.
 
818
 *
 
819
 * The value passed as @n_indices will simply update the
 
820
 * #CoglPrimitive <structfield>n_vertices</structfield> property as if
 
821
 * cogl_primitive_set_n_vertices() were called. This property defines
 
822
 * the number of vertices to draw or, put another way, how many
 
823
 * indices should be read from @indices when drawing.
 
824
 *
 
825
 * <note>The #CoglPrimitive <structfield>first_vertex</structfield> property
 
826
 * also affects drawing with indices by defining the first entry of the
 
827
 * indices to start drawing from.</note>
 
828
 *
 
829
 * Since: 1.10
 
830
 * Stability: unstable
 
831
 */
 
832
void
 
833
cogl_primitive_set_indices (CoglPrimitive *primitive,
 
834
                            CoglIndices *indices,
 
835
                            int n_indices);
 
836
 
 
837
/**
 
838
 * cogl_primitive_get_indices: (skip)
 
839
 * @primitive: A #CoglPrimitive
 
840
 *
 
841
 * Return value: (transfer none): the indices that were set with
 
842
 * cogl_primitive_set_indices() or %NULL if no indices were set.
 
843
 *
 
844
 * Since: 1.10
 
845
 * Stability: unstable
 
846
 */
 
847
CoglIndices *
 
848
cogl_primitive_get_indices (CoglPrimitive *primitive);
 
849
 
 
850
/**
 
851
 * cogl_primitive_copy:
 
852
 * @primitive: A primitive copy
 
853
 *
 
854
 * Makes a copy of an existing #CoglPrimitive. Note that the primitive
 
855
 * is a shallow copy which means it will use the same attributes and
 
856
 * attribute buffers as the original primitive.
 
857
 *
 
858
 * Return value: (transfer full): the new primitive
 
859
 * Since: 1.10
 
860
 * Stability: unstable
 
861
 */
 
862
CoglPrimitive *
 
863
cogl_primitive_copy (CoglPrimitive *primitive);
 
864
 
 
865
/**
 
866
 * cogl_is_primitive:
 
867
 * @object: A #CoglObject
 
868
 *
 
869
 * Gets whether the given object references a #CoglPrimitive.
 
870
 *
 
871
 * Returns: %TRUE if the @object references a #CoglPrimitive,
 
872
 *   %FALSE otherwise
 
873
 *
 
874
 * Since: 1.6
 
875
 * Stability: Unstable
 
876
 */
 
877
CoglBool
 
878
cogl_is_primitive (void *object);
 
879
 
 
880
/**
 
881
 * CoglPrimitiveAttributeCallback:
 
882
 * @primitive: The #CoglPrimitive whose attributes are being iterated
 
883
 * @attribute: The #CoglAttribute
 
884
 * @user_data: The private data passed to cogl_primitive_foreach_attribute()
 
885
 *
 
886
 * The callback prototype used with cogl_primitive_foreach_attribute()
 
887
 * for iterating all the attributes of a #CoglPrimitive.
 
888
 *
 
889
 * The function should return TRUE to continue iteration or FALSE to
 
890
 * stop.
 
891
 *
 
892
 * Since: 1.10
 
893
 * Stability: Unstable
 
894
 */
 
895
typedef CoglBool (* CoglPrimitiveAttributeCallback) (CoglPrimitive *primitive,
 
896
                                                     CoglAttribute *attribute,
 
897
                                                     void *user_data);
 
898
 
 
899
/**
 
900
 * cogl_primitive_foreach_attribute:
 
901
 * @primitive: A #CoglPrimitive object
 
902
 * @callback: (scope call): A #CoglPrimitiveAttributeCallback to be
 
903
 *            called for each attribute
 
904
 * @user_data: (closure): Private data that will be passed to the
 
905
 *             callback
 
906
 *
 
907
 * Iterates all the attributes of the given #CoglPrimitive.
 
908
 *
 
909
 * Since: 1.10
 
910
 * Stability: Unstable
 
911
 */
 
912
void
 
913
cogl_primitive_foreach_attribute (CoglPrimitive *primitive,
 
914
                                  CoglPrimitiveAttributeCallback callback,
 
915
                                  void *user_data);
 
916
 
 
917
/**
 
918
 * cogl_primitive_draw: (skip)
 
919
 * @primitive: A #CoglPrimitive geometry object
 
920
 * @framebuffer: A destination #CoglFramebuffer
 
921
 * @pipeline: A #CoglPipeline state object
 
922
 *
 
923
 * Draws the given @primitive geometry to the specified destination
 
924
 * @framebuffer using the graphics processing state described by @pipeline.
 
925
 *
 
926
 * This drawing api doesn't support high-level meta texture types such
 
927
 * as #CoglTexture2DSliced so it is the user's responsibility to
 
928
 * ensure that only low-level textures that can be directly sampled by
 
929
 * a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D
 
930
 * are associated with layers of the given @pipeline.
 
931
 *
 
932
 * Stability: unstable
 
933
 * Since: 1.16
 
934
 */
 
935
void
 
936
cogl_primitive_draw (CoglPrimitive *primitive,
 
937
                     CoglFramebuffer *framebuffer,
 
938
                     CoglPipeline *pipeline);
 
939
 
 
940
 
 
941
COGL_END_DECLS
 
942
 
 
943
#endif /* __COGL_PRIMITIVE_H__ */
 
944