4
* A Low Level GPU Graphics and Utilities API
6
* Copyright (C) 2010 Intel Corporation.
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:
16
* The above copyright notice and this permission notice shall be
17
* included in all copies or substantial portions of the Software.
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
31
* Robert Bragg <robert@linux.intel.com>
34
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
35
#error "Only <cogl/cogl.h> can be included directly."
38
#ifndef __COGL_PRIMITIVE_H__
39
#define __COGL_PRIMITIVE_H__
41
/* We forward declare the CoglPrimitive type here to avoid some circular
42
* dependency issues with the following headers.
44
typedef struct _CoglPrimitive CoglPrimitive;
46
#include <cogl/cogl-types.h> /* for CoglVerticesMode */
47
#include <cogl/cogl-attribute.h>
48
#include <cogl/cogl-framebuffer.h>
50
#include <glib-object.h>
55
* SECTION:cogl-primitive
56
* @short_description: Functions for creating, manipulating and drawing
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)
69
* cogl_primitive_get_gtype:
71
* Returns: a #GType that can be used with the GLib type system.
73
GType cogl_primitive_get_gtype (void);
77
* @x: The x component of a position attribute
78
* @y: The y component of a position attribute
80
* A convenience vertex definition that can be used with
81
* cogl_primitive_new_p2().
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
96
* A convenience vertex definition that can be used with
97
* cogl_primitive_new_p3().
100
* Stability: Unstable
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
115
* A convenience vertex definition that can be used with
116
* cogl_primitive_new_p2c4().
119
* Stability: Unstable
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
136
* A convenience vertex definition that can be used with
137
* cogl_primitive_new_p3c4().
140
* Stability: Unstable
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
154
* A convenience vertex definition that can be used with
155
* cogl_primitive_new_p2t2().
158
* Stability: Unstable
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
173
* A convenience vertex definition that can be used with
174
* cogl_primitive_new_p3t2().
177
* Stability: Unstable
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
196
* A convenience vertex definition that can be used with
197
* cogl_primitive_new_p3t2c4().
200
* Stability: Unstable
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
220
* A convenience vertex definition that can be used with
221
* cogl_primitive_new_p3t2c4().
224
* Stability: Unstable
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
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.
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.
247
* Return value: (transfer full): A newly allocated #CoglPrimitive object
250
* Stability: Unstable
253
cogl_primitive_new (CoglVerticesMode mode,
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
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.
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.
273
* Return value: (transfer full): A newly allocated #CoglPrimitive object
276
* Stability: Unstable
279
cogl_primitive_new_with_attributes (CoglVerticesMode mode,
281
CoglAttribute **attributes,
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
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.
298
* For example to draw a convex polygon you can do:
300
* CoglVertexP2 triangle[] =
306
* prim = cogl_primitive_new_p2 (COGL_VERTICES_MODE_TRIANGLE_FAN,
308
* cogl_primitive_draw (prim);
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.
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>
326
* Return value: (transfer full): A newly allocated #CoglPrimitive
327
* with a reference of 1. This can be freed using cogl_object_unref().
330
* Stability: Unstable
333
cogl_primitive_new_p2 (CoglContext *context,
334
CoglVerticesMode mode,
336
const CoglVertexP2 *data);
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
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.
352
* For example to draw a convex polygon you can do:
354
* CoglVertexP3 triangle[] =
360
* prim = cogl_primitive_new_p3 (COGL_VERTICES_MODE_TRIANGLE_FAN,
362
* cogl_primitive_draw (prim);
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.
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>
380
* Return value: (transfer full): A newly allocated #CoglPrimitive
381
* with a reference of 1. This can be freed using cogl_object_unref().
384
* Stability: Unstable
387
cogl_primitive_new_p3 (CoglContext *context,
388
CoglVerticesMode mode,
390
const CoglVertexP3 *data);
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
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
407
* For example to draw a convex polygon with a linear gradient you
410
* CoglVertexP2C4 triangle[] =
412
* { 0, 300, 0xff, 0x00, 0x00, 0xff },
413
* { 150, 0, 0x00, 0xff, 0x00, 0xff },
414
* { 300, 300, 0xff, 0x00, 0x00, 0xff }
416
* prim = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
418
* cogl_primitive_draw (prim);
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.
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>
436
* Return value: (transfer full): A newly allocated #CoglPrimitive
437
* with a reference of 1. This can be freed using cogl_object_unref().
440
* Stability: Unstable
443
cogl_primitive_new_p2c4 (CoglContext *context,
444
CoglVerticesMode mode,
446
const CoglVertexP2C4 *data);
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
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
463
* For example to draw a convex polygon with a linear gradient you
466
* CoglVertexP3C4 triangle[] =
468
* { 0, 300, 0, 0xff, 0x00, 0x00, 0xff },
469
* { 150, 0, 0, 0x00, 0xff, 0x00, 0xff },
470
* { 300, 300, 0, 0xff, 0x00, 0x00, 0xff }
472
* prim = cogl_primitive_new_p3c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
474
* cogl_primitive_draw (prim);
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.
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>
492
* Return value: (transfer full): A newly allocated #CoglPrimitive
493
* with a reference of 1. This can be freed using cogl_object_unref().
496
* Stability: Unstable
499
cogl_primitive_new_p3c4 (CoglContext *context,
500
CoglVerticesMode mode,
502
const CoglVertexP3C4 *data);
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
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
519
* For example to draw a convex polygon with texture mapping you can
522
* CoglVertexP2T2 triangle[] =
524
* { 0, 300, 0.0, 1.0},
525
* { 150, 0, 0.5, 0.0},
526
* { 300, 300, 1.0, 1.0}
528
* prim = cogl_primitive_new_p2t2 (COGL_VERTICES_MODE_TRIANGLE_FAN,
530
* cogl_primitive_draw (prim);
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.
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>
548
* Return value: (transfer full): A newly allocated #CoglPrimitive
549
* with a reference of 1. This can be freed using cogl_object_unref().
552
* Stability: Unstable
555
cogl_primitive_new_p2t2 (CoglContext *context,
556
CoglVerticesMode mode,
558
const CoglVertexP2T2 *data);
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
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
575
* For example to draw a convex polygon with texture mapping you can
578
* CoglVertexP3T2 triangle[] =
580
* { 0, 300, 0, 0.0, 1.0},
581
* { 150, 0, 0, 0.5, 0.0},
582
* { 300, 300, 0, 1.0, 1.0}
584
* prim = cogl_primitive_new_p3t2 (COGL_VERTICES_MODE_TRIANGLE_FAN,
586
* cogl_primitive_draw (prim);
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.
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>
604
* Return value: (transfer full): A newly allocated #CoglPrimitive
605
* with a reference of 1. This can be freed using cogl_object_unref().
608
* Stability: Unstable
611
cogl_primitive_new_p3t2 (CoglContext *context,
612
CoglVerticesMode mode,
614
const CoglVertexP3T2 *data);
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
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
631
* For example to draw a convex polygon with texture mapping and a
632
* linear gradient you can do:
634
* CoglVertexP2T2C4 triangle[] =
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}
640
* prim = cogl_primitive_new_p2t2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
642
* cogl_primitive_draw (prim);
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.
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>
660
* Return value: (transfer full): A newly allocated #CoglPrimitive
661
* with a reference of 1. This can be freed using cogl_object_unref().
664
* Stability: Unstable
667
cogl_primitive_new_p2t2c4 (CoglContext *context,
668
CoglVerticesMode mode,
670
const CoglVertexP2T2C4 *data);
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
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
687
* For example to draw a convex polygon with texture mapping and a
688
* linear gradient you can do:
690
* CoglVertexP3T2C4 triangle[] =
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}
696
* prim = cogl_primitive_new_p3t2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
698
* cogl_primitive_draw (prim);
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.
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>
716
* Return value: (transfer full): A newly allocated #CoglPrimitive
717
* with a reference of 1. This can be freed using cogl_object_unref().
720
* Stability: Unstable
723
cogl_primitive_new_p3t2c4 (CoglContext *context,
724
CoglVerticesMode mode,
726
const CoglVertexP3T2C4 *data);
728
cogl_primitive_get_first_vertex (CoglPrimitive *primitive);
731
cogl_primitive_set_first_vertex (CoglPrimitive *primitive,
735
* cogl_primitive_get_n_vertices:
736
* @primitive: A #CoglPrimitive object
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.
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.
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>
751
* Returns: The number of vertices to read when drawing.
754
* Stability: unstable
757
cogl_primitive_get_n_vertices (CoglPrimitive *primitive);
760
* cogl_primitive_set_n_vertices:
761
* @primitive: A #CoglPrimitive object
762
* @n_vertices: The number of vertices to read when drawing.
764
* Specifies how many vertices should be read when drawing the given
767
* Usually this value is set implicitly when associating vertex data
768
* or indices with a #CoglPrimitive.
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>
775
* Stability: unstable
778
cogl_primitive_set_n_vertices (CoglPrimitive *primitive,
782
cogl_primitive_get_mode (CoglPrimitive *primitive);
785
cogl_primitive_set_mode (CoglPrimitive *primitive,
786
CoglVerticesMode mode);
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
794
* Replaces all the attributes of the given #CoglPrimitive object.
797
* Stability: Unstable
800
cogl_primitive_set_attributes (CoglPrimitive *primitive,
801
CoglAttribute **attributes,
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
810
* Associates a sequence of #CoglIndices with the given @primitive.
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.
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.
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>
830
* Stability: unstable
833
cogl_primitive_set_indices (CoglPrimitive *primitive,
834
CoglIndices *indices,
838
* cogl_primitive_get_indices: (skip)
839
* @primitive: A #CoglPrimitive
841
* Return value: (transfer none): the indices that were set with
842
* cogl_primitive_set_indices() or %NULL if no indices were set.
845
* Stability: unstable
848
cogl_primitive_get_indices (CoglPrimitive *primitive);
851
* cogl_primitive_copy:
852
* @primitive: A primitive copy
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.
858
* Return value: (transfer full): the new primitive
860
* Stability: unstable
863
cogl_primitive_copy (CoglPrimitive *primitive);
867
* @object: A #CoglObject
869
* Gets whether the given object references a #CoglPrimitive.
871
* Returns: %TRUE if the @object references a #CoglPrimitive,
875
* Stability: Unstable
878
cogl_is_primitive (void *object);
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()
886
* The callback prototype used with cogl_primitive_foreach_attribute()
887
* for iterating all the attributes of a #CoglPrimitive.
889
* The function should return TRUE to continue iteration or FALSE to
893
* Stability: Unstable
895
typedef CoglBool (* CoglPrimitiveAttributeCallback) (CoglPrimitive *primitive,
896
CoglAttribute *attribute,
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
907
* Iterates all the attributes of the given #CoglPrimitive.
910
* Stability: Unstable
913
cogl_primitive_foreach_attribute (CoglPrimitive *primitive,
914
CoglPrimitiveAttributeCallback callback,
918
* cogl_primitive_draw: (skip)
919
* @primitive: A #CoglPrimitive geometry object
920
* @framebuffer: A destination #CoglFramebuffer
921
* @pipeline: A #CoglPipeline state object
923
* Draws the given @primitive geometry to the specified destination
924
* @framebuffer using the graphics processing state described by @pipeline.
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.
932
* Stability: unstable
936
cogl_primitive_draw (CoglPrimitive *primitive,
937
CoglFramebuffer *framebuffer,
938
CoglPipeline *pipeline);
943
#endif /* __COGL_PRIMITIVE_H__ */