Support for PangoFT2, PangoCairo, fontconfig2, freetype22, GL, Clutter, ClutterX11...
[girtod.git] / gtk2 / cogl.d
blobe41f69d79bf73ca5ba3b03934afd1806f339c98b
1 // *** DO NOT EDIT ***
2 // Automatically generated from "/usr/share/gir-1.0/Cogl-1.0.gir"
4 module Cogl;
5 public import gtk2.gl;
6 alias gtk2.gl GL;
7 public import gtk2.glib2;
8 alias gtk2.glib2 GLib2;
9 public import gtk2.gobject2;
10 alias gtk2.gobject2 GObject2;
12 // package: "cogl-1.0";
13 // C header: "cogl/cogl.h";
15 // c:symbol-prefixes: ["cogl"]
16 // c:identifier-prefixes: ["Cogl"]
18 // module Cogl;
21 // Integer representation of an angle such that 1024 corresponds to
22 // full circle (i.e., 2 * pi).
23 alias int Angle;
25 // Type used for storing references to cogl objects, the CoglHandle is
26 // a fully opaque type without any public data members.
27 alias void* Handle;
28 enum int AFIRST_BIT = 64;
29 enum int A_BIT = 16;
30 struct Attribute {
32 // Unintrospectable function: new() / cogl_attribute_new()
33 // Describes the layout for a list of vertex attribute values (For
34 // example, a list of texture coordinates or colors).
35 //
36 // The @name is used to access the attribute inside a GLSL vertex
37 // shader and there are some special names you should use if they are
38 // applicable:
39 // <itemizedlist>
40 // <listitem>"cogl_position_in" (used for vertex positions)</listitem>
41 // <listitem>"cogl_color_in" (used for vertex colors)</listitem>
42 // <listitem>"cogl_tex_coord0_in", "cogl_tex_coord1", ...
43 // (used for vertex texture coordinates)</listitem>
44 // <listitem>"cogl_normal_in" (used for vertex normals)</listitem>
45 // </itemizedlist>
46 //
47 // The attribute values corresponding to different vertices can either
48 // be tightly packed or interleaved with other attribute values. For
49 // example it's common to define a structure for a single vertex like:
50 // |[
51 // typedef struct
52 // {
53 // float x, y, z; /<!-- -->* position attribute *<!-- -->/
54 // float s, t; /<!-- -->* texture coordinate attribute *<!-- -->/
55 // } MyVertex;
56 // ]|
57 //
58 // And then create an array of vertex data something like:
59 // |[
60 // MyVertex vertices[100] = { .... }
61 // ]|
62 //
63 // In this case, to describe either the position or texture coordinate
64 // attribute you have to move <pre>sizeof (MyVertex)</pre> bytes to
65 // move from one vertex to the next. This is called the attribute
66 // @stride. If you weren't interleving attributes and you instead had
67 // a packed array of float x, y pairs then the attribute stride would
68 // be <pre>(2 * sizeof (float))</pre>. So the @stride is the number of
69 // bytes to move to find the attribute value of the next vertex.
70 //
71 // Normally a list of attributes starts at the beginning of an array.
72 // So for the <pre>MyVertex</pre> example above the @offset is the
73 // offset inside the <pre>MyVertex</pre> structure to the first
74 // component of the attribute. For the texture coordinate attribute
75 // the offset would be <pre>offsetof (MyVertex, s)</pre> or instead of
76 // using the offsetof macro you could use <pre>sizeof (float) * 3</pre>.
77 // If you've divided your @array into blocks of non-interleved
78 // attributes then you will need to calculate the @offset as the
79 // number of bytes in blocks preceding the attribute you're
80 // describing.
81 //
82 // An attribute often has more than one component. For example a color
83 // is often comprised of 4 red, green, blue and alpha @components, and a
84 // position may be comprised of 2 x and y @components. You should aim
85 // to keep the number of components to a minimum as more components
86 // means more data needs to be mapped into the GPU which can be a
87 // bottlneck when dealing with a large number of vertices.
88 //
89 // Finally you need to specify the component data type. Here you
90 // should aim to use the smallest type that meets your precision
91 // requirements. Again the larger the type then more data needs to be
92 // mapped into the GPU which can be a bottlneck when dealing with
93 // a large number of vertices.
94 //
95 // layout for a list of attribute values stored in @array.
96 // RETURNS: A newly allocated #CoglAttribute describing the
97 // <attribute_buffer>: The #CoglAttributeBuffer containing the actual attribute data
98 // <name>: The name of the attribute (used to reference it from GLSL)
99 // <stride>: The number of bytes to jump to get to the next attribute value for the next vertex. (Usually <pre>sizeof (MyVertex)</pre>)
100 // <offset>: The byte offset from the start of @attribute_buffer for the first attribute value. (Usually <pre>offsetof (MyVertex, component0)</pre>
101 // <components>: The number of components (e.g. 4 for an rgba color or 3 for and (x,y,z) position)
102 // <type>: FIXME
103 static Attribute* new_(AttributeBuffer* attribute_buffer, char* name, size_t stride, size_t offset, int components, AttributeType type) {
104 return cogl_attribute_new(attribute_buffer, name, stride, offset, components, type);
108 struct AttributeBuffer {
110 // Unintrospectable function: new() / cogl_attribute_buffer_new()
111 // Declares a new #CoglAttributeBuffer of @size bytes to contain arrays of vertex
112 // attribute data. Once declared, data can be set using cogl_buffer_set_data()
113 // or by mapping it into the application's address space using cogl_buffer_map().
115 // If @data isn't %NULL then @size bytes will be read from @data and
116 // immediately copied into the new buffer.
117 // <bytes>: The number of bytes to allocate for vertex attribute data.
118 // <data>: An optional pointer to vertex data to upload immediately.
119 static AttributeBuffer* new_(size_t bytes, void* data) {
120 return cogl_attribute_buffer_new(bytes, data);
124 // Data types for the components of a vertex attribute.
125 enum AttributeType /* Version 1.0 */ {
126 BYTE = 5120,
127 UNSIGNED_BYTE = 5121,
128 SHORT = 5122,
129 UNSIGNED_SHORT = 5123,
130 FLOAT = 5126
132 enum int BGR_BIT = 32;
133 struct Bitmap {
135 // Parses an image file enough to extract the width and height
136 // of the bitmap.
137 // RETURNS: %TRUE if the image was successfully parsed
138 // <filename>: the file to check
139 // <width>: return location for the bitmap width, or %NULL
140 // <height>: return location for the bitmap height, or %NULL
141 static int get_size_from_file(char* filename, /*out*/ int* width, /*out*/ int* height) {
142 return cogl_bitmap_get_size_from_file(filename, width, height);
145 // Unintrospectable function: new_from_file() / cogl_bitmap_new_from_file()
146 // Loads an image file from disk. This function can be safely called from
147 // within a thread.
149 // %NULL if loading the image failed.
150 // RETURNS: a #CoglBitmap to the new loaded image data, or
151 // <filename>: the file to load.
152 static Bitmap* new_from_file(char* filename, GLib2.Error** error=null) {
153 return cogl_bitmap_new_from_file(filename, error);
158 // Error codes that can be thrown when performing bitmap
159 // operations. Note that gdk_pixbuf_new_from_file() can also throw
160 // errors directly from the underlying image loading library. For
161 // example, if GdkPixbuf is used then errors #GdkPixbufError<!-- -->s
162 // will be used directly.
163 enum BitmapError /* Version 1.4 */ {
164 FAILED = 0,
165 UNKNOWN_TYPE = 1,
166 CORRUPT_IMAGE = 2
168 // Error enumeration for the blend strings parser
169 enum BlendStringError /* Version 1.0 */ {
170 PARSE_ERROR = 0,
171 ARGUMENT_PARSE_ERROR = 1,
172 INVALID_ERROR = 2,
173 GPU_UNSUPPORTED_ERROR = 3
175 struct Buffer {
176 uint get_size_EXP() {
177 return cogl_buffer_get_size_EXP(&this);
179 BufferUpdateHint get_update_hint_EXP() {
180 return cogl_buffer_get_update_hint_EXP(&this);
182 // Unintrospectable method: map_EXP() / cogl_buffer_map_EXP()
183 void* map_EXP(BufferAccess access, BufferMapHint hints) {
184 return cogl_buffer_map_EXP(&this, access, hints);
186 int set_data_EXP(size_t offset, void* data, size_t size) {
187 return cogl_buffer_set_data_EXP(&this, offset, data, size);
189 void set_update_hint_EXP(BufferUpdateHint hint) {
190 cogl_buffer_set_update_hint_EXP(&this, hint);
192 void unmap_EXP() {
193 cogl_buffer_unmap_EXP(&this);
197 // The access hints for cogl_buffer_set_update_hint()
198 enum BufferAccess /* Version 1.2 */ {
199 READ = 1,
200 WRITE = 2,
201 READ_WRITE = 3
203 // Types of auxiliary buffers
204 enum BufferBit /* Version 1.0 */ {
205 COLOR = 1,
206 DEPTH = 2,
207 STENCIL = 4
210 // Hints to Cogl about how you are planning to modify the data once it
211 // is mapped.
212 enum BufferMapHint /* Version 1.4 */ {
213 DISCARD = 1
215 // Target flags for FBOs.
216 enum BufferTarget /* Version 0.8 */ {
217 WINDOW_BUFFER = 2,
218 OFFSCREEN_BUFFER = 4
221 // The update hint on a buffer allows the user to give some detail on how often
222 // the buffer data is going to be updated.
223 enum BufferUpdateHint /* Version 1.2 */ {
224 STATIC = 0,
225 DYNAMIC = 1,
226 STREAM = 2
229 // A structure for holding a color definition. The contents of
230 // the CoglColor structure are private and should never by accessed
231 // directly.
232 struct Color /* Version 1.0 */ {
233 private ubyte red, green, blue, alpha;
234 private uint padding0, padding1, padding2;
237 // Unintrospectable method: copy() / cogl_color_copy()
238 // Creates a copy of @color
240 // to free the allocate resources
241 // RETURNS: a newly-allocated #CoglColor. Use cogl_color_free()
242 Color* copy() {
243 return cogl_color_copy(&this);
245 // Frees the resources allocated by cogl_color_new() and cogl_color_copy()
246 void free() {
247 cogl_color_free(&this);
250 // Retrieves the alpha channel of @color as a fixed point
251 // value between 0 and %1.0.
252 // RETURNS: the alpha channel of the passed color
253 float get_alpha() {
254 return cogl_color_get_alpha(&this);
257 // Retrieves the alpha channel of @color as a byte value
258 // between 0 and 255
259 // RETURNS: the alpha channel of the passed color
260 ubyte get_alpha_byte() {
261 return cogl_color_get_alpha_byte(&this);
264 // Retrieves the alpha channel of @color as a floating point
265 // value between 0.0 and 1.0
266 // RETURNS: the alpha channel of the passed color
267 float get_alpha_float() {
268 return cogl_color_get_alpha_float(&this);
271 // Retrieves the blue channel of @color as a fixed point
272 // value between 0 and %1.0.
273 // RETURNS: the blue channel of the passed color
274 float get_blue() {
275 return cogl_color_get_blue(&this);
278 // Retrieves the blue channel of @color as a byte value
279 // between 0 and 255
280 // RETURNS: the blue channel of the passed color
281 ubyte get_blue_byte() {
282 return cogl_color_get_blue_byte(&this);
285 // Retrieves the blue channel of @color as a floating point
286 // value between 0.0 and 1.0
287 // RETURNS: the blue channel of the passed color
288 float get_blue_float() {
289 return cogl_color_get_blue_float(&this);
292 // Retrieves the green channel of @color as a fixed point
293 // value between 0 and %1.0.
294 // RETURNS: the green channel of the passed color
295 float get_green() {
296 return cogl_color_get_green(&this);
299 // Retrieves the green channel of @color as a byte value
300 // between 0 and 255
301 // RETURNS: the green channel of the passed color
302 ubyte get_green_byte() {
303 return cogl_color_get_green_byte(&this);
306 // Retrieves the green channel of @color as a floating point
307 // value between 0.0 and 1.0
308 // RETURNS: the green channel of the passed color
309 float get_green_float() {
310 return cogl_color_get_green_float(&this);
313 // Retrieves the red channel of @color as a fixed point
314 // value between 0 and %1.0.
315 // RETURNS: the red channel of the passed color
316 float get_red() {
317 return cogl_color_get_red(&this);
320 // Retrieves the red channel of @color as a byte value
321 // between 0 and 255
322 // RETURNS: the red channel of the passed color
323 ubyte get_red_byte() {
324 return cogl_color_get_red_byte(&this);
327 // Retrieves the red channel of @color as a floating point
328 // value between 0.0 and 1.0
329 // RETURNS: the red channel of the passed color
330 float get_red_float() {
331 return cogl_color_get_red_float(&this);
334 // Sets the values of the passed channels into a #CoglColor
335 // <red>: value of the red channel, between 0 and %1.0
336 // <green>: value of the green channel, between 0 and %1.0
337 // <blue>: value of the blue channel, between 0 and %1.0
338 // <alpha>: value of the alpha channel, between 0 and %1.0
339 void init_from_4f(float red, float green, float blue, float alpha) {
340 cogl_color_init_from_4f(&this, red, green, blue, alpha);
343 // Sets the values of the passed channels into a #CoglColor
344 // <color_array>: a pointer to an array of 4 float color components
345 void init_from_4fv(float* color_array) {
346 cogl_color_init_from_4fv(&this, color_array);
349 // Sets the values of the passed channels into a #CoglColor.
350 // <red>: value of the red channel, between 0 and 255
351 // <green>: value of the green channel, between 0 and 255
352 // <blue>: value of the blue channel, between 0 and 255
353 // <alpha>: value of the alpha channel, between 0 and 255
354 void init_from_4ub(ubyte red, ubyte green, ubyte blue, ubyte alpha) {
355 cogl_color_init_from_4ub(&this, red, green, blue, alpha);
358 // Converts a non-premultiplied color to a pre-multiplied color. For
359 // example, semi-transparent red is (1.0, 0, 0, 0.5) when non-premultiplied
360 // and (0.5, 0, 0, 0.5) when premultiplied.
361 void premultiply() {
362 cogl_color_premultiply(&this);
365 // Sets the alpha channel of @color to @alpha.
366 // <alpha>: a float value between 0.0f and 1.0f
367 void set_alpha(float alpha) {
368 cogl_color_set_alpha(&this, alpha);
371 // Sets the alpha channel of @color to @alpha.
372 // <alpha>: a byte value between 0 and 255
373 void set_alpha_byte(ubyte alpha) {
374 cogl_color_set_alpha_byte(&this, alpha);
377 // Sets the alpha channel of @color to @alpha.
378 // <alpha>: a float value between 0.0f and 1.0f
379 void set_alpha_float(float alpha) {
380 cogl_color_set_alpha_float(&this, alpha);
383 // Sets the blue channel of @color to @blue.
384 // <blue>: a float value between 0.0f and 1.0f
385 void set_blue(float blue) {
386 cogl_color_set_blue(&this, blue);
389 // Sets the blue channel of @color to @blue.
390 // <blue>: a byte value between 0 and 255
391 void set_blue_byte(ubyte blue) {
392 cogl_color_set_blue_byte(&this, blue);
395 // Sets the blue channel of @color to @blue.
396 // <blue>: a float value between 0.0f and 1.0f
397 void set_blue_float(float blue) {
398 cogl_color_set_blue_float(&this, blue);
401 // Sets the values of the passed channels into a #CoglColor
402 // <red>: value of the red channel, between 0 and %1.0
403 // <green>: value of the green channel, between 0 and %1.0
404 // <blue>: value of the blue channel, between 0 and %1.0
405 // <alpha>: value of the alpha channel, between 0 and %1.0
406 void set_from_4f(float red, float green, float blue, float alpha) {
407 cogl_color_set_from_4f(&this, red, green, blue, alpha);
410 // Sets the values of the passed channels into a #CoglColor.
411 // <red>: value of the red channel, between 0 and 255
412 // <green>: value of the green channel, between 0 and 255
413 // <blue>: value of the blue channel, between 0 and 255
414 // <alpha>: value of the alpha channel, between 0 and 255
415 void set_from_4ub(ubyte red, ubyte green, ubyte blue, ubyte alpha) {
416 cogl_color_set_from_4ub(&this, red, green, blue, alpha);
419 // Sets the green channel of @color to @green.
420 // <green>: a float value between 0.0f and 1.0f
421 void set_green(float green) {
422 cogl_color_set_green(&this, green);
425 // Sets the green channel of @color to @green.
426 // <green>: a byte value between 0 and 255
427 void set_green_byte(ubyte green) {
428 cogl_color_set_green_byte(&this, green);
431 // Sets the green channel of @color to @green.
432 // <green>: a float value between 0.0f and 1.0f
433 void set_green_float(float green) {
434 cogl_color_set_green_float(&this, green);
437 // Sets the red channel of @color to @red.
438 // <red>: a float value between 0.0f and 1.0f
439 void set_red(float red) {
440 cogl_color_set_red(&this, red);
443 // Sets the red channel of @color to @red.
444 // <red>: a byte value between 0 and 255
445 void set_red_byte(ubyte red) {
446 cogl_color_set_red_byte(&this, red);
449 // Sets the red channel of @color to @red.
450 // <red>: a float value between 0.0f and 1.0f
451 void set_red_float(float red) {
452 cogl_color_set_red_float(&this, red);
455 // Converts a pre-multiplied color to a non-premultiplied color. For
456 // example, semi-transparent red is (0.5, 0, 0, 0.5) when premultiplied
457 // and (1.0, 0, 0, 0.5) when non-premultiplied.
458 void unpremultiply() {
459 cogl_color_unpremultiply(&this);
462 // Compares two #CoglColor<!-- -->s and checks if they are the same.
464 // This function can be passed to g_hash_table_new() as the @key_equal_func
465 // parameter, when using #CoglColor<!-- -->s as keys in a #GHashTable.
466 // RETURNS: %TRUE if the two colors are the same.
467 // <v1>: a #CoglColor
468 // <v2>: a #CoglColor
469 static int equal(const(void)* v1, const(void)* v2) {
470 return cogl_color_equal(v1, v2);
473 // Unintrospectable function: new() / cogl_color_new()
474 // Creates a new (empty) color
476 // to free the allocated resources
477 // RETURNS: a newly-allocated #CoglColor. Use cogl_color_free()
478 static Color* new_() {
479 return cogl_color_new();
484 // Defines a bit mask of color channels. This can be used with
485 // cogl_pipeline_set_color_mask() for example to define which color
486 // channels should be written to the current framebuffer when
487 // drawing something.
488 enum ColorMask {
489 NONE = 0,
490 RED = 1,
491 GREEN = 2,
492 BLUE = 4,
493 ALPHA = 8,
494 ALL = 15
497 // A callback function to use for cogl_debug_object_foreach_type().
498 // <info>: A pointer to a struct containing information about the type.
499 extern (C) alias void function (DebugObjectTypeInfo* info, void* user_data) DebugObjectForeachTypeCallback;
502 // This struct is used to pass information to the callback when
503 // cogl_debug_object_foreach_type() is called.
504 struct DebugObjectTypeInfo /* Version 1.8 */ {
505 char* name;
506 uint instance_count;
509 struct DepthState {
510 uint magic;
511 int test_enabled;
512 DepthTestFunction test_function;
513 int write_enabled;
514 float range_near, range_far;
515 uint padding0, padding1, padding2, padding3, padding4, padding5, padding6, padding7, padding8, padding9;
518 // Gets the current range to which normalized depth values are mapped
519 // before writing to the depth buffer. This corresponds to the range
520 // set with cogl_pipeline_set_depth_range().
521 // <near_val>: A pointer to store the near component of the depth range
522 // <far_val>: A pointer to store the far component of the depth range
523 void get_range(float* near_val, float* far_val) {
524 cogl_depth_state_get_range(&this, near_val, far_val);
527 // Gets the current depth test enabled state as previously set by
528 // cogl_depth_state_set_test_enabled().
529 // RETURNS: The pipeline's current depth test enabled state.
530 int get_test_enabled() {
531 return cogl_depth_state_get_test_enabled(&this);
534 // Gets the current depth test enable state as previously set via
535 // cogl_pipeline_set_depth_test_enabled().
536 // RETURNS: The current depth test enable state.
537 DepthTestFunction get_test_function() {
538 return cogl_depth_state_get_test_function(&this);
541 // Gets the depth writing enable state as set by the corresponding
542 // cogl_pipeline_set_depth_writing_enabled.
543 // RETURNS: The current depth writing enable state
544 int get_write_enabled() {
545 return cogl_depth_state_get_write_enabled(&this);
548 // Initializes the members of @state to their default values.
550 // You should never pass an un initialized #CoglDepthState structure
551 // to cogl_pipeline_set_depth_state().
552 void init() {
553 cogl_depth_state_init(&this);
556 // Sets the range to map depth values in normalized device coordinates
557 // to before writing out to a depth buffer.
559 // After your geometry has be transformed, clipped and had perspective
560 // division applied placing it in normalized device
561 // coordinates all depth values between the near and far z clipping
562 // planes are in the range -1 to 1. Before writing any depth value to
563 // the depth buffer though the value is mapped into the range [0, 1].
565 // With this function you can change the range which depth values are
566 // mapped too although the range must still lye within the range [0,
567 // 1].
569 // If your driver does not support this feature (for example you are
570 // using GLES 1 drivers) then if you don't use the default range
571 // values you will get an error reported when calling
572 // cogl_pipeline_set_depth_state (). You can check ahead of time for
573 // the %COGL_FEATURE_DEPTH_RANGE feature with
574 // cogl_features_available() to know if this function will succeed.
576 // By default normalized device coordinate depth values are mapped to
577 // the full range of depth buffer values, [0, 1].
579 // NB: this won't directly affect the state of the GPU. You have
580 // to then set the state on a #CoglPipeline using
581 // cogl_pipeline_set_depth_state().
582 // <near_val>: The near component of the desired depth range which will be clamped to the range [0, 1]
583 // <far_val>: The far component of the desired depth range which will be clamped to the range [0, 1]
584 void set_range(float near_val, float far_val) {
585 cogl_depth_state_set_range(&this, near_val, far_val);
588 // Enables or disables depth testing according to the value of
589 // @enable.
591 // If depth testing is enable then the #CoglDepthTestFunction set
592 // using cogl_pipeline_set_depth_test_function() us used to evaluate
593 // the depth value of incoming fragments against the corresponding
594 // value stored in the current depth buffer, and if the test passes
595 // then the fragments depth value is used to update the depth buffer.
596 // (unless you have disabled depth writing via
597 // cogl_pipeline_set_depth_writing_enabled ())
599 // By default depth testing is disabled.
601 // NB: this won't directly affect the state of the GPU. You have
602 // to then set the state on a #CoglPipeline using
603 // cogl_pipeline_set_depth_state()
604 // <enable>: The enable state you want
605 void set_test_enabled(int enable) {
606 cogl_depth_state_set_test_enabled(&this, enable);
609 // Sets the #CoglDepthTestFunction used to compare the depth value of
610 // an incoming fragment against the corresponding value in the current
611 // depth buffer.
613 // By default the depth test function is %COGL_DEPTH_TEST_FUNCTION_LESS
615 // NB: this won't directly affect the state of the GPU. You have
616 // to then set the state on a #CoglPipeline using
617 // cogl_pipeline_set_depth_state()
618 // <function>: The #CoglDepthTestFunction to set
619 void set_test_function(DepthTestFunction function_) {
620 cogl_depth_state_set_test_function(&this, function_);
623 // Enables or disables depth buffer writing according to the value of
624 // @enable. Normally when depth testing is enabled and the comparison
625 // between a fragment's depth value and the corresponding depth buffer
626 // value passes then the fragment's depth is written to the depth
627 // buffer unless writing is disabled here.
629 // By default depth writing is enabled
631 // NB: this won't directly affect the state of the GPU. You have
632 // to then set the state on a #CoglPipeline using
633 // cogl_pipeline_set_depth_state()
634 // <enable>: The enable state you want
635 void set_write_enabled(int enable) {
636 cogl_depth_state_set_write_enabled(&this, enable);
641 // When using depth testing one of these functions is used to compare
642 // the depth of an incoming fragment against the depth value currently
643 // stored in the depth buffer. The function is changed using
644 // cogl_material_set_depth_test_function().
646 // The test is only done when depth testing is explicitly enabled. (See
647 // cogl_material_set_depth_test_enabled())
648 enum DepthTestFunction {
649 NEVER = 512,
650 LESS = 513,
651 EQUAL = 514,
652 LEQUAL = 515,
653 GREATER = 516,
654 NOTEQUAL = 517,
655 GEQUAL = 518,
656 ALWAYS = 519
659 // Error enumeration for Cogl
661 // The @COGL_ERROR_UNSUPPORTED error can be thrown for a variety of
662 // reasons. For example:
664 // <itemizedlist>
665 // <listitem><para>You've tried to use a feature that is not
666 // advertised by cogl_get_features(). This could happen if you create
667 // a non-sliced texture with a non-power-of-two size when
668 // %COGL_FEATURE_TEXTURE_NPOT is not advertised.</para></listitem>
669 // <listitem><para>The GPU can not handle the configuration you have
670 // requested. An example might be if you try to use too many texture
671 // layers in a single #CoglPipeline</para></listitem>
672 // <listitem><para>The driver does not support some
673 // configuration.</para></listiem>
674 // </itemizedlist>
676 // Currently this is only used by Cogl API marked as experimental so
677 // this enum should also be considered experimental.
678 enum Error /* Version 1.4 */ {
679 UNSUPPORTED = 0
682 // Represents an ordered rotation first of @heading degrees around an
683 // object's y axis, then @pitch degrees around an object's x axis and
684 // finally @roll degrees around an object's z axis.
686 // <note>It's important to understand the that axis are associated
687 // with the object being rotated, so the axis also rotate in sequence
688 // with the rotations being applied.</note>
690 // The members of a #CoglEuler can be initialized, for example, with
691 // cogl_euler_init() and cogl_euler_init_from_quaternion ().
693 // You may also want to look at cogl_quaternion_init_from_euler() if
694 // you want to do interpolation between 3d rotations.
695 struct Euler /* Version 2.0 */ {
696 float heading, pitch, roll;
697 private float padding0, padding1, padding2, padding3, padding4;
700 // Unintrospectable method: copy() / cogl_euler_copy()
701 // Allocates a new #CoglEuler and initilizes it with the component
702 // angles of @src. The newly allocated euler should be freed using
703 // cogl_euler_free().
704 // RETURNS: A newly allocated #CoglEuler
705 Euler* copy() {
706 return cogl_euler_copy(&this);
709 // Frees a #CoglEuler that was previously allocated using
710 // cogl_euler_copy().
711 void free() {
712 cogl_euler_free(&this);
715 // Initializes @euler to represent a rotation of @x_angle degrees
716 // around the x axis, then @y_angle degrees around the y_axis and
717 // @z_angle degrees around the z axis.
718 // <heading>: Angle to rotate around an object's y axis
719 // <pitch>: Angle to rotate around an object's x axis
720 // <roll>: Angle to rotate around an object's z axis
721 void init(float heading, float pitch, float roll) {
722 cogl_euler_init(&this, heading, pitch, roll);
725 // Extracts a euler rotation from the given @matrix and
726 // initializses @euler with the component x, y and z rotation angles.
727 // <matrix>: A #CoglMatrix containing a rotation, but no scaling, mirroring or skewing.
728 void init_from_matrix(Matrix* matrix) {
729 cogl_euler_init_from_matrix(&this, matrix);
732 // Initializes a @euler rotation with the equivalent rotation
733 // represented by the given @quaternion.
734 // <quaternion>: A #CoglEuler with the rotation to initialize with
735 void init_from_quaternion(Quaternion* quaternion) {
736 cogl_euler_init_from_quaternion(&this, quaternion);
739 // Compares the two given euler angles @v1 and @v1 and it they are
740 // equal returns %TRUE else %FALSE.
742 // <note>This function only checks that all three components rotations
743 // are numerically equal, it does not consider that some rotations
744 // can be represented with different component rotations</note>
745 // RETURNS: %TRUE if @v1 and @v2 are equal else %FALSE.
746 // <v1>: The second euler angle to compare
747 static int equal(const(void)* v1, const(void)* v2) {
748 return cogl_euler_equal(v1, v2);
752 enum int FIXED_0_5 = 32768;
753 enum int FIXED_1 = 1;
754 enum int FIXED_2_PI = 411775;
755 enum int FIXED_BITS = 32;
756 enum int FIXED_EPSILON = 1;
757 enum int FIXED_MAX = 2147483647;
758 enum int FIXED_MIN = cast(int)2147483648;
759 enum int FIXED_PI = 205887;
760 enum int FIXED_PI_2 = 102944;
761 enum int FIXED_PI_4 = 51472;
762 enum int FIXED_Q = -16;
763 // Flags for the supported features.
764 enum FeatureFlags /* Version 0.8 */ {
765 TEXTURE_RECTANGLE = 2,
766 TEXTURE_NPOT = 4,
767 TEXTURE_YUV = 8,
768 TEXTURE_READ_PIXELS = 16,
769 SHADERS_GLSL = 32,
770 OFFSCREEN = 64,
771 OFFSCREEN_MULTISAMPLE = 128,
772 OFFSCREEN_BLIT = 256,
773 FOUR_CLIP_PLANES = 512,
774 STENCIL_BUFFER = 1024,
775 VBOS = 2048,
776 PBOS = 4096,
777 UNSIGNED_INT_INDICES = 8192,
778 DEPTH_RANGE = 16384,
779 TEXTURE_NPOT_BASIC = 32768,
780 TEXTURE_NPOT_MIPMAP = 65536,
781 TEXTURE_NPOT_REPEAT = 131072,
782 POINT_SPRITE = 262144,
783 TEXTURE_3D = 524288,
784 SHADERS_ARBFP = 1048576,
785 MAP_BUFFER_FOR_READ = 2097152,
786 MAP_BUFFER_FOR_WRITE = 4194304,
787 ONSCREEN_MULTIPLE = 8388608
789 enum FilterReturn {
790 CONTINUE = 0,
791 REMOVE = 1
793 // Fixed point number using a (16.16) notation.
794 struct Fixed {
796 // Unintrospectable function: log2() / cogl_fixed_log2()
797 // Calculates base 2 logarithm.
799 // This function is some 2.5 times faster on x86, and over 12 times faster on
800 // fpu-less arm, than using libc log().
801 // RETURNS: base 2 logarithm.
802 // <x>: value to calculate base 2 logarithm from
803 static Fixed log2(uint x) {
804 return cogl_fixed_log2(x);
807 // Calculates @x to the @y power.
808 // RETURNS: the power of @x to the @y
809 // <x>: base
810 // <y>: #CoglFixed exponent
811 static uint pow(uint x, Fixed y) {
812 return cogl_fixed_pow(x, y);
815 // Unintrospectable method: atan() / cogl_fixed_atan()
816 // Computes the arc tangent of @a.
817 // RETURNS: the arc tangent of the passed value, in fixed point notation
818 Fixed atan() {
819 return cogl_fixed_atan(&this);
822 // Unintrospectable method: atan2() / cogl_fixed_atan2()
823 // Computes the arc tangent of @a / @b but uses the sign of both
824 // arguments to return the angle in right quadrant.
826 // notation
827 // RETURNS: the arc tangent of the passed fraction, in fixed point
828 // <b>: the denominator as a #CoglFixed number
829 Fixed atan2(Fixed b) {
830 return cogl_fixed_atan2(&this, b);
833 // Unintrospectable method: cos() / cogl_fixed_cos()
834 // Computes the cosine of @angle.
835 // RETURNS: the cosine of the passed angle, in fixed point notation
836 Fixed cos() {
837 return cogl_fixed_cos(&this);
839 // Unintrospectable method: div() / cogl_fixed_div()
840 Fixed div(Fixed b) {
841 return cogl_fixed_div(&this, b);
843 // Unintrospectable method: mul() / cogl_fixed_mul()
844 Fixed mul(Fixed b) {
845 return cogl_fixed_mul(&this, b);
847 // Unintrospectable method: mul_div() / cogl_fixed_mul_div()
848 Fixed mul_div(Fixed b, Fixed c) {
849 return cogl_fixed_mul_div(&this, b, c);
852 // Calculates 2 to the @x power.
854 // This function is around 11 times faster on x86, and around 22 times faster
855 // on fpu-less arm than libc pow(2, x).
856 // RETURNS: the power of 2 to the passed value
857 uint pow2() {
858 return cogl_fixed_pow2(&this);
861 // Unintrospectable method: sin() / cogl_fixed_sin()
862 // Computes the sine of @angle.
863 // RETURNS: the sine of the passed angle, in fixed point notation
864 Fixed sin() {
865 return cogl_fixed_sin(&this);
868 // Unintrospectable method: sqrt() / cogl_fixed_sqrt()
869 // Computes the square root of @x.
871 // notation
872 // RETURNS: the square root of the passed value, in floating point
873 Fixed sqrt() {
874 return cogl_fixed_sqrt(&this);
877 // Unintrospectable method: tan() / cogl_fixed_tan()
878 // Computes the tangent of @angle.
879 // RETURNS: the tangent of the passed angle, in fixed point notation
880 Fixed tan() {
881 return cogl_fixed_tan(&this);
886 // The fog mode determines the equation used to calculate the fogging blend
887 // factor while fogging is enabled. The simplest %COGL_FOG_MODE_LINEAR mode
888 // determines f as:
890 // |[
891 // f = end - eye_distance / end - start
892 // ]|
894 // Where eye_distance is the distance of the current fragment in eye
895 // coordinates from the origin.
896 enum FogMode /* Version 1.0 */ {
897 LINEAR = 0,
898 EXPONENTIAL = 1,
899 EXPONENTIAL_SQUARED = 2
901 struct Framebuffer {
905 // The type used by cogl for function pointers, note that this type
906 // is used as a generic catch-all cast for function pointers and the
907 // actual arguments and return type may be different.
908 extern (C) alias void function () FuncPtr;
910 struct IndexBuffer {
912 // Unintrospectable function: new() / cogl_index_buffer_new()
913 // Declares a new #CoglIndexBuffer of @size bytes to contain vertex
914 // indices. Once declared, data can be set using
915 // cogl_buffer_set_data() or by mapping it into the application's
916 // address space using cogl_buffer_map().
917 // <bytes>: The number of bytes to allocate for vertex attribute data.
918 static IndexBuffer* new_(size_t bytes) {
919 return cogl_index_buffer_new(bytes);
923 struct Indices {
924 // Unintrospectable method: get_buffer() / cogl_indices_get_buffer()
925 IndexBuffer* get_buffer() {
926 return cogl_indices_get_buffer(&this);
928 size_t get_offset() {
929 return cogl_indices_get_offset(&this);
931 void set_offset(size_t offset) {
932 cogl_indices_set_offset(&this, offset);
934 // Unintrospectable function: new() / cogl_indices_new()
935 static Indices* new_(IndicesType type, void* indices_data, int n_indices) {
936 return cogl_indices_new(type, indices_data, n_indices);
938 // Unintrospectable function: new_for_buffer() / cogl_indices_new_for_buffer()
939 static Indices* new_for_buffer(IndicesType type, IndexBuffer* buffer, size_t offset) {
940 return cogl_indices_new_for_buffer(type, buffer, offset);
945 // You should aim to use the smallest data type that gives you enough
946 // range, since it reduces the size of your index array and can help
947 // reduce the demand on memory bandwidth.
949 // Note that %COGL_INDICES_TYPE_UNSIGNED_INT is only supported if the
950 // %COGL_FEATURE_UNSIGNED_INT_INDICES feature is available. This
951 // should always be available on OpenGL but on OpenGL ES it will only
952 // be available if the GL_OES_element_index_uint extension is
953 // advertized.
954 enum IndicesType {
955 BYTE = 0,
956 SHORT = 1,
957 INT = 2
959 struct Material {
961 // Unintrospectable method: copy() / cogl_material_copy()
962 // Creates a new material with the configuration copied from the
963 // source material.
965 // We would strongly advise developers to always aim to use
966 // cogl_material_copy() instead of cogl_material_new() whenever there will
967 // be any similarity between two materials. Copying a material helps Cogl
968 // keep track of a materials ancestry which we may use to help minimize GPU
969 // state changes.
970 // RETURNS: a pointer to the newly allocated #CoglMaterial
971 Material* copy() {
972 return cogl_material_copy(&this);
975 // Retrieves the current ambient color for @material
976 // <ambient>: The location to store the ambient color
977 void get_ambient(Color* ambient) {
978 cogl_material_get_ambient(&this, ambient);
981 // Retrieves the current material color.
982 // <color>: The location to store the color
983 void get_color(/*out*/ Color* color) {
984 cogl_material_get_color(&this, color);
987 // Retrieves the current diffuse color for @material
988 // <diffuse>: The location to store the diffuse color
989 void get_diffuse(Color* diffuse) {
990 cogl_material_get_diffuse(&this, diffuse);
993 // Retrieves the materials current emission color.
994 // <emission>: The location to store the emission color
995 void get_emission(Color* emission) {
996 cogl_material_get_emission(&this, emission);
999 // Gets whether point sprite coordinate generation is enabled for this
1000 // texture layer.
1002 // point sprite coordinates.
1003 // RETURNS: whether the texture coordinates will be replaced with
1004 // <layer_index>: the layer number to check.
1005 int get_layer_point_sprite_coords_enabled(int layer_index) {
1006 return cogl_material_get_layer_point_sprite_coords_enabled(&this, layer_index);
1009 // Returns the wrap mode for the 'p' coordinate of texture lookups on this
1010 // layer.
1012 // this layer.
1013 // RETURNS: the wrap mode for the 'p' coordinate of texture lookups on
1014 // <layer_index>: the layer number to change.
1015 MaterialWrapMode get_layer_wrap_mode_p(int layer_index) {
1016 return cogl_material_get_layer_wrap_mode_p(&this, layer_index);
1019 // Returns the wrap mode for the 's' coordinate of texture lookups on this
1020 // layer.
1022 // this layer.
1023 // RETURNS: the wrap mode for the 's' coordinate of texture lookups on
1024 // <layer_index>: the layer number to change.
1025 MaterialWrapMode get_layer_wrap_mode_s(int layer_index) {
1026 return cogl_material_get_layer_wrap_mode_s(&this, layer_index);
1029 // Returns the wrap mode for the 't' coordinate of texture lookups on this
1030 // layer.
1032 // this layer.
1033 // RETURNS: the wrap mode for the 't' coordinate of texture lookups on
1034 // <layer_index>: the layer number to change.
1035 MaterialWrapMode get_layer_wrap_mode_t(int layer_index) {
1036 return cogl_material_get_layer_wrap_mode_t(&this, layer_index);
1039 // This function lets you access a material's internal list of layers
1040 // for iteration.
1042 // <note>You should avoid using this API if possible since it was only
1043 // made public by mistake and will be deprecated when we have
1044 // suitable alternative.</note>
1046 // <note>It's important to understand that the list returned may not
1047 // remain valid if you modify the material or any of the layers in any
1048 // way and so you would have to re-get the list in that
1049 // situation.</note>
1051 // list of #CoglMaterialLayer<!-- -->'s that can be passed to the
1052 // cogl_material_layer_* functions. The list is owned by Cogl and it
1053 // should not be modified or freed
1054 // RETURNS: A
1055 GLib2.List* get_layers() {
1056 return cogl_material_get_layers(&this);
1059 // Retrieves the number of layers defined for the given @material
1060 // RETURNS: the number of layers
1061 int get_n_layers() {
1062 return cogl_material_get_n_layers(&this);
1065 // Get the size of points drawn when %COGL_VERTICES_MODE_POINTS is
1066 // used with the vertex buffer API.
1067 // RETURNS: the point size of the material.
1068 float get_point_size() {
1069 return cogl_material_get_point_size(&this);
1072 // Retrieves the materials current emission color.
1073 // RETURNS: The materials current shininess value
1074 float get_shininess() {
1075 return cogl_material_get_shininess(&this);
1078 // Retrieves the materials current specular color.
1079 // <specular>: The location to store the specular color
1080 void get_specular(Color* specular) {
1081 cogl_material_get_specular(&this, specular);
1084 // Queries what user program has been associated with the given
1085 // @material using cogl_material_set_user_program().
1087 // or %COGL_INVALID_HANDLE.
1088 // RETURNS: The current user program
1089 Handle get_user_program() {
1090 return cogl_material_get_user_program(&this);
1093 // This function removes a layer from your material
1094 // <layer_index>: Specifies the layer you want to remove
1095 void remove_layer(int layer_index) {
1096 cogl_material_remove_layer(&this, layer_index);
1099 // Before a primitive is blended with the framebuffer, it goes through an
1100 // alpha test stage which lets you discard fragments based on the current
1101 // alpha value. This function lets you change the function used to evaluate
1102 // the alpha channel, and thus determine which fragments are discarded
1103 // and which continue on to the blending stage.
1105 // The default is %COGL_MATERIAL_ALPHA_FUNC_ALWAYS
1106 // <alpha_func>: A @CoglMaterialAlphaFunc constant
1107 // <alpha_reference>: A reference point that the chosen alpha function uses to compare incoming fragments to.
1108 void set_alpha_test_function(MaterialAlphaFunc alpha_func, float alpha_reference) {
1109 cogl_material_set_alpha_test_function(&this, alpha_func, alpha_reference);
1112 // Sets the material's ambient color, in the standard OpenGL lighting
1113 // model. The ambient color affects the overall color of the object.
1115 // Since the diffuse color will be intense when the light hits the surface
1116 // directly, the ambient will be most apparent where the light hits at a
1117 // slant.
1119 // The default value is (0.2, 0.2, 0.2, 1.0)
1120 // <ambient>: The components of the desired ambient color
1121 void set_ambient(Color* ambient) {
1122 cogl_material_set_ambient(&this, ambient);
1125 // Conveniently sets the diffuse and ambient color of @material at the same
1126 // time. See cogl_material_set_ambient() and cogl_material_set_diffuse().
1128 // The default ambient color is (0.2, 0.2, 0.2, 1.0)
1130 // The default diffuse color is (0.8, 0.8, 0.8, 1.0)
1131 // <color>: The components of the desired ambient and diffuse colors
1132 void set_ambient_and_diffuse(Color* color) {
1133 cogl_material_set_ambient_and_diffuse(&this, color);
1136 // If not already familiar; please refer <link linkend="cogl-Blend-Strings">here</link>
1137 // for an overview of what blend strings are, and their syntax.
1139 // Blending occurs after the alpha test function, and combines fragments with
1140 // the framebuffer.
1141 // Currently the only blend function Cogl exposes is ADD(). So any valid
1142 // blend statements will be of the form:
1144 // |[
1145 // &lt;channel-mask&gt;=ADD(SRC_COLOR*(&lt;factor&gt;), DST_COLOR*(&lt;factor&gt;))
1146 // ]|
1148 // <warning>The brackets around blend factors are currently not
1149 // optional!</warning>
1151 // This is the list of source-names usable as blend factors:
1152 // <itemizedlist>
1153 // <listitem><para>SRC_COLOR: The color of the in comming fragment</para></listitem>
1154 // <listitem><para>DST_COLOR: The color of the framebuffer</para></listitem>
1155 // <listitem><para>CONSTANT: The constant set via cogl_material_set_blend_constant()</para></listitem>
1156 // </itemizedlist>
1158 // The source names can be used according to the
1159 // <link linkend="cogl-Blend-String-syntax">color-source and factor syntax</link>,
1160 // so for example "(1-SRC_COLOR[A])" would be a valid factor, as would
1161 // "(CONSTANT[RGB])"
1163 // These can also be used as factors:
1164 // <itemizedlist>
1165 // <listitem>0: (0, 0, 0, 0)</listitem>
1166 // <listitem>1: (1, 1, 1, 1)</listitem>
1167 // <listitem>SRC_ALPHA_SATURATE_FACTOR: (f,f,f,1) where f = MIN(SRC_COLOR[A],1-DST_COLOR[A])</listitem>
1168 // </itemizedlist>
1170 // <note>Remember; all color components are normalized to the range [0, 1]
1171 // before computing the result of blending.</note>
1173 // <example id="cogl-Blend-Strings-blend-unpremul">
1174 // <title>Blend Strings/1</title>
1175 // <para>Blend a non-premultiplied source over a destination with
1176 // premultiplied alpha:</para>
1177 // <programlisting>
1178 // "RGB = ADD(SRC_COLOR*(SRC_COLOR[A]), DST_COLOR*(1-SRC_COLOR[A]))"
1179 // "A = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))"
1180 // </programlisting>
1181 // </example>
1183 // <example id="cogl-Blend-Strings-blend-premul">
1184 // <title>Blend Strings/2</title>
1185 // <para>Blend a premultiplied source over a destination with
1186 // premultiplied alpha</para>
1187 // <programlisting>
1188 // "RGBA = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))"
1189 // </programlisting>
1190 // </example>
1192 // The default blend string is:
1193 // |[
1194 // RGBA = ADD (SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))
1195 // ]|
1197 // That gives normal alpha-blending when the calculated color for the material
1198 // is in premultiplied form.
1200 // described blending is supported by the underlying driver/hardware. If
1201 // there was an error, %FALSE is returned and @error is set accordingly (if
1202 // present).
1203 // RETURNS: %TRUE if the blend string was successfully parsed, and the
1204 // <blend_string>: A <link linkend="cogl-Blend-Strings">Cogl blend string</link> describing the desired blend function.
1205 int set_blend(char* blend_string, GLib2.Error** error=null) {
1206 return cogl_material_set_blend(&this, blend_string, error);
1209 // When blending is setup to reference a CONSTANT blend factor then
1210 // blending will depend on the constant set with this function.
1211 // <constant_color>: The constant color you want
1212 void set_blend_constant(Color* constant_color) {
1213 cogl_material_set_blend_constant(&this, constant_color);
1216 // Sets the basic color of the material, used when no lighting is enabled.
1218 // Note that if you don't add any layers to the material then the color
1219 // will be blended unmodified with the destination; the default blend
1220 // expects premultiplied colors: for example, use (0.5, 0.0, 0.0, 0.5) for
1221 // semi-transparent red. See cogl_color_premultiply().
1223 // The default value is (1.0, 1.0, 1.0, 1.0)
1224 // <color>: The components of the color
1225 void set_color(Color* color) {
1226 cogl_material_set_color(&this, color);
1229 // Sets the basic color of the material, used when no lighting is enabled.
1231 // The default value is (1.0, 1.0, 1.0, 1.0)
1232 // <red>: The red component
1233 // <green>: The green component
1234 // <blue>: The blue component
1235 // <alpha>: The alpha component
1236 void set_color4f(float red, float green, float blue, float alpha) {
1237 cogl_material_set_color4f(&this, red, green, blue, alpha);
1240 // Sets the basic color of the material, used when no lighting is enabled.
1242 // The default value is (0xff, 0xff, 0xff, 0xff)
1243 // <red>: The red component
1244 // <green>: The green component
1245 // <blue>: The blue component
1246 // <alpha>: The alpha component
1247 void set_color4ub(ubyte red, ubyte green, ubyte blue, ubyte alpha) {
1248 cogl_material_set_color4ub(&this, red, green, blue, alpha);
1251 // Sets the material's diffuse color, in the standard OpenGL lighting
1252 // model. The diffuse color is most intense where the light hits the
1253 // surface directly - perpendicular to the surface.
1255 // The default value is (0.8, 0.8, 0.8, 1.0)
1256 // <diffuse>: The components of the desired diffuse color
1257 void set_diffuse(Color* diffuse) {
1258 cogl_material_set_diffuse(&this, diffuse);
1261 // Sets the material's emissive color, in the standard OpenGL lighting
1262 // model. It will look like the surface is a light source emitting this
1263 // color.
1265 // The default value is (0.0, 0.0, 0.0, 1.0)
1266 // <emission>: The components of the desired emissive color
1267 void set_emission(Color* emission) {
1268 cogl_material_set_emission(&this, emission);
1271 // In addition to the standard OpenGL lighting model a Cogl material may have
1272 // one or more layers comprised of textures that can be blended together in
1273 // order, with a number of different texture combine modes. This function
1274 // defines a new texture layer.
1276 // The index values of multiple layers do not have to be consecutive; it is
1277 // only their relative order that is important.
1279 // <note>In the future, we may define other types of material layers, such
1280 // as purely GLSL based layers.</note>
1281 // <layer_index>: the index of the layer
1282 // <texture>: a #CoglHandle for the layer object
1283 void set_layer(int layer_index, Handle texture) {
1284 cogl_material_set_layer(&this, layer_index, texture);
1287 // If not already familiar; you can refer
1288 // <link linkend="cogl-Blend-Strings">here</link> for an overview of what blend
1289 // strings are and there syntax.
1291 // These are all the functions available for texture combining:
1292 // <itemizedlist>
1293 // <listitem>REPLACE(arg0) = arg0</listitem>
1294 // <listitem>MODULATE(arg0, arg1) = arg0 x arg1</listitem>
1295 // <listitem>ADD(arg0, arg1) = arg0 + arg1</listitem>
1296 // <listitem>ADD_SIGNED(arg0, arg1) = arg0 + arg1 - 0.5</listitem>
1297 // <listitem>INTERPOLATE(arg0, arg1, arg2) = arg0 x arg2 + arg1 x (1 - arg2)</listitem>
1298 // <listitem>SUBTRACT(arg0, arg1) = arg0 - arg1</listitem>
1299 // <listitem>
1300 // <programlisting>
1301 // DOT3_RGB(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) +
1302 // (arg0[G] - 0.5)) * (arg1[G] - 0.5) +
1303 // (arg0[B] - 0.5)) * (arg1[B] - 0.5))
1304 // </programlisting>
1305 // </listitem>
1306 // <listitem>
1307 // <programlisting>
1308 // DOT3_RGBA(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) +
1309 // (arg0[G] - 0.5)) * (arg1[G] - 0.5) +
1310 // (arg0[B] - 0.5)) * (arg1[B] - 0.5))
1311 // </programlisting>
1312 // </listitem>
1313 // </itemizedlist>
1315 // Refer to the
1316 // <link linkend="cogl-Blend-String-syntax">color-source syntax</link> for
1317 // describing the arguments. The valid source names for texture combining
1318 // are:
1319 // <variablelist>
1320 // <varlistentry>
1321 // <term>TEXTURE</term>
1322 // <listitem>Use the color from the current texture layer</listitem>
1323 // </varlistentry>
1324 // <varlistentry>
1325 // <term>TEXTURE_0, TEXTURE_1, etc</term>
1326 // <listitem>Use the color from the specified texture layer</listitem>
1327 // </varlistentry>
1328 // <varlistentry>
1329 // <term>CONSTANT</term>
1330 // <listitem>Use the color from the constant given with
1331 // cogl_material_set_layer_constant()</listitem>
1332 // </varlistentry>
1333 // <varlistentry>
1334 // <term>PRIMARY</term>
1335 // <listitem>Use the color of the material as set with
1336 // cogl_material_set_color()</listitem>
1337 // </varlistentry>
1338 // <varlistentry>
1339 // <term>PREVIOUS</term>
1340 // <listitem>Either use the texture color from the previous layer, or
1341 // if this is layer 0, use the color of the material as set with
1342 // cogl_material_set_color()</listitem>
1343 // </varlistentry>
1344 // </variablelist>
1346 // <refsect2 id="cogl-Layer-Combine-Examples">
1347 // <title>Layer Combine Examples</title>
1348 // <para>This is effectively what the default blending is:</para>
1349 // <informalexample><programlisting>
1350 // RGBA = MODULATE (PREVIOUS, TEXTURE)
1351 // </programlisting></informalexample>
1352 // <para>This could be used to cross-fade between two images, using
1353 // the alpha component of a constant as the interpolator. The constant
1354 // color is given by calling cogl_material_set_layer_constant.</para>
1355 // <informalexample><programlisting>
1356 // RGBA = INTERPOLATE (PREVIOUS, TEXTURE, CONSTANT[A])
1357 // </programlisting></informalexample>
1358 // </refsect2>
1360 // <note>You can't give a multiplication factor for arguments as you can
1361 // with blending.</note>
1363 // described texture combining is supported by the underlying driver and
1364 // or hardware. On failure, %FALSE is returned and @error is set
1365 // RETURNS: %TRUE if the blend string was successfully parsed, and the
1366 // <layer_index>: Specifies the layer you want define a combine function for
1367 // <blend_string>: A <link linkend="cogl-Blend-Strings">Cogl blend string</link> describing the desired texture combine function.
1368 int set_layer_combine(int layer_index, char* blend_string, GLib2.Error** error=null) {
1369 return cogl_material_set_layer_combine(&this, layer_index, blend_string, error);
1372 // When you are using the 'CONSTANT' color source in a layer combine
1373 // description then you can use this function to define its value.
1374 // <layer_index>: Specifies the layer you want to specify a constant used for texture combining
1375 // <constant>: The constant color you want
1376 void set_layer_combine_constant(int layer_index, Color* constant) {
1377 cogl_material_set_layer_combine_constant(&this, layer_index, constant);
1380 // Changes the decimation and interpolation filters used when a texture is
1381 // drawn at other scales than 100%.
1382 // <layer_index>: the layer number to change.
1383 // <min_filter>: the filter used when scaling a texture down.
1384 // <mag_filter>: the filter used when magnifying a texture.
1385 void set_layer_filters(int layer_index, MaterialFilter min_filter, MaterialFilter mag_filter) {
1386 cogl_material_set_layer_filters(&this, layer_index, min_filter, mag_filter);
1389 // This function lets you set a matrix that can be used to e.g. translate
1390 // and rotate a single layer of a material used to fill your geometry.
1391 // <layer_index>: the index for the layer inside @material
1392 // <matrix>: the transformation matrix for the layer
1393 void set_layer_matrix(int layer_index, Matrix* matrix) {
1394 cogl_material_set_layer_matrix(&this, layer_index, matrix);
1397 // When rendering points, if @enable is %TRUE then the texture
1398 // coordinates for this layer will be replaced with coordinates that
1399 // vary from 0.0 to 1.0 across the primitive. The top left of the
1400 // point will have the coordinates 0.0,0.0 and the bottom right will
1401 // have 1.0,1.0. If @enable is %FALSE then the coordinates will be
1402 // fixed for the entire point.
1404 // This function will only work if %COGL_FEATURE_POINT_SPRITE is
1405 // available. If the feature is not available then the function will
1406 // return %FALSE and set @error.
1407 // RETURNS: %TRUE if the function succeeds, %FALSE otherwise.
1408 // <layer_index>: the layer number to change.
1409 // <enable>: whether to enable point sprite coord generation.
1410 int set_layer_point_sprite_coords_enabled(int layer_index, int enable, GLib2.Error** error=null) {
1411 return cogl_material_set_layer_point_sprite_coords_enabled(&this, layer_index, enable, error);
1414 // Sets the wrap mode for all three coordinates of texture lookups on
1415 // this layer. This is equivalent to calling
1416 // cogl_material_set_layer_wrap_mode_s(),
1417 // cogl_material_set_layer_wrap_mode_t() and
1418 // cogl_material_set_layer_wrap_mode_p() separately.
1419 // <layer_index>: the layer number to change.
1420 // <mode>: the new wrap mode
1421 void set_layer_wrap_mode(int layer_index, MaterialWrapMode mode) {
1422 cogl_material_set_layer_wrap_mode(&this, layer_index, mode);
1425 // Sets the wrap mode for the 'p' coordinate of texture lookups on
1426 // this layer. 'p' is the third coordinate.
1427 // <layer_index>: the layer number to change.
1428 // <mode>: the new wrap mode
1429 void set_layer_wrap_mode_p(int layer_index, MaterialWrapMode mode) {
1430 cogl_material_set_layer_wrap_mode_p(&this, layer_index, mode);
1433 // Sets the wrap mode for the 's' coordinate of texture lookups on this layer.
1434 // <layer_index>: the layer number to change.
1435 // <mode>: the new wrap mode
1436 void set_layer_wrap_mode_s(int layer_index, MaterialWrapMode mode) {
1437 cogl_material_set_layer_wrap_mode_s(&this, layer_index, mode);
1440 // Sets the wrap mode for the 't' coordinate of texture lookups on this layer.
1441 // <layer_index>: the layer number to change.
1442 // <mode>: the new wrap mode
1443 void set_layer_wrap_mode_t(int layer_index, MaterialWrapMode mode) {
1444 cogl_material_set_layer_wrap_mode_t(&this, layer_index, mode);
1447 // Changes the size of points drawn when %COGL_VERTICES_MODE_POINTS is
1448 // used with the vertex buffer API. Note that typically the GPU will
1449 // only support a limited minimum and maximum range of point sizes. If
1450 // the chosen point size is outside that range then the nearest value
1451 // within that range will be used instead. The size of a point is in
1452 // screen space so it will be the same regardless of any
1453 // transformations. The default point size is 1.0.
1454 // <point_size>: the new point size.
1455 void set_point_size(float point_size) {
1456 cogl_material_set_point_size(&this, point_size);
1459 // Sets the shininess of the material, in the standard OpenGL lighting
1460 // model, which determines the size of the specular highlights. A
1461 // higher @shininess will produce smaller highlights which makes the
1462 // object appear more shiny.
1464 // The default value is 0.0
1465 // <shininess>: The desired shininess; must be >= 0.0
1466 void set_shininess(float shininess) {
1467 cogl_material_set_shininess(&this, shininess);
1470 // Sets the material's specular color, in the standard OpenGL lighting
1471 // model. The intensity of the specular color depends on the viewport
1472 // position, and is brightest along the lines of reflection.
1474 // The default value is (0.0, 0.0, 0.0, 1.0)
1475 // <specular>: The components of the desired specular color
1476 void set_specular(Color* specular) {
1477 cogl_material_set_specular(&this, specular);
1480 // Associates a linked CoglProgram with the given material so that the
1481 // program can take full control of vertex and/or fragment processing.
1483 // This is an example of how it can be used to associate an ARBfp
1484 // program with a #CoglMaterial:
1485 // |[
1486 // CoglHandle shader;
1487 // CoglHandle program;
1488 // CoglMaterial *material;
1490 // shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT);
1491 // cogl_shader_source (shader,
1492 // "!!ARBfp1.0\n"
1493 // "MOV result.color,fragment.color;\n"
1494 // "END\n");
1495 // cogl_shader_compile (shader);
1497 // program = cogl_create_program ();
1498 // cogl_program_attach_shader (program, shader);
1499 // cogl_program_link (program);
1501 // material = cogl_material_new ();
1502 // cogl_material_set_user_program (material, program);
1504 // cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
1505 // cogl_rectangle (0, 0, 100, 100);
1506 // ]|
1508 // It is possibly worth keeping in mind that this API is not part of
1509 // the long term design for how we want to expose shaders to Cogl
1510 // developers (We are planning on deprecating the cogl_program and
1511 // cogl_shader APIs in favour of a "snippet" framework) but in the
1512 // meantime we hope this will handle most practical GLSL and ARBfp
1513 // requirements.
1515 // Also remember you need to check for either the
1516 // %COGL_FEATURE_SHADERS_GLSL or %COGL_FEATURE_SHADERS_ARBFP before
1517 // using the cogl_program or cogl_shader API.
1518 // <program>: A #CoglHandle to a linked CoglProgram
1519 void set_user_program(Handle program) {
1520 cogl_material_set_user_program(&this, program);
1523 // Unintrospectable function: new() / cogl_material_new()
1524 // Allocates and initializes a blank white material
1525 // RETURNS: a pointer to a new #CoglMaterial
1526 static Material* new_() {
1527 return cogl_material_new();
1530 // Unintrospectable function: ref() / cogl_material_ref()
1531 // Increment the reference count for a #CoglMaterial.
1532 // RETURNS: the @material.
1533 // <material>: a #CoglMaterial object.
1534 static Handle ref_(Handle material) {
1535 return cogl_material_ref(material);
1538 // Decrement the reference count for a #CoglMaterial.
1539 // <material>: a #CoglMaterial object.
1540 static void unref(Handle material) {
1541 cogl_material_unref(material);
1546 // Alpha testing happens before blending primitives with the framebuffer and
1547 // gives an opportunity to discard fragments based on a comparison with the
1548 // incoming alpha value and a reference alpha value. The #CoglMaterialAlphaFunc
1549 // determines how the comparison is done.
1550 enum MaterialAlphaFunc {
1551 NEVER = 512,
1552 LESS = 513,
1553 EQUAL = 514,
1554 LEQUAL = 515,
1555 GREATER = 516,
1556 NOTEQUAL = 517,
1557 GEQUAL = 518,
1558 ALWAYS = 519
1561 // Texture filtering is used whenever the current pixel maps either to more
1562 // than one texture element (texel) or less than one. These filter enums
1563 // correspond to different strategies used to come up with a pixel color, by
1564 // possibly referring to multiple neighbouring texels and taking a weighted
1565 // average or simply using the nearest texel.
1566 enum MaterialFilter {
1567 NEAREST = 9728,
1568 LINEAR = 9729,
1569 NEAREST_MIPMAP_NEAREST = 9984,
1570 LINEAR_MIPMAP_NEAREST = 9985,
1571 NEAREST_MIPMAP_LINEAR = 9986,
1572 LINEAR_MIPMAP_LINEAR = 9987
1574 struct MaterialLayer {
1576 // Queries the currently set downscaling filter for a material later
1577 // RETURNS: the current downscaling filter
1578 MaterialFilter get_mag_filter() {
1579 return cogl_material_layer_get_mag_filter(&this);
1582 // Queries the currently set downscaling filter for a material layer
1583 // RETURNS: the current downscaling filter
1584 MaterialFilter get_min_filter() {
1585 return cogl_material_layer_get_min_filter(&this);
1588 // Extracts a texture handle for a specific layer.
1590 // <note>In the future Cogl may support purely GLSL based layers; for those
1591 // layers this function which will likely return %COGL_INVALID_HANDLE if you
1592 // try to get the texture handle from them. Considering this scenario, you
1593 // should call cogl_material_layer_get_type() first in order check it is of
1594 // type %COGL_MATERIAL_LAYER_TYPE_TEXTURE before calling this function.</note>
1595 // RETURNS: a #CoglHandle for the texture inside the layer
1596 Handle get_texture() {
1597 return cogl_material_layer_get_texture(&this);
1600 // Gets the wrap mode for the 'p' coordinate of texture lookups on
1601 // this layer. 'p' is the third coordinate.
1602 // RETURNS: the wrap mode value for the p coordinate.
1603 MaterialWrapMode get_wrap_mode_p() {
1604 return cogl_material_layer_get_wrap_mode_p(&this);
1607 // Gets the wrap mode for the 's' coordinate of texture lookups on this layer.
1608 // RETURNS: the wrap mode value for the s coordinate.
1609 MaterialWrapMode get_wrap_mode_s() {
1610 return cogl_material_layer_get_wrap_mode_s(&this);
1613 // Gets the wrap mode for the 't' coordinate of texture lookups on this layer.
1614 // RETURNS: the wrap mode value for the t coordinate.
1615 MaterialWrapMode get_wrap_mode_t() {
1616 return cogl_material_layer_get_wrap_mode_t(&this);
1621 // Available types of layers for a #CoglMaterial. This enumeration
1622 // might be expanded in later versions.
1623 enum MaterialLayerType /* Version 1.0 */ {
1624 TEXTURE = 0
1627 // The wrap mode specifies what happens when texture coordinates
1628 // outside the range 0→1 are used. Note that if the filter mode is
1629 // anything but %COGL_MATERIAL_FILTER_NEAREST then texels outside the
1630 // range 0→1 might be used even when the coordinate is exactly 0 or 1
1631 // because OpenGL will try to sample neighbouring pixels. For example
1632 // if you are trying to render the full texture then you may get
1633 // artifacts around the edges when the pixels from the other side are
1634 // merged in if the wrap mode is set to repeat.
1635 enum MaterialWrapMode /* Version 1.4 */ {
1636 REPEAT = 10497,
1637 CLAMP_TO_EDGE = 33071,
1638 AUTOMATIC = 519
1641 // A CoglMatrix holds a 4x4 transform matrix. This is a single precision,
1642 // column-major matrix which means it is compatible with what OpenGL expects.
1644 // A CoglMatrix can represent transforms such as, rotations, scaling,
1645 // translation, sheering, and linear projections. You can combine these
1646 // transforms by multiplying multiple matrices in the order you want them
1647 // applied.
1649 // The transformation of a vertex (x, y, z, w) by a CoglMatrix is given by:
1651 // |[
1652 // x_new = xx * x + xy * y + xz * z + xw * w
1653 // y_new = yx * x + yy * y + yz * z + yw * w
1654 // z_new = zx * x + zy * y + zz * z + zw * w
1655 // w_new = wx * x + wy * y + wz * z + ww * w
1656 // ]|
1658 // Where w is normally 1
1660 // <note>You must consider the members of the CoglMatrix structure read only,
1661 // and all matrix modifications must be done via the cogl_matrix API. This
1662 // allows Cogl to annotate the matrices internally. Violation of this will give
1663 // undefined results. If you need to initialize a matrix with a constant other
1664 // than the identity matrix you can use cogl_matrix_init_from_array().</note>
1665 struct Matrix {
1666 float xx, yx, zx, wx, xy, yy, zy, wy, xz, yz, zz, wz, xw, yw, zw, ww;
1667 private float[16] inv;
1668 private uint type, flags, _padding3;
1671 // Unintrospectable method: copy() / cogl_matrix_copy()
1672 // Allocates a new #CoglMatrix on the heap and initializes it with
1673 // the same values as @matrix.
1675 // cogl_matrix_free()
1676 // RETURNS: A newly allocated #CoglMatrix which should be freed using
1677 Matrix* copy() {
1678 return cogl_matrix_copy(&this);
1681 // Frees a #CoglMatrix that was previously allocated via a call to
1682 // cogl_matrix_copy().
1683 void free() {
1684 cogl_matrix_free(&this);
1687 // Multiplies @matrix by the given frustum perspective matrix.
1688 // <left>: coord of left vertical clipping plane
1689 // <right>: coord of right vertical clipping plane
1690 // <bottom>: coord of bottom horizontal clipping plane
1691 // <top>: coord of top horizontal clipping plane
1692 // <z_near>: positive distance to near depth clipping plane
1693 // <z_far>: positive distance to far depth clipping plane
1694 void frustum(float left, float right, float bottom, float top, float z_near, float z_far) {
1695 cogl_matrix_frustum(&this, left, right, bottom, top, z_near, z_far);
1698 // Casts @matrix to a float array which can be directly passed to OpenGL.
1699 // RETURNS: a pointer to the float array
1700 float* get_array() {
1701 return cogl_matrix_get_array(&this);
1704 // Gets the inverse transform of a given matrix and uses it to initialize
1705 // a new #CoglMatrix.
1707 // <note>Although the first parameter is annotated as const to indicate
1708 // that the transform it represents isn't modified this function may
1709 // technically save a copy of the inverse transform within the given
1710 // #CoglMatrix so that subsequent requests for the inverse transform may
1711 // avoid costly inversion calculations.</note>
1713 // for degenerate transformations that can't be inverted (in this case the
1714 // @inverse matrix will simply be initialized with the identity matrix)
1715 // RETURNS: %TRUE if the inverse was successfully calculated or %FALSE
1716 // <inverse>: The destination for a 4x4 inverse transformation matrix
1717 int get_inverse(/*out*/ Matrix* inverse) {
1718 return cogl_matrix_get_inverse(&this, inverse);
1721 // Initializes @matrix with the contents of @array
1722 // <array>: A linear array of 16 floats (column-major order)
1723 void init_from_array(float* array) {
1724 cogl_matrix_init_from_array(&this, array);
1727 // Resets matrix to the identity matrix:
1729 // |[
1730 // .xx=1; .xy=0; .xz=0; .xw=0;
1731 // .yx=0; .yy=1; .yz=0; .yw=0;
1732 // .zx=0; .zy=0; .zz=1; .zw=0;
1733 // .wx=0; .wy=0; .wz=0; .ww=1;
1734 // ]|
1735 void init_identity() {
1736 cogl_matrix_init_identity(&this);
1739 // Determines if the given matrix is an identity matrix.
1740 // RETURNS: %TRUE if @matrix is an identity matrix else %FALSE
1741 int is_identity() {
1742 return cogl_matrix_is_identity(&this);
1744 void look_at_EXP(float eye_position_x, float eye_position_y, float eye_position_z, float object_x, float object_y, float object_z, float world_up_x, float world_up_y, float world_up_z) {
1745 cogl_matrix_look_at_EXP(&this, eye_position_x, eye_position_y, eye_position_z, object_x, object_y, object_z, world_up_x, world_up_y, world_up_z);
1748 // Multiplies the two supplied matrices together and stores
1749 // the resulting matrix inside @result.
1751 // <note>It is possible to multiply the @a matrix in-place, so
1752 // @result can be equal to @a but can't be equal to @b.</note>
1753 // <a>: A 4x4 transformation matrix
1754 // <b>: A 4x4 transformation matrix
1755 void multiply(Matrix* a, Matrix* b) {
1756 cogl_matrix_multiply(&this, a, b);
1759 // Multiplies @matrix by a parallel projection matrix.
1760 // <left>: The coordinate for the left clipping plane
1761 // <right>: The coordinate for the right clipping plane
1762 // <bottom>: The coordinate for the bottom clipping plane
1763 // <top>: The coordinate for the top clipping plane
1764 // <z_near>: The coordinate for the near clipping plane (may be negative if the plane is behind the viewer)
1765 // <z_far>: The coordinate for the far clipping plane (may be negative if the plane is behind the viewer)
1766 void ortho(float left, float right, float bottom, float top, float z_near, float z_far) {
1767 cogl_matrix_ortho(&this, left, right, bottom, top, z_near, z_far);
1770 // Multiplies @matrix by the described perspective matrix
1772 // <note>You should be careful not to have to great a @z_far / @z_near ratio
1773 // since that will reduce the effectiveness of depth testing since there wont
1774 // be enough precision to identify the depth of objects near to each
1775 // other.</note>
1776 // <fov_y>: A field of view angle for the Y axis
1777 // <aspect>: The ratio of width to height determining the field of view angle for the x axis.
1778 // <z_near>: The distance to the near clip plane. Never pass 0 and always pass a positive number.
1779 // <z_far>: The distance to the far clip plane. (Should always be positive)
1780 void perspective(float fov_y, float aspect, float z_near, float z_far) {
1781 cogl_matrix_perspective(&this, fov_y, aspect, z_near, z_far);
1784 // Multiplies @matrix with a rotation matrix that applies a rotation
1785 // of @angle degrees around the specified 3D vector.
1786 // <angle>: The angle you want to rotate in degrees
1787 // <x>: X component of your rotation vector
1788 // <y>: Y component of your rotation vector
1789 // <z>: Z component of your rotation vector
1790 void rotate(float angle, float x, float y, float z) {
1791 cogl_matrix_rotate(&this, angle, x, y, z);
1794 // Multiplies @matrix with a transform matrix that scales along the X,
1795 // Y and Z axis.
1796 // <sx>: The X scale factor
1797 // <sy>: The Y scale factor
1798 // <sz>: The Z scale factor
1799 void scale(float sx, float sy, float sz) {
1800 cogl_matrix_scale(&this, sx, sy, sz);
1803 // Transforms a point whos position is given and returned as four float
1804 // components.
1805 // <x>: The X component of your points position
1806 // <y>: The Y component of your points position
1807 // <z>: The Z component of your points position
1808 // <w>: The W component of your points position
1809 void transform_point(/*inout*/ float* x, /*inout*/ float* y, /*inout*/ float* z, /*inout*/ float* w) {
1810 cogl_matrix_transform_point(&this, x, y, z, w);
1813 // Multiplies @matrix with a transform matrix that translates along
1814 // the X, Y and Z axis.
1815 // <x>: The X translation you want to apply
1816 // <y>: The Y translation you want to apply
1817 // <z>: The Z translation you want to apply
1818 void translate(float x, float y, float z) {
1819 cogl_matrix_translate(&this, x, y, z);
1822 // Compares two matrices to see if they represent the same
1823 // transformation. Although internally the matrices may have different
1824 // annotations associated with them and may potentially have a cached
1825 // inverse matrix these are not considered in the comparison.
1826 // <v1>: A 4x4 transformation matrix
1827 // <v2>: A 4x4 transformation matrix
1828 static int equal(const(void)* v1, const(void)* v2) {
1829 return cogl_matrix_equal(v1, v2);
1833 struct Object {
1835 // Unintrospectable method: get_user_data() / cogl_object_get_user_data()
1836 // Finds the user data previously associated with @object using
1837 // the given @key. If no user data has been associated with @object
1838 // for the given @key this function returns NULL.
1840 // with @object using the given @key; or %NULL if no associated
1841 // data is found.
1842 // RETURNS: The user data previously associated
1843 // <key>: The address of a #CoglUserDataKey which provides a unique value with which to index the private data.
1844 void* get_user_data(UserDataKey* key) {
1845 return cogl_object_get_user_data(&this, key);
1848 // Unintrospectable method: set_user_data() / cogl_object_set_user_data()
1849 // Associates some private @user_data with a given #CoglObject. To
1850 // later remove the association call cogl_object_set_user_data() with
1851 // the same @key but NULL for the @user_data.
1852 // <key>: The address of a #CoglUserDataKey which provides a unique value with which to index the private data.
1853 // <user_data>: The data to associate with the given object, or %NULL to remove a previous association.
1854 // <destroy>: A #CoglUserDataDestroyCallback to call if the object is destroyed or if the association is removed by later setting %NULL data for the same key.
1855 void set_user_data(UserDataKey* key, void* user_data, UserDataDestroyCallback destroy) {
1856 cogl_object_set_user_data(&this, key, user_data, destroy);
1859 // Unintrospectable function: ref() / cogl_object_ref()
1860 // Increases the reference count of @handle by 1
1861 // RETURNS: the @object, with its reference count increased
1862 // <object>: a #CoglObject
1863 static void* ref_(void* object) {
1864 return cogl_object_ref(object);
1867 // Unintrospectable function: unref() / cogl_object_unref()
1868 // Drecreases the reference count of @object by 1; if the reference
1869 // count reaches 0, the resources allocated by @object will be freed
1870 // <object>: a #CoglObject
1871 static void unref(void* object) {
1872 cogl_object_unref(object);
1876 enum int PIXEL_FORMAT_24 = 2;
1877 enum int PIXEL_FORMAT_32 = 3;
1878 enum int PREMULT_BIT = 128;
1879 struct Path {
1881 // Unintrospectable method: copy() / cogl_path_copy()
1882 // Returns a new copy of the path in @path. The new path has a
1883 // reference count of 1 so you should unref it with
1884 // cogl_object_unref() if you no longer need it.
1886 // Internally the path will share the data until one of the paths is
1887 // modified so copying paths should be relatively cheap.
1888 // RETURNS: a copy of the path in @path.
1889 Path* /*new*/ copy() {
1890 return cogl_path_copy(&this);
1893 // Adds an elliptical arc segment to the current path. A straight line
1894 // segment will link the current pen location with the first vertex
1895 // of the arc. If you perform a move_to to the arcs start just before
1896 // drawing it you create a free standing arc.
1898 // The angles are measured in degrees where 0° is in the direction of
1899 // the positive X axis and 90° is in the direction of the positive Y
1900 // axis. The angle of the arc begins at @angle_1 and heads towards
1901 // @angle_2 (so if @angle_2 is less than @angle_1 it will decrease,
1902 // otherwise it will increase).
1903 // <center_x>: X coordinate of the elliptical arc center
1904 // <center_y>: Y coordinate of the elliptical arc center
1905 // <radius_x>: X radius of the elliptical arc
1906 // <radius_y>: Y radius of the elliptical arc
1907 // <angle_1>: Angle in degrees at which the arc begin
1908 // <angle_2>: Angle in degrees at which the arc ends
1909 static void arc(float center_x, float center_y, float radius_x, float radius_y, float angle_1, float angle_2) {
1910 cogl_path_arc(center_x, center_y, radius_x, radius_y, angle_1, angle_2);
1913 // Closes the path being constructed by adding a straight line segment
1914 // to it that ends at the first vertex of the path.
1915 static void close() {
1916 cogl_path_close();
1919 // Adds a cubic bezier curve segment to the current path with the given
1920 // second, third and fourth control points and using current pen location
1921 // as the first control point.
1922 // <x_1>: X coordinate of the second bezier control point
1923 // <y_1>: Y coordinate of the second bezier control point
1924 // <x_2>: X coordinate of the third bezier control point
1925 // <y_2>: Y coordinate of the third bezier control point
1926 // <x_3>: X coordinate of the fourth bezier control point
1927 // <y_3>: Y coordinate of the fourth bezier control point
1928 static void curve_to(float x_1, float y_1, float x_2, float y_2, float x_3, float y_3) {
1929 cogl_path_curve_to(x_1, y_1, x_2, y_2, x_3, y_3);
1932 // Constructs an ellipse shape. If there is an existing path this will
1933 // start a new disjoint sub-path.
1934 // <center_x>: X coordinate of the ellipse center
1935 // <center_y>: Y coordinate of the ellipse center
1936 // <radius_x>: X radius of the ellipse
1937 // <radius_y>: Y radius of the ellipse
1938 static void ellipse(float center_x, float center_y, float radius_x, float radius_y) {
1939 cogl_path_ellipse(center_x, center_y, radius_x, radius_y);
1942 // Fills the interior of the constructed shape using the current
1943 // drawing color. The current path is then cleared. To use the path
1944 // again, call cogl_path_fill_preserve() instead.
1946 // The interior of the shape is determined using the fill rule of the
1947 // path. See %CoglPathFillRule for details.
1948 static void fill() {
1949 cogl_path_fill();
1952 // Fills the interior of the constructed shape using the current
1953 // drawing color and preserves the path to be used again. See
1954 // cogl_path_fill() for a description what is considered the interior
1955 // of the shape.
1956 static void fill_preserve() {
1957 cogl_path_fill_preserve();
1960 // Retrieves the fill rule set using cogl_path_set_fill_rule().
1961 // RETURNS: the fill rule that is used for the current path.
1962 static PathFillRule get_fill_rule() {
1963 return cogl_path_get_fill_rule();
1966 // Constructs a straight line shape starting and ending at the given
1967 // coordinates. If there is an existing path this will start a new
1968 // disjoint sub-path.
1969 // <x_1>: X coordinate of the start line vertex
1970 // <y_1>: Y coordinate of the start line vertex
1971 // <x_2>: X coordinate of the end line vertex
1972 // <y_2>: Y coordinate of the end line vertex
1973 static void line(float x_1, float y_1, float x_2, float y_2) {
1974 cogl_path_line(x_1, y_1, x_2, y_2);
1977 // Adds a straight line segment to the current path that ends at the
1978 // given coordinates.
1979 // <x>: X coordinate of the end line vertex
1980 // <y>: Y coordinate of the end line vertex
1981 static void line_to(float x, float y) {
1982 cogl_path_line_to(x, y);
1985 // Moves the pen to the given location. If there is an existing path
1986 // this will start a new disjoint subpath.
1987 // <x>: X coordinate of the pen location to move to.
1988 // <y>: Y coordinate of the pen location to move to.
1989 static void move_to(float x, float y) {
1990 cogl_path_move_to(x, y);
1993 // Clears the current path and starts a new one. Creating a new path
1994 // also resets the fill rule to the default which is
1995 // %COGL_PATH_FILL_RULE_EVEN_ODD.
1996 static void new_() {
1997 cogl_path_new();
2000 // Constructs a polygonal shape of the given number of vertices. If
2001 // there is an existing path this will start a new disjoint sub-path.
2003 // The coords array must contain 2 * num_points values. The first value
2004 // represents the X coordinate of the first vertex, the second value
2005 // represents the Y coordinate of the first vertex, continuing in the same
2006 // fashion for the rest of the vertices.
2007 // <coords>: A pointer to the first element of an array of fixed-point values that specify the vertex coordinates.
2008 // <num_points>: The total number of vertices.
2009 static void polygon(float* coords, int num_points) {
2010 cogl_path_polygon(coords, num_points);
2013 // Constructs a series of straight line segments, starting from the
2014 // first given vertex coordinate. If there is an existing path this
2015 // will start a new disjoint sub-path. Each subsequent segment starts
2016 // where the previous one ended and ends at the next given vertex
2017 // coordinate.
2019 // The coords array must contain 2 * num_points values. The first value
2020 // represents the X coordinate of the first vertex, the second value
2021 // represents the Y coordinate of the first vertex, continuing in the same
2022 // fashion for the rest of the vertices. (num_points - 1) segments will
2023 // be constructed.
2024 // <coords>: A pointer to the first element of an array of fixed-point values that specify the vertex coordinates.
2025 // <num_points>: The total number of vertices.
2026 static void polyline(float* coords, int num_points) {
2027 cogl_path_polyline(coords, num_points);
2030 // Constructs a rectangular shape at the given coordinates. If there
2031 // is an existing path this will start a new disjoint sub-path.
2032 // <x_1>: X coordinate of the top-left corner.
2033 // <y_1>: Y coordinate of the top-left corner.
2034 // <x_2>: X coordinate of the bottom-right corner.
2035 // <y_2>: Y coordinate of the bottom-right corner.
2036 static void rectangle(float x_1, float y_1, float x_2, float y_2) {
2037 cogl_path_rectangle(x_1, y_1, x_2, y_2);
2040 // Adds a cubic bezier curve segment to the current path with the given
2041 // second, third and fourth control points and using current pen location
2042 // as the first control point. The given coordinates are relative to the
2043 // current pen location.
2044 // <x_1>: X coordinate of the second bezier control point
2045 // <y_1>: Y coordinate of the second bezier control point
2046 // <x_2>: X coordinate of the third bezier control point
2047 // <y_2>: Y coordinate of the third bezier control point
2048 // <x_3>: X coordinate of the fourth bezier control point
2049 // <y_3>: Y coordinate of the fourth bezier control point
2050 static void rel_curve_to(float x_1, float y_1, float x_2, float y_2, float x_3, float y_3) {
2051 cogl_path_rel_curve_to(x_1, y_1, x_2, y_2, x_3, y_3);
2054 // Adds a straight line segment to the current path that ends at the
2055 // given coordinates relative to the current pen location.
2056 // <x>: X offset from the current pen location of the end line vertex
2057 // <y>: Y offset from the current pen location of the end line vertex
2058 static void rel_line_to(float x, float y) {
2059 cogl_path_rel_line_to(x, y);
2062 // Moves the pen to the given offset relative to the current pen
2063 // location. If there is an existing path this will start a new
2064 // disjoint subpath.
2065 // <x>: X offset from the current pen location to move the pen to.
2066 // <y>: Y offset from the current pen location to move the pen to.
2067 static void rel_move_to(float x, float y) {
2068 cogl_path_rel_move_to(x, y);
2071 // Constructs a rectangular shape with rounded corners. If there is an
2072 // existing path this will start a new disjoint sub-path.
2073 // <x_1>: X coordinate of the top-left corner.
2074 // <y_1>: Y coordinate of the top-left corner.
2075 // <x_2>: X coordinate of the bottom-right corner.
2076 // <y_2>: Y coordinate of the bottom-right corner.
2077 // <radius>: Radius of the corner arcs.
2078 // <arc_step>: Angle increment resolution for subdivision of the corner arcs.
2079 static void round_rectangle(float x_1, float y_1, float x_2, float y_2, float radius, float arc_step) {
2080 cogl_path_round_rectangle(x_1, y_1, x_2, y_2, radius, arc_step);
2083 // Sets the fill rule of the current path to @fill_rule. This will
2084 // affect how the path is filled when cogl_path_fill() is later
2085 // called. Note that the fill rule state is attached to the path so
2086 // calling cogl_get_path() will preserve the fill rule and calling
2087 // cogl_path_new() will reset the fill rule back to the default.
2088 // <fill_rule>: The new fill rule.
2089 static void set_fill_rule(PathFillRule fill_rule) {
2090 cogl_path_set_fill_rule(fill_rule);
2093 // Strokes the constructed shape using the current drawing color and a
2094 // width of 1 pixel (regardless of the current transformation
2095 // matrix). To current path is then cleared. To use the path again,
2096 // call cogl_path_stroke_preserve() instead.
2097 static void stroke() {
2098 cogl_path_stroke();
2101 // Strokes the constructed shape using the current drawing color and
2102 // preserves the path to be used again.
2103 static void stroke_preserve() {
2104 cogl_path_stroke_preserve();
2109 // #CoglPathFillRule is used to determine how a path is filled. There
2110 // are two options - 'non-zero' and 'even-odd'. To work out whether any
2111 // point will be filled imagine drawing an infinetely long line in any
2112 // direction from that point. The number of times and the direction
2113 // that the edges of the path crosses this line determines whether the
2114 // line is filled as described below. Any open sub paths are treated
2115 // as if there was an extra line joining the first point and the last
2116 // point.
2118 // The default fill rule is %COGL_PATH_FILL_RULE_EVEN_ODD. The fill
2119 // rule is attached to the current path so preserving a path with
2120 // cogl_get_path() also preserves the fill rule. Calling
2121 // cogl_path_new() resets the current fill rule to the default.
2123 // <figure id="fill-rule-non-zero">
2124 // <title>Example of filling various paths using the non-zero rule</title>
2125 // <graphic fileref="fill-rule-non-zero.png" format="PNG"/>
2126 // </figure>
2128 // <figure id="fill-rule-even-odd">
2129 // <title>Example of filling various paths using the even-odd rule</title>
2130 // <graphic fileref="fill-rule-even-odd.png" format="PNG"/>
2131 // </figure>
2132 enum PathFillRule /* Version 1.4 */ {
2133 NON_ZERO = 0,
2134 EVEN_ODD = 1
2136 struct PixelBuffer {
2137 // Unintrospectable function: new_with_size_EXP() / cogl_pixel_buffer_new_with_size_EXP()
2138 static PixelBuffer* new_with_size_EXP(uint width, uint height, PixelFormat format, uint* stride) {
2139 return cogl_pixel_buffer_new_with_size_EXP(width, height, format, stride);
2144 // Pixel formats used by COGL. For the formats with a byte per
2145 // component, the order of the components specify the order in
2146 // increasing memory addresses. So for example
2147 // %COGL_PIXEL_FORMAT_RGB_888 would have the red component in the
2148 // lowest address, green in the next address and blue after that
2149 // regardless of the endinanness of the system.
2151 // For the 16-bit formats the component order specifies the order
2152 // within a 16-bit number from most significant bit to least
2153 // significant. So for %COGL_PIXEL_FORMAT_RGB_565, the red component
2154 // would be in bits 11-15, the green component would be in 6-11 and
2155 // the blue component would be in 1-5. Therefore the order in memory
2156 // depends on the endianness of the system.
2158 // When uploading a texture %COGL_PIXEL_FORMAT_ANY can be used as the
2159 // internal format. Cogl will try to pick the best format to use
2160 // internally and convert the texture data if necessary.
2161 enum PixelFormat /* Version 0.8 */ {
2162 ANY = 0,
2163 A_8 = 17,
2164 RGB_565 = 4,
2165 RGBA_4444 = 21,
2166 RGBA_5551 = 22,
2167 YUV = 7,
2168 G_8 = 8,
2169 RGB_888 = 2,
2170 BGR_888 = 34,
2171 RGBA_8888 = 19,
2172 BGRA_8888 = 51,
2173 ARGB_8888 = 83,
2174 ABGR_8888 = 115,
2175 RGBA_8888_PRE = 147,
2176 BGRA_8888_PRE = 179,
2177 ARGB_8888_PRE = 211,
2178 ABGR_8888_PRE = 243,
2179 RGBA_4444_PRE = 149,
2180 RGBA_5551_PRE = 150
2182 struct Primitive {
2183 // Draw the given @primitive with the current source material.
2184 void draw() {
2185 cogl_primitive_draw(&this);
2187 int get_first_vertex() {
2188 return cogl_primitive_get_first_vertex(&this);
2190 VerticesMode get_mode() {
2191 return cogl_primitive_get_mode(&this);
2193 int get_n_vertices() {
2194 return cogl_primitive_get_n_vertices(&this);
2197 // Replaces all the attributes of the given #CoglPrimitive object.
2198 // <attributes>: A %NULL terminated array of #CoglAttribute pointers
2199 void set_attributes(Attribute** attributes, int n_attributes) {
2200 cogl_primitive_set_attributes(&this, attributes, n_attributes);
2202 void set_first_vertex(int first_vertex) {
2203 cogl_primitive_set_first_vertex(&this, first_vertex);
2205 void set_indices(Indices* indices) {
2206 cogl_primitive_set_indices(&this, indices);
2208 void set_mode(VerticesMode mode) {
2209 cogl_primitive_set_mode(&this, mode);
2211 void set_n_vertices(int n_vertices) {
2212 cogl_primitive_set_n_vertices(&this, n_vertices);
2215 // Unintrospectable function: new() / cogl_primitive_new()
2216 // Combines a set of #CoglAttribute<!-- -->s with a specific draw @mode
2217 // and defines a vertex count so a #CoglPrimitive object can be retained and
2218 // drawn later with no addition information required.
2219 // RETURNS: A newly allocated #CoglPrimitive object
2220 // <mode>: A #CoglVerticesMode defining how to draw the vertices
2221 // <n_vertices>: The number of vertices to process when drawing
2222 alias cogl_primitive_new new_; // Variadic
2224 // Unintrospectable function: new_p2() / cogl_primitive_new_p2()
2225 // Provides a convenient way to describe a primitive, such as a single
2226 // triangle strip or a triangle fan, that will internally allocate the
2227 // necessary #CoglAttributeBuffer storage, describe the position
2228 // attribute with a #CoglAttribute and upload your data.
2230 // For example to draw a convex polygon you can do:
2231 // |[
2232 // CoglVertexP2 triangle[] =
2233 // {
2234 // { 0, 300 },
2235 // { 150, 0, },
2236 // { 300, 300 }
2237 // };
2238 // prim = cogl_primitive_new_p2 (COGL_VERTICES_MODE_TRIANGLE_FAN,
2239 // 3, triangle);
2240 // cogl_primitive_draw (prim);
2241 // ]|
2243 // <note>The primitive API doesn't support drawing with sliced
2244 // textures (since switching between slices implies changing state and
2245 // so that implies multiple primitives need to be submitted). You
2246 // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
2247 // might be used while drawing with this API. If your hardware doesn't
2248 // support non-power of two textures (For example you are using GLES
2249 // 1.1) then you will need to make sure your assets are resized to a
2250 // power-of-two size (though they don't have to be square)</note>
2252 // 1. This can be freed using cogl_object_unref().
2253 // RETURNS: A newly allocated #CoglPrimitive with a reference of
2254 // <mode>: A #CoglVerticesMode defining how to draw the vertices
2255 // <n_vertices>: The number of vertices to process when drawing
2256 // <data>: An array of #CoglVertexP2 vertices
2257 static Primitive* new_p2(VerticesMode mode, int n_vertices, VertexP2* data) {
2258 return cogl_primitive_new_p2(mode, n_vertices, data);
2261 // Unintrospectable function: new_p2c4() / cogl_primitive_new_p2c4()
2262 // Provides a convenient way to describe a primitive, such as a single
2263 // triangle strip or a triangle fan, that will internally allocate the
2264 // necessary #CoglAttributeBuffer storage, describe the position
2265 // and color attributes with #CoglAttribute<!-- -->s and upload
2266 // your data.
2268 // For example to draw a convex polygon with a linear gradient you
2269 // can do:
2270 // |[
2271 // CoglVertexP2C4 triangle[] =
2272 // {
2273 // { 0, 300, 0xff, 0x00, 0x00, 0xff },
2274 // { 150, 0, 0x00, 0xff, 0x00, 0xff },
2275 // { 300, 300, 0xff, 0x00, 0x00, 0xff }
2276 // };
2277 // prim = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
2278 // 3, triangle);
2279 // cogl_primitive_draw (prim);
2280 // ]|
2282 // <note>The primitive API doesn't support drawing with sliced
2283 // textures (since switching between slices implies changing state and
2284 // so that implies multiple primitives need to be submitted). You
2285 // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
2286 // might be used while drawing with this API. If your hardware doesn't
2287 // support non-power of two textures (For example you are using GLES
2288 // 1.1) then you will need to make sure your assets are resized to a
2289 // power-of-two size (though they don't have to be square)</note>
2291 // 1. This can be freed using cogl_object_unref().
2292 // RETURNS: A newly allocated #CoglPrimitive with a reference of
2293 // <mode>: A #CoglVerticesMode defining how to draw the vertices
2294 // <n_vertices>: The number of vertices to process when drawing
2295 // <data>: An array of #CoglVertexP2C4 vertices
2296 static Primitive* new_p2c4(VerticesMode mode, int n_vertices, VertexP2C4* data) {
2297 return cogl_primitive_new_p2c4(mode, n_vertices, data);
2300 // Unintrospectable function: new_p2t2() / cogl_primitive_new_p2t2()
2301 // Provides a convenient way to describe a primitive, such as a single
2302 // triangle strip or a triangle fan, that will internally allocate the
2303 // necessary #CoglAttributeBuffer storage, describe the position and
2304 // texture coordinate attributes with #CoglAttribute<!-- -->s and
2305 // upload your data.
2307 // For example to draw a convex polygon with texture mapping you can
2308 // do:
2309 // |[
2310 // CoglVertexP2T2 triangle[] =
2311 // {
2312 // { 0, 300, 0.0, 1.0},
2313 // { 150, 0, 0.5, 0.0},
2314 // { 300, 300, 1.0, 1.0}
2315 // };
2316 // prim = cogl_primitive_new_p2t2 (COGL_VERTICES_MODE_TRIANGLE_FAN,
2317 // 3, triangle);
2318 // cogl_primitive_draw (prim);
2319 // ]|
2321 // <note>The primitive API doesn't support drawing with sliced
2322 // textures (since switching between slices implies changing state and
2323 // so that implies multiple primitives need to be submitted). You
2324 // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
2325 // might be used while drawing with this API. If your hardware doesn't
2326 // support non-power of two textures (For example you are using GLES
2327 // 1.1) then you will need to make sure your assets are resized to a
2328 // power-of-two size (though they don't have to be square)</note>
2330 // 1. This can be freed using cogl_object_unref().
2331 // RETURNS: A newly allocated #CoglPrimitive with a reference of
2332 // <mode>: A #CoglVerticesMode defining how to draw the vertices
2333 // <n_vertices>: The number of vertices to process when drawing
2334 // <data>: An array of #CoglVertexP2T2 vertices
2335 static Primitive* new_p2t2(VerticesMode mode, int n_vertices, VertexP2T2* data) {
2336 return cogl_primitive_new_p2t2(mode, n_vertices, data);
2339 // Unintrospectable function: new_p2t2c4() / cogl_primitive_new_p2t2c4()
2340 // Provides a convenient way to describe a primitive, such as a single
2341 // triangle strip or a triangle fan, that will internally allocate the
2342 // necessary #CoglAttributeBuffer storage, describe the position, texture
2343 // coordinate and color attributes with #CoglAttribute<!-- -->s and
2344 // upload your data.
2346 // For example to draw a convex polygon with texture mapping and a
2347 // linear gradient you can do:
2348 // |[
2349 // CoglVertexP2T2C4 triangle[] =
2350 // {
2351 // { 0, 300, 0.0, 1.0, 0xff, 0x00, 0x00, 0xff},
2352 // { 150, 0, 0.5, 0.0, 0x00, 0xff, 0x00, 0xff},
2353 // { 300, 300, 1.0, 1.0, 0xff, 0x00, 0x00, 0xff}
2354 // };
2355 // prim = cogl_primitive_new_p2t2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
2356 // 3, triangle);
2357 // cogl_primitive_draw (prim);
2358 // ]|
2360 // <note>The primitive API doesn't support drawing with sliced
2361 // textures (since switching between slices implies changing state and
2362 // so that implies multiple primitives need to be submitted). You
2363 // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
2364 // might be used while drawing with this API. If your hardware doesn't
2365 // support non-power of two textures (For example you are using GLES
2366 // 1.1) then you will need to make sure your assets are resized to a
2367 // power-of-two size (though they don't have to be square)</note>
2369 // 1. This can be freed using cogl_object_unref().
2370 // RETURNS: A newly allocated #CoglPrimitive with a reference of
2371 // <mode>: A #CoglVerticesMode defining how to draw the vertices
2372 // <n_vertices>: The number of vertices to process when drawing
2373 // <data>: An array of #CoglVertexP2T2C4 vertices
2374 static Primitive* new_p2t2c4(VerticesMode mode, int n_vertices, VertexP2T2C4* data) {
2375 return cogl_primitive_new_p2t2c4(mode, n_vertices, data);
2378 // Unintrospectable function: new_p3() / cogl_primitive_new_p3()
2379 // Provides a convenient way to describe a primitive, such as a single
2380 // triangle strip or a triangle fan, that will internally allocate the
2381 // necessary #CoglAttributeBuffer storage, describe the position
2382 // attribute with a #CoglAttribute and upload your data.
2384 // For example to draw a convex polygon you can do:
2385 // |[
2386 // CoglVertexP3 triangle[] =
2387 // {
2388 // { 0, 300, 0 },
2389 // { 150, 0, 0 },
2390 // { 300, 300, 0 }
2391 // };
2392 // prim = cogl_primitive_new_p3 (COGL_VERTICES_MODE_TRIANGLE_FAN,
2393 // 3, triangle);
2394 // cogl_primitive_draw (prim);
2395 // ]|
2397 // <note>The primitive API doesn't support drawing with sliced
2398 // textures (since switching between slices implies changing state and
2399 // so that implies multiple primitives need to be submitted). You
2400 // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
2401 // might be used while drawing with this API. If your hardware doesn't
2402 // support non-power of two textures (For example you are using GLES
2403 // 1.1) then you will need to make sure your assets are resized to a
2404 // power-of-two size (though they don't have to be square)</note>
2406 // 1. This can be freed using cogl_object_unref().
2407 // RETURNS: A newly allocated #CoglPrimitive with a reference of
2408 // <mode>: A #CoglVerticesMode defining how to draw the vertices
2409 // <n_vertices>: The number of vertices to process when drawing
2410 // <data>: An array of #CoglVertexP3 vertices
2411 static Primitive* new_p3(VerticesMode mode, int n_vertices, VertexP3* data) {
2412 return cogl_primitive_new_p3(mode, n_vertices, data);
2415 // Unintrospectable function: new_p3c4() / cogl_primitive_new_p3c4()
2416 // Provides a convenient way to describe a primitive, such as a single
2417 // triangle strip or a triangle fan, that will internally allocate the
2418 // necessary #CoglAttributeBuffer storage, describe the position
2419 // and color attributes with #CoglAttribute<!-- -->s and upload
2420 // your data.
2422 // For example to draw a convex polygon with a linear gradient you
2423 // can do:
2424 // |[
2425 // CoglVertexP3C4 triangle[] =
2426 // {
2427 // { 0, 300, 0, 0xff, 0x00, 0x00, 0xff },
2428 // { 150, 0, 0, 0x00, 0xff, 0x00, 0xff },
2429 // { 300, 300, 0, 0xff, 0x00, 0x00, 0xff }
2430 // };
2431 // prim = cogl_primitive_new_p3c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
2432 // 3, triangle);
2433 // cogl_primitive_draw (prim);
2434 // ]|
2436 // <note>The primitive API doesn't support drawing with sliced
2437 // textures (since switching between slices implies changing state and
2438 // so that implies multiple primitives need to be submitted). You
2439 // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
2440 // might be used while drawing with this API. If your hardware doesn't
2441 // support non-power of two textures (For example you are using GLES
2442 // 1.1) then you will need to make sure your assets are resized to a
2443 // power-of-two size (though they don't have to be square)</note>
2445 // 1. This can be freed using cogl_object_unref().
2446 // RETURNS: A newly allocated #CoglPrimitive with a reference of
2447 // <mode>: A #CoglVerticesMode defining how to draw the vertices
2448 // <n_vertices>: The number of vertices to process when drawing
2449 // <data>: An array of #CoglVertexP3C4 vertices
2450 static Primitive* new_p3c4(VerticesMode mode, int n_vertices, VertexP3C4* data) {
2451 return cogl_primitive_new_p3c4(mode, n_vertices, data);
2454 // Unintrospectable function: new_p3t2() / cogl_primitive_new_p3t2()
2455 // Provides a convenient way to describe a primitive, such as a single
2456 // triangle strip or a triangle fan, that will internally allocate the
2457 // necessary #CoglAttributeBuffer storage, describe the position and
2458 // texture coordinate attributes with #CoglAttribute<!-- -->s and
2459 // upload your data.
2461 // For example to draw a convex polygon with texture mapping you can
2462 // do:
2463 // |[
2464 // CoglVertexP3T2 triangle[] =
2465 // {
2466 // { 0, 300, 0, 0.0, 1.0},
2467 // { 150, 0, 0, 0.5, 0.0},
2468 // { 300, 300, 0, 1.0, 1.0}
2469 // };
2470 // prim = cogl_primitive_new_p3t2 (COGL_VERTICES_MODE_TRIANGLE_FAN,
2471 // 3, triangle);
2472 // cogl_primitive_draw (prim);
2473 // ]|
2475 // <note>The primitive API doesn't support drawing with sliced
2476 // textures (since switching between slices implies changing state and
2477 // so that implies multiple primitives need to be submitted). You
2478 // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
2479 // might be used while drawing with this API. If your hardware doesn't
2480 // support non-power of two textures (For example you are using GLES
2481 // 1.1) then you will need to make sure your assets are resized to a
2482 // power-of-two size (though they don't have to be square)</note>
2484 // 1. This can be freed using cogl_object_unref().
2485 // RETURNS: A newly allocated #CoglPrimitive with a reference of
2486 // <mode>: A #CoglVerticesMode defining how to draw the vertices
2487 // <n_vertices>: The number of vertices to process when drawing
2488 // <data>: An array of #CoglVertexP3T2 vertices
2489 static Primitive* new_p3t2(VerticesMode mode, int n_vertices, VertexP3T2* data) {
2490 return cogl_primitive_new_p3t2(mode, n_vertices, data);
2493 // Unintrospectable function: new_p3t2c4() / cogl_primitive_new_p3t2c4()
2494 // Provides a convenient way to describe a primitive, such as a single
2495 // triangle strip or a triangle fan, that will internally allocate the
2496 // necessary #CoglAttributeBuffer storage, describe the position, texture
2497 // coordinate and color attributes with #CoglAttribute<!-- -->s and
2498 // upload your data.
2500 // For example to draw a convex polygon with texture mapping and a
2501 // linear gradient you can do:
2502 // |[
2503 // CoglVertexP3T2C4 triangle[] =
2504 // {
2505 // { 0, 300, 0, 0.0, 1.0, 0xff, 0x00, 0x00, 0xff},
2506 // { 150, 0, 0, 0.5, 0.0, 0x00, 0xff, 0x00, 0xff},
2507 // { 300, 300, 0, 1.0, 1.0, 0xff, 0x00, 0x00, 0xff}
2508 // };
2509 // prim = cogl_primitive_new_p3t2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN,
2510 // 3, triangle);
2511 // cogl_primitive_draw (prim);
2512 // ]|
2514 // <note>The primitive API doesn't support drawing with sliced
2515 // textures (since switching between slices implies changing state and
2516 // so that implies multiple primitives need to be submitted). You
2517 // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
2518 // might be used while drawing with this API. If your hardware doesn't
2519 // support non-power of two textures (For example you are using GLES
2520 // 1.1) then you will need to make sure your assets are resized to a
2521 // power-of-two size (though they don't have to be square)</note>
2523 // 1. This can be freed using cogl_object_unref().
2524 // RETURNS: A newly allocated #CoglPrimitive with a reference of
2525 // <mode>: A #CoglVerticesMode defining how to draw the vertices
2526 // <n_vertices>: The number of vertices to process when drawing
2527 // <data>: An array of #CoglVertexP3T2C4 vertices
2528 static Primitive* new_p3t2c4(VerticesMode mode, int n_vertices, VertexP3T2C4* data) {
2529 return cogl_primitive_new_p3t2c4(mode, n_vertices, data);
2531 // Unintrospectable function: new_with_attributes() / cogl_primitive_new_with_attributes()
2532 static Primitive* new_with_attributes(VerticesMode mode, int n_vertices, Attribute** attributes, int n_attributes) {
2533 return cogl_primitive_new_with_attributes(mode, n_vertices, attributes, n_attributes);
2538 // A quaternion is comprised of a scalar component and a 3D vector
2539 // component. The scalar component is normally referred to as w and the
2540 // vector might either be referred to as v or a (for axis) or expanded
2541 // with the individual components: (x, y, z) A full quaternion would
2542 // then be written as <pre>[w (x, y, z)]</pre>.
2544 // Quaternions can be considered to represent an axis and angle
2545 // pair although sadly these numbers are buried somewhat under some
2546 // maths...
2548 // For the curious you can see here that a given axis (a) and angle (𝜃)
2549 // pair are represented in a quaternion as follows:
2550 // |[
2551 // [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )]
2552 // ]|
2554 // Unit Quaternions:
2555 // When using Quaternions to represent spatial orientations for 3D
2556 // graphics it's always assumed you have a unit quaternion. The
2557 // magnitude of a quaternion is defined as:
2558 // |[
2559 // sqrt (w² + x² + y² + z²)
2560 // ]|
2561 // and a unit quaternion satisfies this equation:
2562 // |[
2563 // w² + x² + y² + z² = 1
2564 // ]|
2566 // Thankfully most of the time we don't actually have to worry about
2567 // the maths that goes on behind the scenes but if you are curious to
2568 // learn more here are some external references:
2570 // <itemizedlist>
2571 // <listitem>
2572 // <ulink url="http://mathworld.wolfram.com/Quaternion.html"/>
2573 // </listitem>
2574 // <listitem>
2575 // <ulink url="http://www.gamedev.net/reference/articles/article1095.asp"/>
2576 // </listitem>
2577 // <listitem>
2578 // <ulink url="http://www.cprogramming.com/tutorial/3d/quaternions.html"/>
2579 // </listitem>
2580 // <listitem>
2581 // <ulink url="http://www.isner.com/tutorials/quatSpells/quaternion_spells_12.htm"/>
2582 // </listitem>
2583 // <listitem>
2584 // 3D Maths Primer for Graphics and Game Development ISBN-10: 1556229119
2585 // </listitem>
2586 // <listitem>
2587 // <ulink url="http://www.cs.caltech.edu/courses/cs171/quatut.pdf"/>
2588 // </listitem>
2589 // <listitem>
2590 // <ulink url="http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56"/>
2591 // </listitem>
2592 // </itemizedlist>
2594 // rotation it is sin(𝜃/2)*axis.x
2595 // rotation it is sin(𝜃/2)*axis.y
2596 // rotation it is sin(𝜃/2)*axis.z
2597 struct Quaternion {
2598 float w, x, y, z, padding0, padding1, padding2, padding3;
2601 // Unintrospectable method: copy() / cogl_quaternion_copy()
2602 // Allocates a new #CoglQuaternion on the stack and initializes it with
2603 // the same values as @src.
2605 // using cogl_quaternion_free()
2606 // RETURNS: A newly allocated #CoglQuaternion which should be freed
2607 Quaternion* copy() {
2608 return cogl_quaternion_copy(&this);
2610 float dot_product(Quaternion* b) {
2611 return cogl_quaternion_dot_product(&this, b);
2614 // Frees a #CoglQuaternion that was previously allocated via
2615 // cogl_quaternion_copy().
2616 void free() {
2617 cogl_quaternion_free(&this);
2619 float get_rotation_angle() {
2620 return cogl_quaternion_get_rotation_angle(&this);
2622 void get_rotation_axis(Vector3* vector) {
2623 cogl_quaternion_get_rotation_axis(&this, vector);
2626 // Initializes a quaternion that rotates @angle degrees around the
2627 // axis vector (@x, @y, @z). The axis vector does not need to be
2628 // normalized.
2630 // rotated @angle degrees around the axis vector (@x, @y, @z)
2631 // RETURNS: A normalized, unit quaternion representing an orientation
2632 // <angle>: The angle you want to rotate around the given axis
2633 // <x>: The x component of your axis vector about which you want to rotate.
2634 // <y>: The y component of your axis vector about which you want to rotate.
2635 // <z>: The z component of your axis vector about which you want to rotate.
2636 void init(float angle, float x, float y, float z) {
2637 cogl_quaternion_init(&this, angle, x, y, z);
2640 // Initializes a quaternion that rotates @angle degrees around the
2641 // given @axis vector. The axis vector does not need to be
2642 // normalized.
2644 // rotated @angle degrees around the given @axis vector.
2645 // RETURNS: A normalized, unit quaternion representing an orientation
2646 // <axis>: your axis vector about which you want to rotate.
2647 void init_from_angle_vector(float angle, Vector3* axis) {
2648 cogl_quaternion_init_from_angle_vector(&this, angle, axis);
2651 // Initializes a [w (x, y,z)] quaternion directly from an array of 4
2652 // floats: [w,x,y,z].
2653 // <array>: An array of 4 floats (x,y,z),w
2654 void init_from_array(float* array) {
2655 cogl_quaternion_init_from_array(&this, array);
2657 void init_from_euler(Euler* euler) {
2658 cogl_quaternion_init_from_euler(&this, euler);
2661 // XXX: check which direction this rotates
2662 // <angle>: The angle to rotate around the x axis
2663 void init_from_x_rotation(float angle) {
2664 cogl_quaternion_init_from_x_rotation(&this, angle);
2666 // <angle>: The angle to rotate around the y axis
2667 void init_from_y_rotation(float angle) {
2668 cogl_quaternion_init_from_y_rotation(&this, angle);
2670 // <angle>: The angle to rotate around the y axis
2671 void init_from_z_rotation(float angle) {
2672 cogl_quaternion_init_from_z_rotation(&this, angle);
2675 // Initializes the quaternion with the canonical quaternion identity
2676 // [1 (0, 0, 0)] which represents no rotation. Multiplying a
2677 // quaternion with this identity leaves the quaternion unchanged.
2679 // You might also want to consider using
2680 // cogl_get_static_identity_quaternion().
2681 void init_identity() {
2682 cogl_quaternion_init_identity(&this);
2684 void invert() {
2685 cogl_quaternion_invert(&this);
2688 // This combines the rotations of two quaternions into @result. The
2689 // operation is not commutative so the order is important because AxB
2690 // != BxA. Cogl follows the standard convention for quaternions here
2691 // so the rotations are applied @right to @left. This is similar to the
2692 // combining of matrices.
2693 // <left>: The second #CoglQuaternion rotation to apply
2694 // <right>: The first #CoglQuaternion rotation to apply
2695 void multiply(Quaternion* left, Quaternion* right) {
2696 cogl_quaternion_multiply(&this, left, right);
2699 // Performs a normalized linear interpolation between two quaternions.
2700 // That is it does a linear interpolation of the quaternion components
2701 // and then normalizes the result. This will follow the shortest arc
2702 // between the two orientations (just like the slerp() function) but
2703 // will not progress at a constant speed. Unlike slerp() nlerp is
2704 // commutative which is useful if you are blending animations
2705 // together. (I.e. nlerp (tmp, a, b) followed by nlerp (result, tmp,
2706 // d) is the same as nlerp (tmp, a, d) followed by nlerp (result, tmp,
2707 // b)). Finally nlerp is cheaper than slerp so it can be a good choice
2708 // if you don't need the constant speed property of the slerp() function.
2710 // Notable properties:
2711 // <itemizedlist>
2712 // <listitem>
2713 // commutative: Yes
2714 // </listitem>
2715 // <listitem>
2716 // constant velocity: No
2717 // </listitem>
2718 // <listitem>
2719 // torque minimal (travels along the surface of the 4-sphere): Yes
2720 // </listitem>
2721 // <listitem>
2722 // faster than cogl_quaternion_slerp()
2723 // </listitem>
2724 // </itemizedlist>
2725 // <a>: The first #CoglQuaternion
2726 // <b>: The second #CoglQuaternion
2727 // <t>: The factor in the range [0,1] used to interpolate between quaterion @a and @b.
2728 void nlerp(Quaternion* a, Quaternion* b, float t) {
2729 cogl_quaternion_nlerp(&this, a, b, t);
2731 void normalize() {
2732 cogl_quaternion_normalize(&this);
2734 void pow(float exponent) {
2735 cogl_quaternion_pow(&this, exponent);
2738 // Performs a spherical linear interpolation between two quaternions.
2740 // Noteable properties:
2741 // <itemizedlist>
2742 // <listitem>
2743 // commutative: No
2744 // </listitem>
2745 // <listitem>
2746 // constant velocity: Yes
2747 // </listitem>
2748 // <listitem>
2749 // torque minimal (travels along the surface of the 4-sphere): Yes
2750 // </listitem>
2751 // <listitem>
2752 // more expensive than cogl_quaternion_nlerp()
2753 // </listitem>
2754 // </itemizedlist>
2755 void slerp(Quaternion* a, Quaternion* b, float t) {
2756 cogl_quaternion_slerp(&this, a, b, t);
2758 void squad(Quaternion* prev, Quaternion* a, Quaternion* b, Quaternion* next, float t) {
2759 cogl_quaternion_squad(&this, prev, a, b, next, t);
2762 // Compares that all the components of quaternions @a and @b are
2763 // equal.
2765 // An epsilon value is not used to compare the float components, but
2766 // the == operator is at least used so that 0 and -0 are considered
2767 // equal.
2768 // RETURNS: %TRUE if the quaternions are equal else %FALSE.
2769 // <v1>: A #CoglQuaternion
2770 // <v2>: A #CoglQuaternion
2771 static int equal(const(void)* v1, const(void)* v2) {
2772 return cogl_quaternion_equal(v1, v2);
2776 enum int RADIANS_TO_DEGREES = 3754936;
2777 // Flags for cogl_read_pixels()
2778 enum ReadPixelsFlags /* Version 1.0 */ {
2779 COLOR_BUFFER = 1
2781 enum RendererError {
2782 NOT_FOUND = 0,
2783 XLIB_DISPLAY_OPEN = 1
2785 enum int SQRTI_ARG_10_PERCENT = 5590;
2786 enum int SQRTI_ARG_5_PERCENT = 210;
2787 enum int SQRTI_ARG_MAX = 4194303;
2788 // Types of shaders
2789 enum ShaderType /* Version 1.0 */ {
2790 VERTEX = 0,
2791 FRAGMENT = 1
2793 enum int TEXTURE_MAX_WASTE = 127;
2794 struct Texture2D {
2797 // Error codes that can be thrown when allocating textures.
2798 enum TextureError /* Version 2.0 */ {
2799 SIZE = 0,
2800 FORMAT = 1,
2801 BAD_PARAMETER = 2
2803 // Flags to pass to the cogl_texture_new_* family of functions.
2804 enum TextureFlags /* Version 1.0 */ {
2805 NONE = 0,
2806 NO_AUTO_MIPMAP = 1,
2807 NO_SLICING = 2,
2808 NO_ATLAS = 4
2810 // Used to specify vertex information when calling cogl_polygon()
2811 struct TextureVertex {
2812 float x, y, z, tx, ty;
2813 Color color;
2816 enum int UNORDERED_MASK = 15;
2817 enum int UNPREMULT_MASK = 127;
2819 // When associating private data with a #CoglObject a callback can be
2820 // given which will be called either if the object is destroyed or if
2821 // cogl_object_set_user_data() is called with NULL user_data for the
2822 // same key.
2823 // <user_data>: The data whos association with a #CoglObject has been destoyed.
2824 extern (C) alias void function (void* user_data) UserDataDestroyCallback;
2827 // A #CoglUserDataKey is used to declare a key for attaching data to a
2828 // #CoglObject using cogl_object_set_user_data. The typedef only exists as a
2829 // formality to make code self documenting since only the unique address of a
2830 // #CoglUserDataKey is used.
2832 // Typically you would declare a static #CoglUserDataKey and set private data
2833 // on an object something like this:
2835 // |[
2836 // static CoglUserDataKey path_private_key;
2838 // static void
2839 // destroy_path_private_cb (void *data)
2840 // {
2841 // g_free (data);
2842 // }
2844 // static void
2845 // my_path_set_data (CoglPath *path, void *data)
2846 // {
2847 // cogl_object_set_user_data (COGL_OBJECT (path),
2848 // &private_key,
2849 // data,
2850 // destroy_path_private_cb);
2851 // }
2852 // ]|
2853 struct UserDataKey /* Version 1.4 */ {
2854 int unused;
2857 struct Vector3 {
2858 float x, y, z;
2860 void add_EXP(Vector3* a, Vector3* b) {
2861 cogl_vector3_add_EXP(&this, a, b);
2863 // Unintrospectable method: copy_EXP() / cogl_vector3_copy_EXP()
2864 Vector3* copy_EXP() {
2865 return cogl_vector3_copy_EXP(&this);
2867 void cross_product_EXP(Vector3* u, Vector3* v) {
2868 cogl_vector3_cross_product_EXP(&this, u, v);
2870 float distance_EXP(Vector3* b) {
2871 return cogl_vector3_distance_EXP(&this, b);
2873 void divide_scalar_EXP(float scalar) {
2874 cogl_vector3_divide_scalar_EXP(&this, scalar);
2876 float dot_product_EXP(Vector3* b) {
2877 return cogl_vector3_dot_product_EXP(&this, b);
2879 int equal_with_epsilon_EXP(Vector3* vector1, float epsilon) {
2880 return cogl_vector3_equal_with_epsilon_EXP(&this, vector1, epsilon);
2882 void free_EXP() {
2883 cogl_vector3_free_EXP(&this);
2885 void init_EXP(float x, float y, float z) {
2886 cogl_vector3_init_EXP(&this, x, y, z);
2888 void init_zero_EXP() {
2889 cogl_vector3_init_zero_EXP(&this);
2891 void invert_EXP() {
2892 cogl_vector3_invert_EXP(&this);
2894 float magnitude_EXP() {
2895 return cogl_vector3_magnitude_EXP(&this);
2897 void multiply_scalar_EXP(float scalar) {
2898 cogl_vector3_multiply_scalar_EXP(&this, scalar);
2900 void normalize_EXP() {
2901 cogl_vector3_normalize_EXP(&this);
2903 void subtract_EXP(Vector3* a, Vector3* b) {
2904 cogl_vector3_subtract_EXP(&this, a, b);
2906 static int equal_EXP(const(void)* v1, const(void)* v2) {
2907 return cogl_vector3_equal_EXP(v1, v2);
2912 // A convenience vertex definition that can be used with
2913 // cogl_primitive_new_with_v2_attributes().
2914 struct VertexP2 /* Version 1.6 */ {
2915 float x, y;
2919 // A convenience vertex definition that can be used with
2920 // cogl_primitive_new_with_v2c4_attributes().
2921 struct VertexP2C4 /* Version 1.6 */ {
2922 float x, y;
2923 ubyte r, g, b, a;
2927 // A convenience vertex definition that can be used with
2928 // cogl_primitive_new_with_v2t2_attributes().
2929 struct VertexP2T2 /* Version 1.6 */ {
2930 float x, y, s, t;
2934 // A convenience vertex definition that can be used with
2935 // cogl_primitive_new_with_v3t2c4_attributes().
2936 struct VertexP2T2C4 /* Version 1.6 */ {
2937 float x, y, s, t;
2938 ubyte r, g, b, a;
2942 // A convenience vertex definition that can be used with
2943 // cogl_primitive_new_with_v3_attributes().
2944 struct VertexP3 /* Version 1.6 */ {
2945 float x, y, z;
2949 // A convenience vertex definition that can be used with
2950 // cogl_primitive_new_with_v3c4_attributes().
2951 struct VertexP3C4 /* Version 1.6 */ {
2952 float x, y, z;
2953 ubyte r, g, b, a;
2957 // A convenience vertex definition that can be used with
2958 // cogl_primitive_new_with_v3t2_attributes().
2959 struct VertexP3T2 /* Version 1.6 */ {
2960 float x, y, z, s, t;
2964 // A convenience vertex definition that can be used with
2965 // cogl_primitive_new_with_v3t2c4_attributes().
2966 struct VertexP3T2C4 /* Version 1.6 */ {
2967 float x, y, z, s, t;
2968 ubyte r, g, b, a;
2971 // Different ways of interpreting vertices when drawing.
2972 enum VerticesMode /* Version 1.0 */ {
2973 POINTS = 0,
2974 LINES = 1,
2975 LINE_LOOP = 2,
2976 LINE_STRIP = 3,
2977 TRIANGLES = 4,
2978 TRIANGLE_STRIP = 5,
2979 TRIANGLE_FAN = 6
2981 enum WinsysFeature {
2982 MULTIPLE_ONSCREEN = 0,
2983 SWAP_THROTTLE = 1,
2984 VBLANK_COUNTER = 2,
2985 VBLANK_WAIT = 3,
2986 TEXTURE_FROM_PIXMAP = 4,
2987 SWAP_BUFFERS_EVENT = 5,
2988 SWAP_REGION = 6,
2989 SWAP_REGION_THROTTLE = 7,
2990 SWAP_REGION_SYNCHRONIZED = 8,
2991 N_FEATURES = 9
2993 // Unintrospectable callback: XlibFilterFunc() / ()
2994 extern (C) alias FilterReturn function (XEvent* event, void* data) XlibFilterFunc;
2996 struct _ColorSizeCheck {
2997 char[/*GIR: -1*/ 0] compile_time_assert_CoglColor_size;
3000 struct _EulerSizeCheck {
3001 char[/*GIR: -1*/ 0] compile_time_assert_CoglEuler_size;
3004 struct _MatrixSizeCheck {
3005 char[/*GIR: -1*/ 0] compile_time_assert_CoglMatrix_size;
3008 struct _QuaternionSizeCheck {
3009 char[/*GIR: -1*/ 0] compile_time_assert_CoglQuaternion_size;
3012 struct _TextureVertexSizeCheck {
3013 char[/*GIR: -1*/ 0] compile_time_assert_CoglTextureVertex_size;
3017 // Unintrospectable function: angle_cos() / cogl_angle_cos()
3018 // Computes the cosine of @angle
3019 // RETURNS: the cosine of the passed angle
3020 // <angle>: an angle expressed using #CoglAngle
3021 static Fixed angle_cos(Angle angle) {
3022 return cogl_angle_cos(angle);
3026 // Unintrospectable function: angle_sin() / cogl_angle_sin()
3027 // Computes the sine of @angle
3028 // RETURNS: the sine of the passed angle
3029 // <angle>: an angle expressed using #CoglAngle
3030 static Fixed angle_sin(Angle angle) {
3031 return cogl_angle_sin(angle);
3035 // Unintrospectable function: angle_tan() / cogl_angle_tan()
3036 // Computes the tangent of @angle
3037 // RETURNS: the tangent of the passed angle
3038 // <angle>: an angle expressed using #CoglAngle
3039 static Fixed angle_tan(Angle angle) {
3040 return cogl_angle_tan(angle);
3044 // We do not advise nor reliably support the interleaving of raw GL drawing and
3045 // Cogl drawing functions, but if you insist, cogl_begin_gl() and cogl_end_gl()
3046 // provide a simple mechanism that may at least give you a fighting chance of
3047 // succeeding.
3049 // Note: this doesn't help you modify the behaviour of Cogl drawing functions
3050 // through the modification of GL state; that will never be reliably supported,
3051 // but if you are trying to do something like:
3053 // |[
3054 // {
3055 // - setup some OpenGL state.
3056 // - draw using OpenGL (e.g. glDrawArrays() )
3057 // - reset modified OpenGL state.
3058 // - continue using Cogl to draw
3059 // }
3060 // ]|
3062 // You should surround blocks of drawing using raw GL with cogl_begin_gl()
3063 // and cogl_end_gl():
3065 // |[
3066 // {
3067 // cogl_begin_gl ();
3068 // - setup some OpenGL state.
3069 // - draw using OpenGL (e.g. glDrawArrays() )
3070 // - reset modified OpenGL state.
3071 // cogl_end_gl ();
3072 // - continue using Cogl to draw
3073 // }
3074 // ]|
3076 // Don't ever try and do:
3078 // |[
3079 // {
3080 // - setup some OpenGL state.
3081 // - use Cogl to draw
3082 // - reset modified OpenGL state.
3083 // }
3084 // ]|
3086 // When the internals of Cogl evolves, this is very liable to break.
3088 // This function will flush all batched primitives, and subsequently flush
3089 // all internal Cogl state to OpenGL as if it were going to draw something
3090 // itself.
3092 // The result is that the OpenGL modelview matrix will be setup; the state
3093 // corresponding to the current source material will be set up and other world
3094 // state such as backface culling, depth and fogging enabledness will be sent
3095 // to OpenGL.
3097 // <note>No special material state is flushed, so if you want Cogl to setup a
3098 // simplified material state it is your responsibility to set a simple source
3099 // material before calling cogl_begin_gl(). E.g. by calling
3100 // cogl_set_source_color4ub().</note>
3102 // <note>It is your responsibility to restore any OpenGL state that you modify
3103 // to how it was after calling cogl_begin_gl() if you don't do this then the
3104 // result of further Cogl calls is undefined.</note>
3106 // <note>You can not nest begin/end blocks.</note>
3108 // Again we would like to stress, we do not advise the use of this API and if
3109 // possible we would prefer to improve Cogl than have developers require raw
3110 // OpenGL.
3111 static void begin_gl() {
3112 cogl_begin_gl();
3115 static GLib2.Quark bitmap_error_quark() {
3116 return cogl_bitmap_error_quark();
3120 // Parses an image file enough to extract the width and height
3121 // of the bitmap.
3122 // RETURNS: %TRUE if the image was successfully parsed
3123 // <filename>: the file to check
3124 // <width>: return location for the bitmap width, or %NULL
3125 // <height>: return location for the bitmap height, or %NULL
3126 static int bitmap_get_size_from_file(char* filename, /*out*/ int* width, /*out*/ int* height) {
3127 return cogl_bitmap_get_size_from_file(filename, width, height);
3130 static GLib2.Quark blend_string_error_quark() {
3131 return cogl_blend_string_error_quark();
3135 // Check whether @name occurs in list of extensions in @ext.
3138 // not appropriate to expose OpenGL extensions through the Cogl API. This
3139 // function can be replaced by the following equivalent code:
3140 // |[
3141 // gboolean retval = (strstr (ext, name) != NULL) ? TRUE : FALSE;
3142 // ]|
3143 // RETURNS: %TRUE if the extension occurs in the list, %FALSE otherwise.
3144 // <name>: extension to check for
3145 // <ext>: list of extensions
3146 static int check_extension(char* name, char* ext) {
3147 return cogl_check_extension(name, ext);
3151 // Clears all the auxiliary buffers identified in the @buffers mask, and if
3152 // that includes the color buffer then the specified @color is used.
3153 // <color>: Background color to clear to
3154 // <buffers>: A mask of #CoglBufferBit<!-- -->'s identifying which auxiliary buffers to clear
3155 static void clear(Color* color, c_ulong buffers) {
3156 cogl_clear(color, buffers);
3160 // Ensures that the current clipping region has been set in GL. This
3161 // will automatically be called before any Cogl primitives but it
3162 // maybe be neccessary to call if you are using raw GL calls with
3163 // clipping.
3164 static void clip_ensure() {
3165 cogl_clip_ensure();
3169 // Reverts the clipping region to the state before the last call to
3170 // cogl_clip_push().
3171 static void clip_pop() {
3172 cogl_clip_pop();
3176 // Specifies a rectangular clipping area for all subsequent drawing
3177 // operations. Any drawing commands that extend outside the rectangle
3178 // will be clipped so that only the portion inside the rectangle will
3179 // be displayed. The rectangle dimensions are transformed by the
3180 // current model-view matrix.
3182 // The rectangle is intersected with the current clip region. To undo
3183 // the effect of this function, call cogl_clip_pop().
3185 // with other API that specify rectangles in model space, and when used
3186 // with a coordinate space that puts the origin at the center and y+
3187 // extending up, it's awkward to use. Please use cogl_clip_push_rectangle()
3188 // instead
3189 // <x_offset>: left edge of the clip rectangle
3190 // <y_offset>: top edge of the clip rectangle
3191 // <width>: width of the clip rectangle
3192 // <height>: height of the clip rectangle
3193 static void clip_push(float x_offset, float y_offset, float width, float height) {
3194 cogl_clip_push(x_offset, y_offset, width, height);
3198 // Sets a new clipping area using the current path. The current path
3199 // is then cleared. The clipping area is intersected with the previous
3200 // clipping area. To restore the previous clipping area, call
3201 // cogl_clip_pop().
3202 static void clip_push_from_path() {
3203 cogl_clip_push_from_path();
3207 // Sets a new clipping area using the current path. The current path
3208 // is then cleared. The clipping area is intersected with the previous
3209 // clipping area. To restore the previous clipping area, call
3210 // cogl_clip_pop().
3211 static void clip_push_from_path_preserve() {
3212 cogl_clip_push_from_path_preserve();
3216 // Specifies a rectangular clipping area for all subsequent drawing
3217 // operations. Any drawing commands that extend outside the rectangle
3218 // will be clipped so that only the portion inside the rectangle will
3219 // be displayed. The rectangle dimensions are transformed by the
3220 // current model-view matrix.
3222 // The rectangle is intersected with the current clip region. To undo
3223 // the effect of this function, call cogl_clip_pop().
3224 // <x0>: x coordinate for top left corner of the clip rectangle
3225 // <y0>: y coordinate for top left corner of the clip rectangle
3226 // <x1>: x coordinate for bottom right corner of the clip rectangle
3227 // <y1>: y coordinate for bottom right corner of the clip rectangle
3228 static void clip_push_rectangle(float x0, float y0, float x1, float y1) {
3229 cogl_clip_push_rectangle(x0, y0, x1, y1);
3233 // Specifies a rectangular clipping area for all subsequent drawing
3234 // operations. Any drawing commands that extend outside the rectangle
3235 // will be clipped so that only the portion inside the rectangle will
3236 // be displayed. The rectangle dimensions are not transformed by the
3237 // current model-view matrix.
3239 // The rectangle is intersected with the current clip region. To undo
3240 // the effect of this function, call cogl_clip_pop().
3241 // <x_offset>: left edge of the clip rectangle in window coordinates
3242 // <y_offset>: top edge of the clip rectangle in window coordinates
3243 // <width>: width of the clip rectangle
3244 // <height>: height of the clip rectangle
3245 static void clip_push_window_rect(float x_offset, float y_offset, float width, float height) {
3246 cogl_clip_push_window_rect(x_offset, y_offset, width, height);
3250 // Specifies a rectangular clipping area for all subsequent drawing
3251 // operations. Any drawing commands that extend outside the rectangle
3252 // will be clipped so that only the portion inside the rectangle will
3253 // be displayed. The rectangle dimensions are not transformed by the
3254 // current model-view matrix.
3256 // The rectangle is intersected with the current clip region. To undo
3257 // the effect of this function, call cogl_clip_pop().
3258 // <x_offset>: left edge of the clip rectangle in window coordinates
3259 // <y_offset>: top edge of the clip rectangle in window coordinates
3260 // <width>: width of the clip rectangle
3261 // <height>: height of the clip rectangle
3262 static void clip_push_window_rectangle(int x_offset, int y_offset, int width, int height) {
3263 cogl_clip_push_window_rectangle(x_offset, y_offset, width, height);
3267 // Restore the state of the clipping stack that was previously saved
3268 // by cogl_clip_stack_save().
3270 // the clip stack when switching back from an offscreen framebuffer,
3271 // but it's not necessary anymore given that framebuffers now own
3272 // separate clip stacks which will be automatically switched between
3273 // when a new buffer is set. Calling this function has no effect
3274 static void clip_stack_restore() {
3275 cogl_clip_stack_restore();
3279 // Save the entire state of the clipping stack and then clear all
3280 // clipping. The previous state can be returned to with
3281 // cogl_clip_stack_restore(). Each call to cogl_clip_push() after this
3282 // must be matched by a call to cogl_clip_pop() before calling
3283 // cogl_clip_stack_restore().
3285 // clip stack when switching to an offscreen framebuffer, but it's
3286 // not necessary anymore given that framebuffers now own separate
3287 // clip stacks which will be automatically switched between when a
3288 // new buffer is set. Calling this function has no effect
3289 static void clip_stack_save() {
3290 cogl_clip_stack_save();
3293 static int clutter_check_extension_CLUTTER(char* name, char* ext) {
3294 return cogl_clutter_check_extension_CLUTTER(name, ext);
3297 static int clutter_winsys_has_feature_CLUTTER(WinsysFeature feature) {
3298 return cogl_clutter_winsys_has_feature_CLUTTER(feature);
3301 // Unintrospectable function: clutter_winsys_xlib_get_visual_info_CLUTTER() / cogl_clutter_winsys_xlib_get_visual_info_CLUTTER()
3302 static /*CTYPE*/ XVisualInfo* clutter_winsys_xlib_get_visual_info_CLUTTER() {
3303 return cogl_clutter_winsys_xlib_get_visual_info_CLUTTER();
3307 // Compares two #CoglColor<!-- -->s and checks if they are the same.
3309 // This function can be passed to g_hash_table_new() as the @key_equal_func
3310 // parameter, when using #CoglColor<!-- -->s as keys in a #GHashTable.
3311 // RETURNS: %TRUE if the two colors are the same.
3312 // <v1>: a #CoglColor
3313 // <v2>: a #CoglColor
3314 static int color_equal(const(void)* v1, const(void)* v2) {
3315 return cogl_color_equal(v1, v2);
3319 // Unintrospectable function: create_program() / cogl_create_program()
3320 // Create a new cogl program object that can be used to replace parts of the GL
3321 // rendering pipeline with custom code.
3322 // RETURNS: a new cogl program.
3323 static Handle create_program() {
3324 return cogl_create_program();
3328 // Unintrospectable function: create_shader() / cogl_create_shader()
3329 // Create a new shader handle, use #cogl_shader_source to set the source code
3330 // to be used on it.
3331 // RETURNS: a new shader handle.
3332 // <shader_type>: COGL_SHADER_TYPE_VERTEX or COGL_SHADER_TYPE_FRAGMENT.
3333 static Handle create_shader(ShaderType shader_type) {
3334 return cogl_create_shader(shader_type);
3338 // This function disables fogging, so primitives drawn afterwards will not be
3339 // blended with any previously set fog color.
3340 static void disable_fog() {
3341 cogl_disable_fog();
3344 // Unintrospectable function: double_to_fixed() / cogl_double_to_fixed()
3345 static Fixed double_to_fixed(double value) {
3346 return cogl_double_to_fixed(value);
3349 static int double_to_int(double value) {
3350 return cogl_double_to_int(value);
3353 static uint double_to_uint(double value) {
3354 return cogl_double_to_uint(value);
3357 static void draw_attributes(VerticesMode mode, int first_vertex, int n_vertices, Attribute** attributes, int n_attributes) {
3358 cogl_draw_attributes(mode, first_vertex, n_vertices, attributes, n_attributes);
3361 static void draw_indexed_attributes(VerticesMode mode, int first_vertex, int n_vertices, Indices* indices, Attribute** attributes, int n_attributes) {
3362 cogl_draw_indexed_attributes(mode, first_vertex, n_vertices, indices, attributes, n_attributes);
3366 // This is the counterpart to cogl_begin_gl() used to delimit blocks of drawing
3367 // code using raw OpenGL. Please refer to cogl_begin_gl() for full details.
3368 static void end_gl() {
3369 cogl_end_gl();
3373 // Compares the two given euler angles @v1 and @v1 and it they are
3374 // equal returns %TRUE else %FALSE.
3376 // <note>This function only checks that all three components rotations
3377 // are numerically equal, it does not consider that some rotations
3378 // can be represented with different component rotations</note>
3379 // RETURNS: %TRUE if @v1 and @v2 are equal else %FALSE.
3380 // <v1>: The second euler angle to compare
3381 static int euler_equal(const(void)* v1, const(void)* v2) {
3382 return cogl_euler_equal(v1, v2);
3386 // Checks whether the given COGL features are available. Multiple
3387 // features can be checked for by or-ing them together with the '|'
3388 // operator. %TRUE is only returned if all of the requested features
3389 // are available.
3390 // RETURNS: %TRUE if the features are available, %FALSE otherwise.
3391 // <features>: A bitmask of features to check for
3392 static int features_available(FeatureFlags features) {
3393 return cogl_features_available(features);
3397 // This function should only need to be called in exceptional circumstances.
3399 // As an optimization Cogl drawing functions may batch up primitives
3400 // internally, so if you are trying to use raw GL outside of Cogl you stand a
3401 // better chance of being successful if you ask Cogl to flush any batched
3402 // geometry before making your state changes.
3404 // It only ensure that the underlying driver is issued all the commands
3405 // necessary to draw the batched primitives. It provides no guarantees about
3406 // when the driver will complete the rendering.
3408 // This provides no guarantees about the GL state upon returning and to avoid
3409 // confusing Cogl you should aim to restore any changes you make before
3410 // resuming use of Cogl.
3412 // If you are making state changes with the intention of affecting Cogl drawing
3413 // primitives you are 100% on your own since you stand a good chance of
3414 // conflicting with Cogl internals. For example clutter-gst which currently
3415 // uses direct GL calls to bind ARBfp programs will very likely break when Cogl
3416 // starts to use ARBfb programs itself for the material API.
3417 static void flush() {
3418 cogl_flush();
3422 // Replaces the current projection matrix with a perspective matrix
3423 // for the given viewing frustum.
3424 // <left>: Left clipping plane
3425 // <right>: Right clipping plane
3426 // <bottom>: Bottom clipping plane
3427 // <top>: Top clipping plane
3428 // <z_near>: Nearest visible point
3429 // <z_far>: Furthest visible point along the z-axis
3430 static void frustum(float left, float right, float bottom, float top, float z_near, float z_far) {
3431 cogl_frustum(left, right, bottom, top, z_near, z_far);
3435 // Queries if backface culling has been enabled via
3436 // cogl_set_backface_culling_enabled()
3437 // RETURNS: %TRUE if backface culling is enabled, and %FALSE otherwise
3438 static int get_backface_culling_enabled() {
3439 return cogl_get_backface_culling_enabled();
3443 // Gets the number of bitplanes used for each of the color components
3444 // in the color buffer. Pass %NULL for any of the arguments if the
3445 // value is not required.
3446 // <red>: Return location for the number of red bits or %NULL
3447 // <green>: Return location for the number of green bits or %NULL
3448 // <blue>: Return location for the number of blue bits or %NULL
3449 // <alpha>: Return location for the number of alpha bits or %NULL
3450 static void get_bitmasks(/*out*/ int* red, /*out*/ int* green, /*out*/ int* blue, /*out*/ int* alpha) {
3451 cogl_get_bitmasks(red, green, blue, alpha);
3455 // Queries if depth testing has been enabled via cogl_set_depth_test_enable()
3458 // instead.
3459 // RETURNS: %TRUE if depth testing is enabled, and %FALSE otherwise
3460 static int get_depth_test_enabled() {
3461 return cogl_get_depth_test_enabled();
3465 // Returns all of the features supported by COGL.
3466 // RETURNS: A logical OR of all the supported COGL features.
3467 static FeatureFlags get_features() {
3468 return cogl_get_features();
3472 // Stores the current model-view matrix in @matrix.
3473 // <matrix>: return location for the model-view matrix
3474 static void get_modelview_matrix(/*out*/ Matrix* matrix) {
3475 cogl_get_modelview_matrix(matrix);
3479 // Unintrospectable function: get_option_group() / cogl_get_option_group()
3480 // Retrieves the #GOptionGroup used by COGL to parse the command
3481 // line options. Clutter uses this to handle the COGL command line
3482 // options during its initialization process.
3483 // RETURNS: a #GOptionGroup
3484 static GLib2.OptionGroup* get_option_group() {
3485 return cogl_get_option_group();
3489 // Unintrospectable function: get_path() / cogl_get_path()
3490 // Gets a pointer to the current path. The path can later be used
3491 // again by calling cogl_path_set(). Note that the path isn't copied
3492 // so if you later call any functions to add to the path it will
3493 // affect the returned object too. No reference is taken on the path
3494 // so if you want to retain it you should take your own reference with
3495 // cogl_object_ref().
3496 // RETURNS: a pointer to the current path.
3497 static Path* get_path() {
3498 return cogl_get_path();
3502 // Unintrospectable function: get_proc_address() / cogl_get_proc_address()
3503 // Gets a pointer to a given GL or GL ES extension function. This acts
3504 // as a wrapper around glXGetProcAddress() or whatever is the
3505 // appropriate function for the current backend.
3507 // function is not available.
3508 // RETURNS: a pointer to the requested function or %NULL if the
3509 // <name>: the name of the function.
3510 static FuncPtr get_proc_address(char* name) {
3511 return cogl_get_proc_address(name);
3515 // Stores the current projection matrix in @matrix.
3516 // <matrix>: return location for the projection matrix
3517 static void get_projection_matrix(/*out*/ Matrix* matrix) {
3518 cogl_get_projection_matrix(matrix);
3521 // Unintrospectable function: get_rectangle_indices() / cogl_get_rectangle_indices()
3522 static Indices* get_rectangle_indices(int n_rectangles) {
3523 return cogl_get_rectangle_indices(n_rectangles);
3527 // Unintrospectable function: get_source() / cogl_get_source()
3528 // Returns the current source material as previously set using
3529 // cogl_set_source().
3531 // <note>You should typically consider the returned material immutable
3532 // and not try to change any of its properties unless you own a
3533 // reference to that material. At times you may be able to get a
3534 // reference to an internally managed materials and the result of
3535 // modifying such materials is undefined.</note>
3536 // RETURNS: The current source material.
3537 static void* get_source() {
3538 return cogl_get_source();
3542 // Returns a pointer to a singleton quaternion constant describing the
3543 // canonical identity [1 (0, 0, 0)] which represents no rotation.
3545 // If you multiply a quaternion with the identity quaternion you will
3546 // get back the same value as the original quaternion.
3547 // RETURNS: A pointer to an identity quaternion
3548 static Quaternion* get_static_identity_quaternion() {
3549 return cogl_get_static_identity_quaternion();
3553 // rotation of 180 degrees around a degenerate axis:
3554 // [0 (0, 0, 0)]
3555 // RETURNS: a pointer to a singleton quaternion constant describing a
3556 static Quaternion* get_static_zero_quaternion() {
3557 return cogl_get_static_zero_quaternion();
3561 // Stores the current viewport in @v. @v[0] and @v[1] get the x and y
3562 // position of the viewport and @v[2] and @v[3] get the width and
3563 // height.
3564 // <v>: pointer to a 4 element array of #float<!-- -->s to receive the viewport dimensions.
3565 static void get_viewport(/*out*/ float v) {
3566 cogl_get_viewport(v);
3569 static Type handle_get_type() {
3570 return cogl_handle_get_type();
3574 // Increases the reference count of @handle by 1
3575 // RETURNS: the handle, with its reference count increased
3576 // <handle>: a #CoglHandle
3577 static Handle handle_ref(Handle handle) {
3578 return cogl_handle_ref(handle);
3582 // Drecreases the reference count of @handle by 1; if the reference
3583 // count reaches 0, the resources allocated by @handle will be freed
3584 // <handle>: a #CoglHandle
3585 static void handle_unref(Handle handle) {
3586 cogl_handle_unref(handle);
3589 static IndicesType indices_get_type(Indices* indices) {
3590 return cogl_indices_get_type(indices);
3594 // Gets whether the given object references a #CoglAttribute.
3596 // %FALSE otherwise
3597 // RETURNS: %TRUE if the handle references a #CoglAttribute,
3598 // <object>: A #CoglObject
3599 static int is_attribute(void* object) {
3600 return cogl_is_attribute(object);
3604 // Gets whether the given object references a #CoglAttributeBuffer.
3606 // %FALSE otherwise
3607 // RETURNS: %TRUE if the handle references a #CoglAttributeBuffer,
3608 // <object>: A #CoglObject
3609 static int is_attribute_buffer(void* object) {
3610 return cogl_is_attribute_buffer(object);
3614 // Checks whether @handle is a #CoglHandle for a bitmap
3616 // and %FALSE otherwise
3617 // RETURNS: %TRUE if the passed handle represents a bitmap,
3618 // <handle>: a #CoglHandle for a bitmap
3619 static int is_bitmap(Handle handle) {
3620 return cogl_is_bitmap(handle);
3623 static int is_buffer_EXP(void* object) {
3624 return cogl_is_buffer_EXP(object);
3628 // Gets whether the given object references a #CoglIndexBuffer.
3630 // %FALSE otherwise
3631 // RETURNS: %TRUE if the handle references a #CoglIndexBuffer,
3632 // <object>: A #CoglObject
3633 static int is_index_buffer(void* object) {
3634 return cogl_is_index_buffer(object);
3638 // Gets whether the given handle references an existing material object.
3640 // %FALSE otherwise
3641 // RETURNS: %TRUE if the handle references a #CoglMaterial,
3642 // <handle>: A CoglHandle
3643 static int is_material(Handle handle) {
3644 return cogl_is_material(handle);
3648 // Determines whether the given #CoglHandle references an offscreen buffer
3649 // object.
3651 // %FALSE otherwise
3652 // RETURNS: %TRUE if the handle references an offscreen buffer,
3653 // <handle>: A CoglHandle for an offscreen buffer
3654 static int is_offscreen(Handle handle) {
3655 return cogl_is_offscreen(handle);
3659 // Gets whether the given handle references an existing path object.
3661 // %FALSE otherwise
3662 // RETURNS: %TRUE if the handle references a #CoglPath,
3663 // <handle>: A CoglHandle
3664 static int is_path(Handle handle) {
3665 return cogl_is_path(handle);
3668 static int is_pixel_buffer_EXP(void* object) {
3669 return cogl_is_pixel_buffer_EXP(object);
3673 // Gets whether the given object references a #CoglPrimitive.
3675 // %FALSE otherwise
3676 // RETURNS: %TRUE if the handle references a #CoglPrimitive,
3677 // <object>: A #CoglObject
3678 static int is_primitive(void* object) {
3679 return cogl_is_primitive(object);
3683 // Gets whether the given handle references an existing program object.
3685 // %FALSE otherwise
3686 // RETURNS: %TRUE if the handle references a program,
3687 // <handle>: A CoglHandle
3688 static int is_program(Handle handle) {
3689 return cogl_is_program(handle);
3693 // Gets whether the given handle references an existing shader object.
3695 // %FALSE otherwise
3696 // RETURNS: %TRUE if the handle references a shader,
3697 // <handle>: A CoglHandle
3698 static int is_shader(Handle handle) {
3699 return cogl_is_shader(handle);
3703 // Gets whether the given handle references an existing texture object.
3705 // %FALSE otherwise
3706 // RETURNS: %TRUE if the handle references a texture, and
3707 // <handle>: A CoglHandle
3708 static int is_texture(Handle handle) {
3709 return cogl_is_texture(handle);
3712 static int is_texture_2d_EXP(void* object) {
3713 return cogl_is_texture_2d_EXP(object);
3716 static int is_texture_3d_EXP(Handle handle) {
3717 return cogl_is_texture_3d_EXP(handle);
3721 // Checks whether @handle is a Vertex Buffer Object
3723 // otherwise
3724 // RETURNS: %TRUE if the handle is a VBO, and %FALSE
3725 // <handle>: a #CoglHandle for a vertex buffer object
3726 static int is_vertex_buffer(Handle handle) {
3727 return cogl_is_vertex_buffer(handle);
3731 // Checks whether @handle is a handle to the indices for a vertex
3732 // buffer object
3734 // otherwise
3735 // RETURNS: %TRUE if the handle is indices, and %FALSE
3736 // <handle>: a #CoglHandle
3737 static int is_vertex_buffer_indices(Handle handle) {
3738 return cogl_is_vertex_buffer_indices(handle);
3742 // Retrieves the type of the layer
3744 // Currently there is only one type of layer defined:
3745 // %COGL_MATERIAL_LAYER_TYPE_TEXTURE, but considering we may add purely GLSL
3746 // based layers in the future, you should write code that checks the type
3747 // first.
3748 // RETURNS: the type of the layer
3749 // <layer>: A #CoglMaterialLayer object
3750 static MaterialLayerType material_layer_get_type(MaterialLayer* layer) {
3751 return cogl_material_layer_get_type(layer);
3755 // Decrement the reference count for a #CoglMaterial.
3756 // <material>: a #CoglMaterial object.
3757 static void material_unref(Handle material) {
3758 cogl_material_unref(material);
3762 // Compares two matrices to see if they represent the same
3763 // transformation. Although internally the matrices may have different
3764 // annotations associated with them and may potentially have a cached
3765 // inverse matrix these are not considered in the comparison.
3766 // <v1>: A 4x4 transformation matrix
3767 // <v2>: A 4x4 transformation matrix
3768 static int matrix_equal(const(void)* v1, const(void)* v2) {
3769 return cogl_matrix_equal(v1, v2);
3773 // Unintrospectable function: object_ref() / cogl_object_ref()
3774 // Increases the reference count of @handle by 1
3775 // RETURNS: the @object, with its reference count increased
3776 // <object>: a #CoglObject
3777 static void* object_ref(void* object) {
3778 return cogl_object_ref(object);
3782 // Unintrospectable function: object_unref() / cogl_object_unref()
3783 // Drecreases the reference count of @object by 1; if the reference
3784 // count reaches 0, the resources allocated by @object will be freed
3785 // <object>: a #CoglObject
3786 static void object_unref(void* object) {
3787 cogl_object_unref(object);
3791 // This creates an offscreen buffer object using the given texture as the
3792 // primary color buffer. It doesn't just initialize the contents of the
3793 // offscreen buffer with the texture; they are tightly bound so that
3794 // drawing to the offscreen buffer effectivly updates the contents of the
3795 // given texture. You don't need to destroy the offscreen buffer before
3796 // you can use the texture again.
3798 // Note: This does not work with sliced Cogl textures.
3800 // buffer or %COGL_INVALID_HANDLE if it wasn't possible to create the
3801 // buffer.
3802 // RETURNS: a #CoglHandle for the new offscreen
3803 // <handle>: A CoglHandle for a Cogl texture
3804 static Handle /*new*/ offscreen_new_to_texture(Handle handle) {
3805 return cogl_offscreen_new_to_texture(handle);
3809 // Increments the reference count on the offscreen buffer.
3810 // RETURNS: For convenience it returns the given CoglHandle
3811 // <handle>: A CoglHandle for an offscreen buffer
3812 static Handle offscreen_ref(Handle handle) {
3813 return cogl_offscreen_ref(handle);
3817 // Decreases the reference count for the offscreen buffer and frees it when
3818 // the count reaches 0.
3819 // <handle>: A CoglHandle for an offscreen buffer
3820 static void offscreen_unref(Handle handle) {
3821 cogl_offscreen_unref(handle);
3824 static void onscreen_clutter_backend_set_size_CLUTTER(int width, int height) {
3825 cogl_onscreen_clutter_backend_set_size_CLUTTER(width, height);
3829 // Replaces the current projection matrix with an orthographic projection
3830 // matrix. See <xref linkend="cogl-ortho-matrix"/> to see how the matrix is
3831 // calculated.
3833 // <figure id="cogl-ortho-matrix">
3834 // <title></title>
3835 // <graphic fileref="cogl_ortho.png" format="PNG"/>
3836 // </figure>
3838 // <note>This function copies the arguments from OpenGL's glOrtho() even
3839 // though they are unnecessarily confusing due to the z near and z far
3840 // arguments actually being a "distance" from the origin, where
3841 // negative values are behind the viewer, instead of coordinates for
3842 // the z clipping planes which would have been consistent with the
3843 // left, right bottom and top arguments.</note>
3844 // <left>: The coordinate for the left clipping plane
3845 // <right>: The coordinate for the right clipping plane
3846 // <bottom>: The coordinate for the bottom clipping plane
3847 // <top>: The coordinate for the top clipping plane
3848 // <near>: The <emphasis>distance</emphasis> to the near clipping plane (negative if the plane is behind the viewer)
3849 // <far>: The <emphasis>distance</emphasis> for the far clipping plane (negative if the plane is behind the viewer)
3850 static void ortho(float left, float right, float bottom, float top, float near, float far) {
3851 cogl_ortho(left, right, bottom, top, near, far);
3855 // Adds an elliptical arc segment to the current path. A straight line
3856 // segment will link the current pen location with the first vertex
3857 // of the arc. If you perform a move_to to the arcs start just before
3858 // drawing it you create a free standing arc.
3860 // The angles are measured in degrees where 0° is in the direction of
3861 // the positive X axis and 90° is in the direction of the positive Y
3862 // axis. The angle of the arc begins at @angle_1 and heads towards
3863 // @angle_2 (so if @angle_2 is less than @angle_1 it will decrease,
3864 // otherwise it will increase).
3865 // <center_x>: X coordinate of the elliptical arc center
3866 // <center_y>: Y coordinate of the elliptical arc center
3867 // <radius_x>: X radius of the elliptical arc
3868 // <radius_y>: Y radius of the elliptical arc
3869 // <angle_1>: Angle in degrees at which the arc begin
3870 // <angle_2>: Angle in degrees at which the arc ends
3871 static void path_arc(float center_x, float center_y, float radius_x, float radius_y, float angle_1, float angle_2) {
3872 cogl_path_arc(center_x, center_y, radius_x, radius_y, angle_1, angle_2);
3876 // Closes the path being constructed by adding a straight line segment
3877 // to it that ends at the first vertex of the path.
3878 static void path_close() {
3879 cogl_path_close();
3883 // Adds a cubic bezier curve segment to the current path with the given
3884 // second, third and fourth control points and using current pen location
3885 // as the first control point.
3886 // <x_1>: X coordinate of the second bezier control point
3887 // <y_1>: Y coordinate of the second bezier control point
3888 // <x_2>: X coordinate of the third bezier control point
3889 // <y_2>: Y coordinate of the third bezier control point
3890 // <x_3>: X coordinate of the fourth bezier control point
3891 // <y_3>: Y coordinate of the fourth bezier control point
3892 static void path_curve_to(float x_1, float y_1, float x_2, float y_2, float x_3, float y_3) {
3893 cogl_path_curve_to(x_1, y_1, x_2, y_2, x_3, y_3);
3897 // Constructs an ellipse shape. If there is an existing path this will
3898 // start a new disjoint sub-path.
3899 // <center_x>: X coordinate of the ellipse center
3900 // <center_y>: Y coordinate of the ellipse center
3901 // <radius_x>: X radius of the ellipse
3902 // <radius_y>: Y radius of the ellipse
3903 static void path_ellipse(float center_x, float center_y, float radius_x, float radius_y) {
3904 cogl_path_ellipse(center_x, center_y, radius_x, radius_y);
3908 // Fills the interior of the constructed shape using the current
3909 // drawing color. The current path is then cleared. To use the path
3910 // again, call cogl_path_fill_preserve() instead.
3912 // The interior of the shape is determined using the fill rule of the
3913 // path. See %CoglPathFillRule for details.
3914 static void path_fill() {
3915 cogl_path_fill();
3919 // Fills the interior of the constructed shape using the current
3920 // drawing color and preserves the path to be used again. See
3921 // cogl_path_fill() for a description what is considered the interior
3922 // of the shape.
3923 static void path_fill_preserve() {
3924 cogl_path_fill_preserve();
3928 // Retrieves the fill rule set using cogl_path_set_fill_rule().
3929 // RETURNS: the fill rule that is used for the current path.
3930 static PathFillRule path_get_fill_rule() {
3931 return cogl_path_get_fill_rule();
3935 // Constructs a straight line shape starting and ending at the given
3936 // coordinates. If there is an existing path this will start a new
3937 // disjoint sub-path.
3938 // <x_1>: X coordinate of the start line vertex
3939 // <y_1>: Y coordinate of the start line vertex
3940 // <x_2>: X coordinate of the end line vertex
3941 // <y_2>: Y coordinate of the end line vertex
3942 static void path_line(float x_1, float y_1, float x_2, float y_2) {
3943 cogl_path_line(x_1, y_1, x_2, y_2);
3947 // Adds a straight line segment to the current path that ends at the
3948 // given coordinates.
3949 // <x>: X coordinate of the end line vertex
3950 // <y>: Y coordinate of the end line vertex
3951 static void path_line_to(float x, float y) {
3952 cogl_path_line_to(x, y);
3956 // Moves the pen to the given location. If there is an existing path
3957 // this will start a new disjoint subpath.
3958 // <x>: X coordinate of the pen location to move to.
3959 // <y>: Y coordinate of the pen location to move to.
3960 static void path_move_to(float x, float y) {
3961 cogl_path_move_to(x, y);
3965 // Clears the current path and starts a new one. Creating a new path
3966 // also resets the fill rule to the default which is
3967 // %COGL_PATH_FILL_RULE_EVEN_ODD.
3968 static void path_new() {
3969 cogl_path_new();
3973 // Constructs a polygonal shape of the given number of vertices. If
3974 // there is an existing path this will start a new disjoint sub-path.
3976 // The coords array must contain 2 * num_points values. The first value
3977 // represents the X coordinate of the first vertex, the second value
3978 // represents the Y coordinate of the first vertex, continuing in the same
3979 // fashion for the rest of the vertices.
3980 // <coords>: A pointer to the first element of an array of fixed-point values that specify the vertex coordinates.
3981 // <num_points>: The total number of vertices.
3982 static void path_polygon(float* coords, int num_points) {
3983 cogl_path_polygon(coords, num_points);
3987 // Constructs a series of straight line segments, starting from the
3988 // first given vertex coordinate. If there is an existing path this
3989 // will start a new disjoint sub-path. Each subsequent segment starts
3990 // where the previous one ended and ends at the next given vertex
3991 // coordinate.
3993 // The coords array must contain 2 * num_points values. The first value
3994 // represents the X coordinate of the first vertex, the second value
3995 // represents the Y coordinate of the first vertex, continuing in the same
3996 // fashion for the rest of the vertices. (num_points - 1) segments will
3997 // be constructed.
3998 // <coords>: A pointer to the first element of an array of fixed-point values that specify the vertex coordinates.
3999 // <num_points>: The total number of vertices.
4000 static void path_polyline(float* coords, int num_points) {
4001 cogl_path_polyline(coords, num_points);
4005 // Constructs a rectangular shape at the given coordinates. If there
4006 // is an existing path this will start a new disjoint sub-path.
4007 // <x_1>: X coordinate of the top-left corner.
4008 // <y_1>: Y coordinate of the top-left corner.
4009 // <x_2>: X coordinate of the bottom-right corner.
4010 // <y_2>: Y coordinate of the bottom-right corner.
4011 static void path_rectangle(float x_1, float y_1, float x_2, float y_2) {
4012 cogl_path_rectangle(x_1, y_1, x_2, y_2);
4016 // Adds a cubic bezier curve segment to the current path with the given
4017 // second, third and fourth control points and using current pen location
4018 // as the first control point. The given coordinates are relative to the
4019 // current pen location.
4020 // <x_1>: X coordinate of the second bezier control point
4021 // <y_1>: Y coordinate of the second bezier control point
4022 // <x_2>: X coordinate of the third bezier control point
4023 // <y_2>: Y coordinate of the third bezier control point
4024 // <x_3>: X coordinate of the fourth bezier control point
4025 // <y_3>: Y coordinate of the fourth bezier control point
4026 static void path_rel_curve_to(float x_1, float y_1, float x_2, float y_2, float x_3, float y_3) {
4027 cogl_path_rel_curve_to(x_1, y_1, x_2, y_2, x_3, y_3);
4031 // Adds a straight line segment to the current path that ends at the
4032 // given coordinates relative to the current pen location.
4033 // <x>: X offset from the current pen location of the end line vertex
4034 // <y>: Y offset from the current pen location of the end line vertex
4035 static void path_rel_line_to(float x, float y) {
4036 cogl_path_rel_line_to(x, y);
4040 // Moves the pen to the given offset relative to the current pen
4041 // location. If there is an existing path this will start a new
4042 // disjoint subpath.
4043 // <x>: X offset from the current pen location to move the pen to.
4044 // <y>: Y offset from the current pen location to move the pen to.
4045 static void path_rel_move_to(float x, float y) {
4046 cogl_path_rel_move_to(x, y);
4050 // Constructs a rectangular shape with rounded corners. If there is an
4051 // existing path this will start a new disjoint sub-path.
4052 // <x_1>: X coordinate of the top-left corner.
4053 // <y_1>: Y coordinate of the top-left corner.
4054 // <x_2>: X coordinate of the bottom-right corner.
4055 // <y_2>: Y coordinate of the bottom-right corner.
4056 // <radius>: Radius of the corner arcs.
4057 // <arc_step>: Angle increment resolution for subdivision of the corner arcs.
4058 static void path_round_rectangle(float x_1, float y_1, float x_2, float y_2, float radius, float arc_step) {
4059 cogl_path_round_rectangle(x_1, y_1, x_2, y_2, radius, arc_step);
4063 // Sets the fill rule of the current path to @fill_rule. This will
4064 // affect how the path is filled when cogl_path_fill() is later
4065 // called. Note that the fill rule state is attached to the path so
4066 // calling cogl_get_path() will preserve the fill rule and calling
4067 // cogl_path_new() will reset the fill rule back to the default.
4068 // <fill_rule>: The new fill rule.
4069 static void path_set_fill_rule(PathFillRule fill_rule) {
4070 cogl_path_set_fill_rule(fill_rule);
4074 // Strokes the constructed shape using the current drawing color and a
4075 // width of 1 pixel (regardless of the current transformation
4076 // matrix). To current path is then cleared. To use the path again,
4077 // call cogl_path_stroke_preserve() instead.
4078 static void path_stroke() {
4079 cogl_path_stroke();
4083 // Strokes the constructed shape using the current drawing color and
4084 // preserves the path to be used again.
4085 static void path_stroke_preserve() {
4086 cogl_path_stroke_preserve();
4090 // Replaces the current projection matrix with a perspective matrix
4091 // based on the provided values.
4092 // <fovy>: Vertical of view angle in degrees.
4093 // <aspect>: Aspect ratio of diesplay
4094 // <z_near>: Nearest visible point
4095 // <z_far>: Furthest visible point along the z-axis
4096 static void perspective(float fovy, float aspect, float z_near, float z_far) {
4097 cogl_perspective(fovy, aspect, z_near, z_far);
4101 // Draws a convex polygon using the current source material to fill / texture
4102 // with according to the texture coordinates passed.
4104 // If @use_color is %TRUE then the color will be changed for each vertex using
4105 // the value specified in the color member of #CoglTextureVertex. This can be
4106 // used for example to make the texture fade out by setting the alpha value of
4107 // the color.
4109 // All of the texture coordinates must be in the range [0,1] and repeating the
4110 // texture is not supported.
4112 // Because of the way this function is implemented it will currently
4113 // only work if either the texture is not sliced or the backend is not
4114 // OpenGL ES and the minifying and magnifying functions are both set
4115 // to COGL_MATERIAL_FILTER_NEAREST.
4116 // <vertices>: An array of #CoglTextureVertex structs
4117 // <n_vertices>: The length of the vertices array
4118 // <use_color>: %TRUE if the color member of #CoglTextureVertex should be used
4119 static void polygon(TextureVertex* vertices, uint n_vertices, int use_color) {
4120 cogl_polygon(vertices, n_vertices, use_color);
4123 // Restore cogl_set_draw_buffer() state.
4124 static void pop_draw_buffer() {
4125 cogl_pop_draw_buffer();
4129 // Restores the framebuffer that was previously at the top of the stack.
4130 // All subsequent drawing will be redirected to this framebuffer.
4131 static void pop_framebuffer() {
4132 cogl_pop_framebuffer();
4135 // Restores the current model-view matrix from the matrix stack.
4136 static void pop_matrix() {
4137 cogl_pop_matrix();
4141 // Removes the material at the top of the source stack. The material
4142 // at the top of this stack defines the GPU state used to process
4143 // later primitives as defined by cogl_set_source().
4144 static void pop_source() {
4145 cogl_pop_source();
4149 // Attaches a shader to a program object, a program can have one vertex shader
4150 // and one fragment shader attached.
4151 // <program_handle>: a #CoglHandle for a shdaer program.
4152 // <shader_handle>: a #CoglHandle for a vertex of fragment shader.
4153 static void program_attach_shader(Handle program_handle, Handle shader_handle) {
4154 cogl_program_attach_shader(program_handle, shader_handle);
4158 // Retrieve the location (offset) of a uniform variable in a shader program,
4159 // a uniform is a variable that is constant for all vertices/fragments for a
4160 // shader object and is possible to modify as an external parameter.
4162 // This uniform can be set using cogl_program_uniform_1f() when the
4163 // program is in use.
4164 // RETURNS: the offset of a uniform in a specified program.
4165 // <handle>: a #CoglHandle for a shader program.
4166 // <uniform_name>: the name of a uniform.
4167 static int program_get_uniform_location(Handle handle, char* uniform_name) {
4168 return cogl_program_get_uniform_location(handle, uniform_name);
4172 // Links a program making it ready for use.
4173 // <handle>: a #CoglHandle for a shader program.
4174 static void program_link(Handle handle) {
4175 cogl_program_link(handle);
4179 // Unintrospectable function: program_ref() / cogl_program_ref()
4180 // Add an extra reference to a program.
4181 // RETURNS: @handle
4182 // <handle>: A #CoglHandle to a program.
4183 static Handle program_ref(Handle handle) {
4184 return cogl_program_ref(handle);
4188 // Changes the value of a floating point uniform for the given linked
4189 // @program.
4190 // <program>: A #CoglHandle for a linked program
4191 // <uniform_location>: the uniform location retrieved from cogl_program_get_uniform_location().
4192 // <value>: the new value of the uniform.
4193 static void program_set_uniform_1f(Handle program, int uniform_location, float value) {
4194 cogl_program_set_uniform_1f(program, uniform_location, value);
4198 // Changes the value of an integer uniform for the given linked
4199 // @program.
4200 // <program>: A #CoglHandle for a linked program
4201 // <uniform_location>: the uniform location retrieved from cogl_program_get_uniform_location().
4202 // <value>: the new value of the uniform.
4203 static void program_set_uniform_1i(Handle program, int uniform_location, int value) {
4204 cogl_program_set_uniform_1i(program, uniform_location, value);
4208 // Changes the value of a float vector uniform, or uniform array for
4209 // the given linked @program.
4210 // <program>: A #CoglHandle for a linked program
4211 // <uniform_location>: the uniform location retrieved from cogl_program_get_uniform_location().
4212 // <n_components>: The number of components for the uniform. For example with glsl you'd use 3 for a vec3 or 4 for a vec4.
4213 // <count>: For uniform arrays this is the array length otherwise just pass 1
4214 // <value>: the new value of the uniform[s].
4215 static void program_set_uniform_float(Handle program, int uniform_location, int n_components, int count, float* value) {
4216 cogl_program_set_uniform_float(program, uniform_location, n_components, count, value);
4220 // Changes the value of a int vector uniform, or uniform array for
4221 // the given linked @program.
4222 // <program>: A #CoglHandle for a linked program
4223 // <uniform_location>: the uniform location retrieved from cogl_program_get_uniform_location().
4224 // <n_components>: The number of components for the uniform. For example with glsl you'd use 3 for a vec3 or 4 for a vec4.
4225 // <count>: For uniform arrays this is the array length otherwise just pass 1
4226 // <value>: the new value of the uniform[s].
4227 static void program_set_uniform_int(Handle program, int uniform_location, int n_components, int count, int* value) {
4228 cogl_program_set_uniform_int(program, uniform_location, n_components, count, value);
4232 // Changes the value of a matrix uniform, or uniform array in the
4233 // given linked @program.
4234 // <program>: A #CoglHandle for a linked program
4235 // <uniform_location>: the uniform location retrieved from cogl_program_get_uniform_location().
4236 // <dimensions>: The dimensions of the matrix. So for for example pass 2 for a 2x2 matrix or 3 for 3x3.
4237 // <count>: For uniform arrays this is the array length otherwise just pass 1
4238 // <transpose>: Whether to transpose the matrix when setting the uniform.
4239 // <value>: the new value of the uniform.
4240 static void program_set_uniform_matrix(Handle program, int uniform_location, int dimensions, int count, int transpose, float* value) {
4241 cogl_program_set_uniform_matrix(program, uniform_location, dimensions, count, transpose, value);
4245 // Changes the value of a floating point uniform in the currently
4246 // used (see cogl_program_use()) shader program.
4247 // <uniform_no>: the uniform to set.
4248 // <value>: the new value of the uniform.
4249 static void program_uniform_1f(int uniform_no, float value) {
4250 cogl_program_uniform_1f(uniform_no, value);
4254 // Changes the value of an integer uniform in the currently
4255 // used (see cogl_program_use()) shader program.
4256 // <uniform_no>: the uniform to set.
4257 // <value>: the new value of the uniform.
4258 static void program_uniform_1i(int uniform_no, int value) {
4259 cogl_program_uniform_1i(uniform_no, value);
4263 // Changes the value of a float vector uniform, or uniform array in the
4264 // currently used (see cogl_program_use()) shader program.
4265 // <uniform_no>: the uniform to set.
4266 // <size>: Size of float vector.
4267 // <count>: Size of array of uniforms.
4268 // <value>: the new value of the uniform.
4269 static void program_uniform_float(int uniform_no, int size, int count, float* value) {
4270 cogl_program_uniform_float(uniform_no, size, count, value);
4274 // Changes the value of a int vector uniform, or uniform array in the
4275 // currently used (see cogl_program_use()) shader program.
4276 // <uniform_no>: the uniform to set.
4277 // <size>: Size of int vector.
4278 // <count>: Size of array of uniforms.
4279 // <value>: the new value of the uniform.
4280 static void program_uniform_int(int uniform_no, int size, int count, int* value) {
4281 cogl_program_uniform_int(uniform_no, size, count, value);
4285 // Changes the value of a matrix uniform, or uniform array in the
4286 // currently used (see cogl_program_use()) shader program. The @size
4287 // parameter is used to determine the square size of the matrix.
4288 // <uniform_no>: the uniform to set.
4289 // <size>: Size of matrix.
4290 // <count>: Size of array of uniforms.
4291 // <transpose>: Whether to transpose the matrix when setting the uniform.
4292 // <value>: the new value of the uniform.
4293 static void program_uniform_matrix(int uniform_no, int size, int count, int transpose, float* value) {
4294 cogl_program_uniform_matrix(uniform_no, size, count, transpose, value);
4298 // Removes a reference to a program. If it was the last reference the
4299 // program object will be destroyed.
4300 // <handle>: A #CoglHandle to a program.
4301 static void program_unref(Handle handle) {
4302 cogl_program_unref(handle);
4306 // Activate a specific shader program replacing that part of the GL
4307 // rendering pipeline, if passed in %COGL_INVALID_HANDLE the default
4308 // behavior of GL is reinstated.
4309 // <handle>: a #CoglHandle for a shader program or %COGL_INVALID_HANDLE.
4310 static void program_use(Handle handle) {
4311 cogl_program_use(handle);
4314 // Save cogl_set_draw_buffer() state.
4315 static void push_draw_buffer() {
4316 cogl_push_draw_buffer();
4320 // Redirects all subsequent drawing to the specified framebuffer. This can
4321 // either be an offscreen buffer created with cogl_offscreen_new_to_texture ()
4322 // or in the future it may be an onscreen framebuffer too.
4324 // You should understand that a framebuffer owns the following state:
4325 // <itemizedlist>
4326 // <listitem><simpara>The projection matrix</simpara></listitem>
4327 // <listitem><simpara>The modelview matrix stack</simpara></listitem>
4328 // <listitem><simpara>The viewport</simpara></listitem>
4329 // <listitem><simpara>The clip stack</simpara></listitem>
4330 // </itemizedlist>
4331 // So these items will automatically be saved and restored when you
4332 // push and pop between different framebuffers.
4334 // Also remember a newly allocated framebuffer will have an identity matrix for
4335 // the projection and modelview matrices which gives you a coordinate space
4336 // like OpenGL with (-1, -1) corresponding to the top left of the viewport,
4337 // (1, 1) corresponding to the bottom right and +z coming out towards the
4338 // viewer.
4340 // If you want to set up a coordinate space like Clutter does with (0, 0)
4341 // corresponding to the top left and (framebuffer_width, framebuffer_height)
4342 // corresponding to the bottom right you can do so like this:
4344 // |[
4345 // static void
4346 // setup_viewport (unsigned int width,
4347 // unsigned int height,
4348 // float fovy,
4349 // float aspect,
4350 // float z_near,
4351 // float z_far)
4352 // {
4353 // float z_camera;
4354 // CoglMatrix projection_matrix;
4355 // CoglMatrix mv_matrix;
4357 // cogl_set_viewport (0, 0, width, height);
4358 // cogl_perspective (fovy, aspect, z_near, z_far);
4360 // cogl_get_projection_matrix (&amp;projection_matrix);
4361 // z_camera = 0.5 * projection_matrix.xx;
4363 // cogl_matrix_init_identity (&amp;mv_matrix);
4364 // cogl_matrix_translate (&amp;mv_matrix, -0.5f, -0.5f, -z_camera);
4365 // cogl_matrix_scale (&amp;mv_matrix, 1.0f / width, -1.0f / height, 1.0f / width);
4366 // cogl_matrix_translate (&amp;mv_matrix, 0.0f, -1.0 * height, 0.0f);
4367 // cogl_set_modelview_matrix (&amp;mv_matrix);
4368 // }
4370 // static void
4371 // my_init_framebuffer (ClutterStage *stage,
4372 // CoglFramebuffer *framebuffer,
4373 // unsigned int framebuffer_width,
4374 // unsigned int framebuffer_height)
4375 // {
4376 // ClutterPerspective perspective;
4378 // clutter_stage_get_perspective (stage, &perspective);
4380 // cogl_push_framebuffer (framebuffer);
4381 // setup_viewport (framebuffer_width,
4382 // framebuffer_height,
4383 // perspective.fovy,
4384 // perspective.aspect,
4385 // perspective.z_near,
4386 // perspective.z_far);
4387 // }
4388 // ]|
4390 // The previous framebuffer can be restored by calling cogl_pop_framebuffer()
4391 // <buffer>: A #CoglFramebuffer object, either onscreen or offscreen.
4392 static void push_framebuffer(Framebuffer* buffer) {
4393 cogl_push_framebuffer(buffer);
4397 // Stores the current model-view matrix on the matrix stack. The matrix
4398 // can later be restored with cogl_pop_matrix().
4399 static void push_matrix() {
4400 cogl_push_matrix();
4404 // Pushes the given @material to the top of the source stack. The
4405 // material at the top of this stack defines the GPU state used to
4406 // process later primitives as defined by cogl_set_source().
4407 // <material>: A #CoglMaterial
4408 static void push_source(void* material) {
4409 cogl_push_source(material);
4413 // Compares that all the components of quaternions @a and @b are
4414 // equal.
4416 // An epsilon value is not used to compare the float components, but
4417 // the == operator is at least used so that 0 and -0 are considered
4418 // equal.
4419 // RETURNS: %TRUE if the quaternions are equal else %FALSE.
4420 // <v1>: A #CoglQuaternion
4421 // <v2>: A #CoglQuaternion
4422 static int quaternion_equal(const(void)* v1, const(void)* v2) {
4423 return cogl_quaternion_equal(v1, v2);
4427 // This reads a rectangle of pixels from the current framebuffer where
4428 // position (0, 0) is the top left. The pixel at (x, y) is the first
4429 // read, and the data is returned with a rowstride of (width * 4).
4431 // Currently Cogl assumes that the framebuffer is in a premultiplied
4432 // format so if @format is non-premultiplied it will convert it. To
4433 // read the pixel values without any conversion you should either
4434 // specify a format that doesn't use an alpha channel or use one of
4435 // the formats ending in PRE.
4436 // <x>: The window x position to start reading from
4437 // <y>: The window y position to start reading from
4438 // <width>: The width of the rectangle you want to read
4439 // <height>: The height of the rectangle you want to read
4440 // <source>: Identifies which auxillary buffer you want to read (only COGL_READ_PIXELS_COLOR_BUFFER supported currently)
4441 // <format>: The pixel format you want the result in (only COGL_PIXEL_FORMAT_RGBA_8888 supported currently)
4442 // <pixels>: The location to write the pixel data.
4443 static void read_pixels(int x, int y, int width, int height, ReadPixelsFlags source, PixelFormat format, ubyte* pixels) {
4444 cogl_read_pixels(x, y, width, height, source, format, pixels);
4448 // Fills a rectangle at the given coordinates with the current source material
4449 // <x_1>: X coordinate of the top-left corner
4450 // <y_1>: Y coordinate of the top-left corner
4451 // <x_2>: X coordinate of the bottom-right corner
4452 // <y_2>: Y coordinate of the bottom-right corner
4453 static void rectangle(float x_1, float y_1, float x_2, float y_2) {
4454 cogl_rectangle(x_1, y_1, x_2, y_2);
4458 // This function draws a rectangle using the current source material to
4459 // texture or fill with. As a material may contain multiple texture layers
4460 // this interface lets you supply texture coordinates for each layer of the
4461 // material.
4463 // The first pair of coordinates are for the first layer (with the smallest
4464 // layer index) and if you supply less texture coordinates than there are
4465 // layers in the current source material then default texture coordinates
4466 // (0.0, 0.0, 1.0, 1.0) are generated.
4467 // <x1>: x coordinate upper left on screen.
4468 // <y1>: y coordinate upper left on screen.
4469 // <x2>: x coordinate lower right on screen.
4470 // <y2>: y coordinate lower right on screen.
4471 // <tex_coords>: An array containing groups of 4 float values: [tx1, ty1, tx2, ty2] that are interpreted as two texture coordinates; one for the upper left texel, and one for the lower right texel. Each value should be between 0.0 and 1.0, where the coordinate (0.0, 0.0) represents the top left of the texture, and (1.0, 1.0) the bottom right.
4472 // <tex_coords_len>: The length of the tex_coords array. (e.g. for one layer and one group of texture coordinates, this would be 4)
4473 static void rectangle_with_multitexture_coords(float x1, float y1, float x2, float y2, float* tex_coords, int tex_coords_len) {
4474 cogl_rectangle_with_multitexture_coords(x1, y1, x2, y2, tex_coords, tex_coords_len);
4478 // Draw a rectangle using the current material and supply texture coordinates
4479 // to be used for the first texture layer of the material. To draw the entire
4480 // texture pass in @tx1=0.0 @ty1=0.0 @tx2=1.0 @ty2=1.0.
4481 // <x1>: x coordinate upper left on screen.
4482 // <y1>: y coordinate upper left on screen.
4483 // <x2>: x coordinate lower right on screen.
4484 // <y2>: y coordinate lower right on screen.
4485 // <tx1>: x part of texture coordinate to use for upper left pixel
4486 // <ty1>: y part of texture coordinate to use for upper left pixel
4487 // <tx2>: x part of texture coordinate to use for lower right pixel
4488 // <ty2>: y part of texture coordinate to use for left pixel
4489 static void rectangle_with_texture_coords(float x1, float y1, float x2, float y2, float tx1, float ty1, float tx2, float ty2) {
4490 cogl_rectangle_with_texture_coords(x1, y1, x2, y2, tx1, ty1, tx2, ty2);
4494 // Draws a series of rectangles in the same way that
4495 // cogl_rectangle() does. In some situations it can give a
4496 // significant performance boost to use this function rather than
4497 // calling cogl_rectangle() separately for each rectangle.
4499 // @verts should point to an array of #float<!-- -->s with
4500 // @n_rects * 4 elements. Each group of 4 values corresponds to the
4501 // parameters x1, y1, x2, and y2, and have the same
4502 // meaning as in cogl_rectangle().
4503 // <verts>: an array of vertices
4504 // <n_rects>: number of rectangles to draw
4505 static void rectangles(float* verts, uint n_rects) {
4506 cogl_rectangles(verts, n_rects);
4510 // Draws a series of rectangles in the same way that
4511 // cogl_rectangle_with_texture_coords() does. In some situations it can give a
4512 // significant performance boost to use this function rather than
4513 // calling cogl_rectangle_with_texture_coords() separately for each rectangle.
4515 // @verts should point to an array of #float<!-- -->s with
4516 // @n_rects * 8 elements. Each group of 8 values corresponds to the
4517 // parameters x1, y1, x2, y2, tx1, ty1, tx2 and ty2 and have the same
4518 // meaning as in cogl_rectangle_with_texture_coords().
4519 // <verts>: an array of vertices
4520 // <n_rects>: number of rectangles to draw
4521 static void rectangles_with_texture_coords(float* verts, uint n_rects) {
4522 cogl_rectangles_with_texture_coords(verts, n_rects);
4526 // Multiplies the current model-view matrix by one that rotates the
4527 // model around the vertex specified by @x, @y and @z. The rotation
4528 // follows the right-hand thumb rule so for example rotating by 10
4529 // degrees about the vertex (0, 0, 1) causes a small counter-clockwise
4530 // rotation.
4531 // <angle>: Angle in degrees to rotate.
4532 // <x>: X-component of vertex to rotate around.
4533 // <y>: Y-component of vertex to rotate around.
4534 // <z>: Z-component of vertex to rotate around.
4535 static void rotate(float angle, float x, float y, float z) {
4536 cogl_rotate(angle, x, y, z);
4540 // Multiplies the current model-view matrix by one that scales the x,
4541 // y and z axes by the given values.
4542 // <x>: Amount to scale along the x-axis
4543 // <y>: Amount to scale along the y-axis
4544 // <z>: Amount to scale along the z-axis
4545 static void scale(float x, float y, float z) {
4546 cogl_scale(x, y, z);
4550 // Sets whether textures positioned so that their backface is showing
4551 // should be hidden. This can be used to efficiently draw two-sided
4552 // textures or fully closed cubes without enabling depth testing. This
4553 // only affects calls to the cogl_rectangle* family of functions and
4554 // cogl_vertex_buffer_draw*. Backface culling is disabled by default.
4555 // <setting>: %TRUE to enable backface culling or %FALSE to disable.
4556 static void set_backface_culling_enabled(int setting) {
4557 cogl_set_backface_culling_enabled(setting);
4561 // Sets whether depth testing is enabled. If it is disabled then the
4562 // order that actors are layered on the screen depends solely on the
4563 // order specified using clutter_actor_raise() and
4564 // clutter_actor_lower(), otherwise it will also take into account the
4565 // actor's depth. Depth testing is disabled by default.
4567 // instead.
4568 // <setting>: %TRUE to enable depth testing or %FALSE to disable.
4569 static void set_depth_test_enabled(int setting) {
4570 cogl_set_depth_test_enabled(setting);
4574 // Redirects all subsequent drawing to the specified framebuffer. This
4575 // can either be an offscreen buffer created with
4576 // cogl_offscreen_new_to_texture () or you can revert to your original
4577 // on screen window buffer.
4579 // the type of CoglHandle given instead.
4580 // <target>: A #CoglBufferTarget that specifies what kind of framebuffer you are setting as the render target.
4581 // <offscreen>: If you are setting a framebuffer of type COGL_OFFSCREEN_BUFFER then this is a CoglHandle for the offscreen buffer.
4582 static void set_draw_buffer(BufferTarget target, Handle offscreen) {
4583 cogl_set_draw_buffer(target, offscreen);
4587 // Enables fogging. Fogging causes vertices that are further away from the eye
4588 // to be rendered with a different color. The color is determined according to
4589 // the chosen fog mode; at it's simplest the color is linearly interpolated so
4590 // that vertices at @z_near are drawn fully with their original color and
4591 // vertices at @z_far are drawn fully with @fog_color. Fogging will remain
4592 // enabled until you call cogl_disable_fog().
4594 // <note>The fogging functions only work correctly when primitives use
4595 // unmultiplied alpha colors. By default Cogl will premultiply textures
4596 // and cogl_set_source_color() will premultiply colors, so unless you
4597 // explicitly load your textures requesting an unmultiplied internal format
4598 // and use cogl_material_set_color() you can only use fogging with fully
4599 // opaque primitives. This might improve in the future when we can depend
4600 // on fragment shaders.</note>
4601 // <fog_color>: The color of the fog
4602 // <mode>: A #CoglFogMode that determines the equation used to calculate the fogging blend factor.
4603 // <density>: Used by %COGL_FOG_MODE_EXPONENTIAL and by %COGL_FOG_MODE_EXPONENTIAL_SQUARED equations.
4604 // <z_near>: Position along Z axis where no fogging should be applied
4605 // <z_far>: Position along Z axis where full fogging should be applied
4606 static void set_fog(Color* fog_color, FogMode mode, float density, float z_near, float z_far) {
4607 cogl_set_fog(fog_color, mode, density, z_near, z_far);
4611 // This redirects all subsequent drawing to the specified framebuffer. This can
4612 // either be an offscreen buffer created with cogl_offscreen_new_to_texture ()
4613 // or in the future it may be an onscreen framebuffers too.
4614 // <buffer>: A #CoglFramebuffer object, either onscreen or offscreen.
4615 static void set_framebuffer(Framebuffer* buffer) {
4616 cogl_set_framebuffer(buffer);
4620 // Loads @matrix as the new model-view matrix.
4621 // <matrix>: the new model-view matrix
4622 static void set_modelview_matrix(Matrix* matrix) {
4623 cogl_set_modelview_matrix(matrix);
4627 // Unintrospectable function: set_path() / cogl_set_path()
4628 // Replaces the current path with @path. A reference is taken on the
4629 // object so if you no longer need the path you should unref with
4630 // cogl_object_unref().
4631 // <path>: A #CoglPath object
4632 static void set_path(Path* path) {
4633 cogl_set_path(path);
4637 // Loads matrix as the new projection matrix.
4638 // <matrix>: the new projection matrix
4639 static void set_projection_matrix(Matrix* matrix) {
4640 cogl_set_projection_matrix(matrix);
4644 // This function changes the material at the top of the source stack.
4645 // The material at the top of this stack defines the GPU state used to
4646 // process subsequent primitives, such as rectangles drawn with
4647 // cogl_rectangle() or vertices drawn using cogl_vertex_buffer_draw().
4648 // <material>: A #CoglMaterial
4649 static void set_source(void* material) {
4650 cogl_set_source(material);
4654 // This is a convenience function for creating a solid fill source material
4655 // from the given color. This color will be used for any subsequent drawing
4656 // operation.
4658 // The color will be premultiplied by Cogl, so the color should be
4659 // non-premultiplied. For example: use (1.0, 0.0, 0.0, 0.5) for
4660 // semi-transparent red.
4662 // See also cogl_set_source_color4ub() and cogl_set_source_color4f()
4663 // if you already have the color components.
4664 // <color>: a #CoglColor
4665 static void set_source_color(Color* color) {
4666 cogl_set_source_color(color);
4670 // This is a convenience function for creating a solid fill source material
4671 // from the given color using normalized values for each component. This color
4672 // will be used for any subsequent drawing operation.
4674 // The value for each component is a fixed point number in the range
4675 // between 0 and %1.0. If the values passed in are outside that
4676 // range, they will be clamped.
4677 // <red>: value of the red channel, between 0 and %1.0
4678 // <green>: value of the green channel, between 0 and %1.0
4679 // <blue>: value of the blue channel, between 0 and %1.0
4680 // <alpha>: value of the alpha channel, between 0 and %1.0
4681 static void set_source_color4f(float red, float green, float blue, float alpha) {
4682 cogl_set_source_color4f(red, green, blue, alpha);
4686 // This is a convenience function for creating a solid fill source material
4687 // from the given color using unsigned bytes for each component. This
4688 // color will be used for any subsequent drawing operation.
4690 // The value for each component is an unsigned byte in the range
4691 // between 0 and 255.
4692 // <red>: value of the red channel, between 0 and 255
4693 // <green>: value of the green channel, between 0 and 255
4694 // <blue>: value of the blue channel, between 0 and 255
4695 // <alpha>: value of the alpha channel, between 0 and 255
4696 static void set_source_color4ub(ubyte red, ubyte green, ubyte blue, ubyte alpha) {
4697 cogl_set_source_color4ub(red, green, blue, alpha);
4701 // This is a convenience function for creating a material with the first
4702 // layer set to #texture_handle and setting that material as the source with
4703 // cogl_set_source.
4705 // Note: There is no interaction between calls to cogl_set_source_color
4706 // and cogl_set_source_texture. If you need to blend a texture with a color then
4707 // you can create a simple material like this:
4708 // <programlisting>
4709 // material = cogl_material_new ();
4710 // cogl_material_set_color4ub (material, 0xff, 0x00, 0x00, 0x80);
4711 // cogl_material_set_layer (material, 0, tex_handle);
4712 // cogl_set_source (material);
4713 // </programlisting>
4714 // <texture_handle>: The Cogl texture you want as your source
4715 static void set_source_texture(Handle texture_handle) {
4716 cogl_set_source_texture(texture_handle);
4720 // Replaces the current viewport with the given values.
4721 // <x>: X offset of the viewport
4722 // <y>: Y offset of the viewport
4723 // <width>: Width of the viewport
4724 // <height>: Height of the viewport
4725 static void set_viewport(int x, int y, int width, int height) {
4726 cogl_set_viewport(x, y, width, height);
4730 // Compiles the shader, no return value, but the shader is now ready for
4731 // linking into a program.
4732 // <handle>: #CoglHandle for a shader.
4733 static void shader_compile(Handle handle) {
4734 cogl_shader_compile(handle);
4738 // Retrieves the information log for a coglobject, can be used in conjunction
4739 // with cogl_shader_get_parameteriv() to retrieve the compiler warnings/error
4740 // messages that caused a shader to not compile correctly, mainly useful for
4741 // debugging purposes.
4743 // g_free() to free it
4744 // RETURNS: a newly allocated string containing the info log. Use
4745 // <handle>: #CoglHandle for a shader.
4746 static char* /*new*/ shader_get_info_log(Handle handle) {
4747 return cogl_shader_get_info_log(handle);
4751 // Retrieves the type of a shader #CoglHandle
4753 // or %COGL_SHADER_TYPE_FRAGMENT if the shader is a frament processor
4754 // RETURNS: %COGL_SHADER_TYPE_VERTEX if the shader is a vertex processor
4755 // <handle>: #CoglHandle for a shader.
4756 static ShaderType shader_get_type(Handle handle) {
4757 return cogl_shader_get_type(handle);
4761 // Retrieves whether a shader #CoglHandle has been compiled
4762 // RETURNS: %TRUE if the shader object has sucessfully be compiled
4763 // <handle>: #CoglHandle for a shader.
4764 static int shader_is_compiled(Handle handle) {
4765 return cogl_shader_is_compiled(handle);
4769 // Unintrospectable function: shader_ref() / cogl_shader_ref()
4770 // Add an extra reference to a shader.
4771 // RETURNS: @handle
4772 // <handle>: A #CoglHandle to a shader.
4773 static Handle shader_ref(Handle handle) {
4774 return cogl_shader_ref(handle);
4778 // Replaces the current GLSL source associated with a shader with a new
4779 // one.
4780 // <shader>: #CoglHandle for a shader.
4781 // <source>: GLSL shader source.
4782 static void shader_source(Handle shader, char* source) {
4783 cogl_shader_source(shader, source);
4787 // Removes a reference to a shader. If it was the last reference the
4788 // shader object will be destroyed.
4789 // <handle>: A #CoglHandle to a shader.
4790 static void shader_unref(Handle handle) {
4791 cogl_shader_unref(handle);
4795 // Very fast fixed point implementation of square root for integers.
4797 // This function is at least 6x faster than clib sqrt() on x86, and (this is
4798 // not a typo!) about 500x faster on ARM without FPU. It's error is less than
4799 // 5% for arguments smaller than %COGL_SQRTI_ARG_5_PERCENT and less than 10%
4800 // for narguments smaller than %COGL_SQRTI_ARG_10_PERCENT. The maximum
4801 // argument that can be passed to this function is %COGL_SQRTI_ARG_MAX.
4802 // RETURNS: integer square root.
4803 // <x>: integer value
4804 static int sqrti(int x) {
4805 return cogl_sqrti(x);
4808 // Unintrospectable function: texture_2d_new_from_data_EXP() / cogl_texture_2d_new_from_data_EXP()
4809 static Texture2D* texture_2d_new_from_data_EXP(CoglContext* ctx, int width, int height, PixelFormat format, PixelFormat internal_format, int rowstride, ubyte* data, GLib2.Error** error=null) {
4810 return cogl_texture_2d_new_from_data_EXP(ctx, width, height, format, internal_format, rowstride, data, error);
4813 // Unintrospectable function: texture_2d_new_from_foreign_EXP() / cogl_texture_2d_new_from_foreign_EXP()
4814 static Texture2D* texture_2d_new_from_foreign_EXP(CoglContext* ctx, uint gl_handle, int width, int height, PixelFormat format, GLib2.Error** error=null) {
4815 return cogl_texture_2d_new_from_foreign_EXP(ctx, gl_handle, width, height, format, error);
4818 // Unintrospectable function: texture_2d_new_with_size_EXP() / cogl_texture_2d_new_with_size_EXP()
4819 static Texture2D* texture_2d_new_with_size_EXP(CoglContext* ctx, int width, int height, PixelFormat internal_format, GLib2.Error** error=null) {
4820 return cogl_texture_2d_new_with_size_EXP(ctx, width, height, internal_format, error);
4823 // Unintrospectable function: texture_3d_new_from_data_EXP() / cogl_texture_3d_new_from_data_EXP()
4824 static Handle texture_3d_new_from_data_EXP(uint width, uint height, uint depth, TextureFlags flags, PixelFormat format, PixelFormat internal_format, uint rowstride, uint image_stride, ubyte* data, GLib2.Error** error=null) {
4825 return cogl_texture_3d_new_from_data_EXP(width, height, depth, flags, format, internal_format, rowstride, image_stride, data, error);
4828 // Unintrospectable function: texture_3d_new_with_size_EXP() / cogl_texture_3d_new_with_size_EXP()
4829 static Handle texture_3d_new_with_size_EXP(uint width, uint height, uint depth, TextureFlags flags, PixelFormat internal_format, GLib2.Error** error=null) {
4830 return cogl_texture_3d_new_with_size_EXP(width, height, depth, flags, internal_format, error);
4833 static GLib2.Quark texture_error_quark() {
4834 return cogl_texture_error_quark();
4838 // Copies the pixel data from a cogl texture to system memory.
4840 // is not valid
4841 // RETURNS: the size of the texture data in bytes, or 0 if the texture
4842 // <handle>: a #CoglHandle for a texture.
4843 // <format>: the #CoglPixelFormat to store the texture as.
4844 // <rowstride>: the rowstride of @data or retrieved from texture if none is specified.
4845 // <data>: memory location to write contents of buffer, or %NULL if we're only querying the data size through the return value.
4846 static int texture_get_data(Handle handle, PixelFormat format, uint rowstride, ubyte* data) {
4847 return cogl_texture_get_data(handle, format, rowstride, data);
4851 // Queries the #CoglPixelFormat of a cogl texture.
4852 // RETURNS: the #CoglPixelFormat of the GPU side texture
4853 // <handle>: a #CoglHandle for a texture.
4854 static PixelFormat texture_get_format(Handle handle) {
4855 return cogl_texture_get_format(handle);
4859 // Queries the GL handles for a GPU side texture through its #CoglHandle.
4861 // If the texture is spliced the data for the first sub texture will be
4862 // queried.
4864 // if the handle was invalid
4865 // RETURNS: %TRUE if the handle was successfully retrieved, %FALSE
4866 // <handle>: a #CoglHandle for a texture.
4867 // <out_gl_handle>: pointer to return location for the textures GL handle, or %NULL.
4868 // <out_gl_target>: pointer to return location for the GL target type, or %NULL.
4869 static int texture_get_gl_texture(Handle handle, /*out*/ GL.uint* out_gl_handle=null, /*out*/ GL.enum* out_gl_target=null) {
4870 return cogl_texture_get_gl_texture(handle, out_gl_handle, out_gl_target);
4874 // Queries the height of a cogl texture.
4875 // RETURNS: the height of the GPU side texture in pixels
4876 // <handle>: a #CoglHandle for a texture.
4877 static uint texture_get_height(Handle handle) {
4878 return cogl_texture_get_height(handle);
4882 // Queries the maximum wasted (unused) pixels in one dimension of a GPU side
4883 // texture.
4884 // RETURNS: the maximum waste
4885 // <handle>: a #CoglHandle for a texture.
4886 static int texture_get_max_waste(Handle handle) {
4887 return cogl_texture_get_max_waste(handle);
4891 // Queries the rowstride of a cogl texture.
4892 // RETURNS: the offset in bytes between each consequetive row of pixels
4893 // <handle>: a #CoglHandle for a texture.
4894 static uint texture_get_rowstride(Handle handle) {
4895 return cogl_texture_get_rowstride(handle);
4899 // Queries the width of a cogl texture.
4900 // RETURNS: the width of the GPU side texture in pixels
4901 // <handle>: a #CoglHandle for a texture.
4902 static uint texture_get_width(Handle handle) {
4903 return cogl_texture_get_width(handle);
4907 // Queries if a texture is sliced (stored as multiple GPU side tecture
4908 // objects).
4910 // is stored as a single GPU texture
4911 // RETURNS: %TRUE if the texture is sliced, %FALSE if the texture
4912 // <handle>: a #CoglHandle for a texture.
4913 static int texture_is_sliced(Handle handle) {
4914 return cogl_texture_is_sliced(handle);
4918 // Unintrospectable function: texture_new_from_bitmap() / cogl_texture_new_from_bitmap()
4919 // Creates a COGL texture from a CoglBitmap.
4921 // %COGL_INVALID_HANDLE on failure
4922 // RETURNS: a #CoglHandle to the newly created texture or
4923 // <bmp_handle>: A CoglBitmap handle
4924 // <flags>: Optional flags for the texture, or %COGL_TEXTURE_NONE
4925 // <internal_format>: the #CoglPixelFormat to use for the GPU storage of the texture
4926 static Handle texture_new_from_bitmap(Handle bmp_handle, TextureFlags flags, PixelFormat internal_format) {
4927 return cogl_texture_new_from_bitmap(bmp_handle, flags, internal_format);
4931 // Unintrospectable function: texture_new_from_data() / cogl_texture_new_from_data()
4932 // Creates a new COGL texture based on data residing in memory.
4934 // %COGL_INVALID_HANDLE on failure
4935 // RETURNS: a #CoglHandle to the newly created texture or
4936 // <width>: width of texture in pixels
4937 // <height>: height of texture in pixels
4938 // <flags>: Optional flags for the texture, or %COGL_TEXTURE_NONE
4939 // <format>: the #CoglPixelFormat the buffer is stored in in RAM
4940 // <internal_format>: the #CoglPixelFormat that will be used for storing the buffer on the GPU. If COGL_PIXEL_FORMAT_ANY is given then a premultiplied format similar to the format of the source data will be used. The default blending equations of Cogl expect premultiplied color data; the main use of passing a non-premultiplied format here is if you have non-premultiplied source data and are going to adjust the blend mode (see cogl_material_set_blend()) or use the data for something other than straight blending.
4941 // <rowstride>: the memory offset in bytes between the starts of scanlines in @data
4942 // <data>: pointer the memory region where the source buffer resides
4943 static Handle texture_new_from_data(uint width, uint height, TextureFlags flags, PixelFormat format, PixelFormat internal_format, uint rowstride, ubyte* data) {
4944 return cogl_texture_new_from_data(width, height, flags, format, internal_format, rowstride, data);
4948 // Unintrospectable function: texture_new_from_file() / cogl_texture_new_from_file()
4949 // Creates a COGL texture from an image file.
4951 // %COGL_INVALID_HANDLE on failure
4952 // RETURNS: a #CoglHandle to the newly created texture or
4953 // <filename>: the file to load
4954 // <flags>: Optional flags for the texture, or %COGL_TEXTURE_NONE
4955 // <internal_format>: the #CoglPixelFormat to use for the GPU storage of the texture. If %COGL_PIXEL_FORMAT_ANY is given then a premultiplied format similar to the format of the source data will be used. The default blending equations of Cogl expect premultiplied color data; the main use of passing a non-premultiplied format here is if you have non-premultiplied source data and are going to adjust the blend mode (see cogl_material_set_blend()) or use the data for something other than straight blending.
4956 static Handle texture_new_from_file(char* filename, TextureFlags flags, PixelFormat internal_format, GLib2.Error** error=null) {
4957 return cogl_texture_new_from_file(filename, flags, internal_format, error);
4961 // Unintrospectable function: texture_new_from_foreign() / cogl_texture_new_from_foreign()
4962 // Creates a COGL texture based on an existing OpenGL texture; the
4963 // width, height and format are passed along since it is not always
4964 // possible to query these from OpenGL.
4966 // The waste arguments allow you to create a Cogl texture that maps to
4967 // a region smaller than the real OpenGL texture. For instance if your
4968 // hardware only supports power-of-two textures you may load a
4969 // non-power-of-two image into a larger power-of-two texture and use
4970 // the waste arguments to tell Cogl which region should be mapped to
4971 // the texture coordinate range [0:1].
4973 // %COGL_INVALID_HANDLE on failure
4974 // RETURNS: a #CoglHandle to the newly created texture or
4975 // <gl_handle>: opengl handle of foreign texture.
4976 // <gl_target>: opengl target type of foreign texture
4977 // <width>: width of foreign texture
4978 // <height>: height of foreign texture.
4979 // <x_pot_waste>: horizontal waste on the right hand edge of the texture.
4980 // <y_pot_waste>: vertical waste on the bottom edge of the texture.
4981 // <format>: format of the foreign texture.
4982 static Handle texture_new_from_foreign(GL.uint gl_handle, GL.enum gl_target, GL.uint width, GL.uint height, GL.uint x_pot_waste, GL.uint y_pot_waste, PixelFormat format) {
4983 return cogl_texture_new_from_foreign(gl_handle, gl_target, width, height, x_pot_waste, y_pot_waste, format);
4987 // Unintrospectable function: texture_new_from_sub_texture() / cogl_texture_new_from_sub_texture()
4988 // Creates a new texture which represents a subregion of another
4989 // texture. The GL resources will be shared so that no new texture
4990 // data is actually allocated.
4992 // Sub textures have undefined behaviour texture coordinates outside
4993 // of the range [0,1] are used. They also do not work with
4994 // CoglVertexBuffers.
4996 // The sub texture will keep a reference to the full texture so you do
4997 // not need to keep one separately if you only want to use the sub
4998 // texture.
4999 // RETURNS: a #CoglHandle to the new texture.
5000 // <full_texture>: a #CoglHandle to an existing texture
5001 // <sub_x>: X coordinate of the top-left of the subregion
5002 // <sub_y>: Y coordinate of the top-left of the subregion
5003 // <sub_width>: Width in pixels of the subregion
5004 // <sub_height>: Height in pixels of the subregion
5005 static Handle texture_new_from_sub_texture(Handle full_texture, int sub_x, int sub_y, int sub_width, int sub_height) {
5006 return cogl_texture_new_from_sub_texture(full_texture, sub_x, sub_y, sub_width, sub_height);
5010 // Unintrospectable function: texture_new_with_size() / cogl_texture_new_with_size()
5011 // Creates a new COGL texture with the specified dimensions and pixel format.
5013 // %COGL_INVALID_HANDLE on failure
5014 // RETURNS: a #CoglHandle to the newly created texture or
5015 // <width>: width of texture in pixels.
5016 // <height>: height of texture in pixels.
5017 // <flags>: Optional flags for the texture, or %COGL_TEXTURE_NONE
5018 // <internal_format>: the #CoglPixelFormat to use for the GPU storage of the texture.
5019 static Handle texture_new_with_size(uint width, uint height, TextureFlags flags, PixelFormat internal_format) {
5020 return cogl_texture_new_with_size(width, height, flags, internal_format);
5024 // Unintrospectable function: texture_ref() / cogl_texture_ref()
5025 // Increment the reference count for a cogl texture.
5026 // RETURNS: the @handle.
5027 // <handle>: a @CoglHandle.
5028 static Handle texture_ref(Handle handle) {
5029 return cogl_texture_ref(handle);
5033 // Sets the pixels in a rectangular subregion of @handle from an in-memory
5034 // buffer containing pixel data.
5036 // %FALSE otherwise
5037 // RETURNS: %TRUE if the subregion upload was successful, and
5038 // <handle>: a #CoglHandle.
5039 // <src_x>: upper left coordinate to use from source data.
5040 // <src_y>: upper left coordinate to use from source data.
5041 // <dst_x>: upper left destination horizontal coordinate.
5042 // <dst_y>: upper left destination vertical coordinate.
5043 // <dst_width>: width of destination region to write.
5044 // <dst_height>: height of destination region to write.
5045 // <width>: width of source data buffer.
5046 // <height>: height of source data buffer.
5047 // <format>: the #CoglPixelFormat used in the source buffer.
5048 // <rowstride>: rowstride of source buffer (computed from width if none specified)
5049 // <data>: the actual pixel data.
5050 static int texture_set_region(Handle handle, int src_x, int src_y, int dst_x, int dst_y, uint dst_width, uint dst_height, int width, int height, PixelFormat format, uint rowstride, ubyte* data) {
5051 return cogl_texture_set_region(handle, src_x, src_y, dst_x, dst_y, dst_width, dst_height, width, height, format, rowstride, data);
5055 // Decrement the reference count for a cogl texture.
5056 // <handle>: a @CoglHandle.
5057 static void texture_unref(Handle handle) {
5058 cogl_texture_unref(handle);
5062 // Multiplies the current model-view matrix by the given matrix.
5063 // <matrix>: the matrix to multiply with the current model-view
5064 static void transform(Matrix* matrix) {
5065 cogl_transform(matrix);
5069 // Multiplies the current model-view matrix by one that translates the
5070 // model along all three axes according to the given values.
5071 // <x>: Distance to translate along the x-axis
5072 // <y>: Distance to translate along the y-axis
5073 // <z>: Distance to translate along the z-axis
5074 static void translate(float x, float y, float z) {
5075 cogl_translate(x, y, z);
5078 // Unintrospectable function: vdraw_attributes() / cogl_vdraw_attributes()
5079 alias cogl_vdraw_attributes vdraw_attributes; // Variadic
5081 // Unintrospectable function: vdraw_indexed_attributes() / cogl_vdraw_indexed_attributes()
5082 alias cogl_vdraw_indexed_attributes vdraw_indexed_attributes; // Variadic
5084 static int vector3_equal_EXP(const(void)* v1, const(void)* v2) {
5085 return cogl_vector3_equal_EXP(v1, v2);
5089 // Adds an attribute to a buffer, or replaces a previously added
5090 // attribute with the same name.
5092 // You either can use one of the built-in names such as "gl_Vertex", or
5093 // "gl_MultiTexCoord0" to add standard attributes, like positions, colors
5094 // and normals, or you can add custom attributes for use in shaders.
5096 // The number of vertices declared when calling cogl_vertex_buffer_new()
5097 // determines how many attribute values will be read from the supplied
5098 // @pointer.
5100 // The data for your attribute isn't copied anywhere until you call
5101 // cogl_vertex_buffer_submit(), or issue a draw call which automatically
5102 // submits pending attribute changes. so the supplied pointer must remain
5103 // valid until then. If you are updating an existing attribute (done by
5104 // re-adding it) then you still need to re-call cogl_vertex_buffer_submit()
5105 // to commit the changes to the GPU. Be carefull to minimize the number
5106 // of calls to cogl_vertex_buffer_submit(), though.
5108 // <note>If you are interleving attributes it is assumed that each interleaved
5109 // attribute starts no farther than +- stride bytes from the other attributes
5110 // it is interleved with. I.e. this is ok:
5111 // <programlisting>
5112 // |-0-0-0-0-0-0-0-0-0-0|
5113 // </programlisting>
5114 // This is not ok:
5115 // <programlisting>
5116 // |- - - - -0-0-0-0-0-0 0 0 0 0|
5117 // </programlisting>
5118 // (Though you can have multiple groups of interleved attributes)</note>
5119 // <handle>: A vertex buffer handle
5120 // <attribute_name>: The name of your attribute. It should be a valid GLSL variable name and standard attribute types must use one of following built-in names: (Note: they correspond to the built-in names of GLSL) <itemizedlist> <listitem>"gl_Color"</listitem> <listitem>"gl_Normal"</listitem> <listitem>"gl_MultiTexCoord0, gl_MultiTexCoord1, ..."</listitem> <listitem>"gl_Vertex"</listitem> </itemizedlist> To support adding multiple variations of the same attribute the name can have a detail component, E.g. "gl_Color::active" or "gl_Color::inactive"
5121 // <n_components>: The number of components per attribute and must be 1, 2, 3 or 4
5122 // <type>: a #CoglAttributeType specifying the data type of each component.
5123 // <normalized>: If %TRUE, this specifies that values stored in an integer format should be mapped into the range [-1.0, 1.0] or [0.0, 1.0] for unsigned values. If %FALSE they are converted to floats directly.
5124 // <stride>: This specifies the number of bytes from the start of one attribute value to the start of the next value (for the same attribute). So, for example, with a position interleved with color like this: XYRGBAXYRGBAXYRGBA, then if each letter represents a byte, the stride for both attributes is 6. The special value 0 means the values are stored sequentially in memory.
5125 // <pointer>: This addresses the first attribute in the vertex array. This must remain valid until you either call cogl_vertex_buffer_submit() or issue a draw call.
5126 static void vertex_buffer_add(Handle handle, char* attribute_name, ubyte n_components, AttributeType type, int normalized, ushort stride, void* pointer) {
5127 cogl_vertex_buffer_add(handle, attribute_name, n_components, type, normalized, stride, pointer);
5131 // Deletes an attribute from a buffer. You will need to call
5132 // cogl_vertex_buffer_submit() or issue a draw call to commit this
5133 // change to the GPU.
5134 // <handle>: A vertex buffer handle
5135 // <attribute_name>: The name of a previously added attribute
5136 static void vertex_buffer_delete(Handle handle, char* attribute_name) {
5137 cogl_vertex_buffer_delete(handle, attribute_name);
5141 // Disables a previosuly added attribute.
5143 // Since it can be costly to add and remove new attributes to buffers; to make
5144 // individual buffers more reuseable it is possible to enable and disable
5145 // attributes before using a buffer for drawing.
5147 // You don't need to call cogl_vertex_buffer_submit() after using this
5148 // function.
5149 // <handle>: A vertex buffer handle
5150 // <attribute_name>: The name of the attribute you want to disable
5151 static void vertex_buffer_disable(Handle handle, char* attribute_name) {
5152 cogl_vertex_buffer_disable(handle, attribute_name);
5156 // Allows you to draw geometry using all or a subset of the
5157 // vertices in a vertex buffer.
5159 // Any un-submitted attribute changes are automatically submitted before
5160 // drawing.
5161 // <handle>: A vertex buffer handle
5162 // <mode>: A #CoglVerticesMode specifying how the vertices should be interpreted.
5163 // <first>: Specifies the index of the first vertex you want to draw with
5164 // <count>: Specifies the number of vertices you want to draw.
5165 static void vertex_buffer_draw(Handle handle, VerticesMode mode, int first, int count) {
5166 cogl_vertex_buffer_draw(handle, mode, first, count);
5170 // This function lets you use an array of indices to specify the vertices
5171 // within your vertex buffer that you want to draw. The indices themselves
5172 // are created by calling cogl_vertex_buffer_indices_new ()
5174 // Any un-submitted attribute changes are automatically submitted before
5175 // drawing.
5176 // <handle>: A vertex buffer handle
5177 // <mode>: A #CoglVerticesMode specifying how the vertices should be interpreted.
5178 // <indices>: A CoglHandle for a set of indices allocated via cogl_vertex_buffer_indices_new ()
5179 // <min_index>: Specifies the minimum vertex index contained in indices
5180 // <max_index>: Specifies the maximum vertex index contained in indices
5181 // <indices_offset>: An offset into named indices. The offset marks the first index to use for drawing.
5182 // <count>: Specifies the number of vertices you want to draw.
5183 static void vertex_buffer_draw_elements(Handle handle, VerticesMode mode, Handle indices, int min_index, int max_index, int indices_offset, int count) {
5184 cogl_vertex_buffer_draw_elements(handle, mode, indices, min_index, max_index, indices_offset, count);
5188 // Enables a previosuly disabled attribute.
5190 // Since it can be costly to add and remove new attributes to buffers; to make
5191 // individual buffers more reuseable it is possible to enable and disable
5192 // attributes before using a buffer for drawing.
5194 // You don't need to call cogl_vertex_buffer_submit() after using this function
5195 // <handle>: A vertex buffer handle
5196 // <attribute_name>: The name of the attribute you want to enable
5197 static void vertex_buffer_enable(Handle handle, char* attribute_name) {
5198 cogl_vertex_buffer_enable(handle, attribute_name);
5202 // Retrieves the number of vertices that @handle represents
5203 // RETURNS: the number of vertices
5204 // <handle>: A vertex buffer handle
5205 static uint vertex_buffer_get_n_vertices(Handle handle) {
5206 return cogl_vertex_buffer_get_n_vertices(handle);
5210 // Unintrospectable function: vertex_buffer_indices_get_for_quads() / cogl_vertex_buffer_indices_get_for_quads()
5211 // Creates a vertex buffer containing the indices needed to draw pairs
5212 // of triangles from a list of vertices grouped as quads. There will
5213 // be at least @n_indices entries in the buffer (but there may be
5214 // more).
5216 // The indices will follow this pattern:
5218 // 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7 ... etc
5220 // For example, if you submit vertices for a quad like like that shown
5221 // in <xref linkend="quad-indices-order"/> then you can request 6
5222 // indices to render two triangles like those shown in <xref
5223 // linkend="quad-indices-triangles"/>.
5225 // <figure id="quad-indices-order">
5226 // <title>Example of vertices submitted to form a quad</title>
5227 // <graphic fileref="quad-indices-order.png" format="PNG"/>
5228 // </figure>
5230 // <figure id="quad-indices-triangles">
5231 // <title>Illustration of the triangle indices that will be generated</title>
5232 // <graphic fileref="quad-indices-triangles.png" format="PNG"/>
5233 // </figure>
5235 // owned by Cogl and should not be modified or unref'd.
5236 // RETURNS: A %CoglHandle containing the indices. The handled is
5237 // <n_indices>: the number of indices in the vertex buffer.
5238 static Handle vertex_buffer_indices_get_for_quads(uint n_indices) {
5239 return cogl_vertex_buffer_indices_get_for_quads(n_indices);
5243 // Queries back the data type used for the given indices
5244 // RETURNS: The CoglIndicesType used
5245 // <indices>: An indices handle
5246 static IndicesType vertex_buffer_indices_get_type(Handle indices) {
5247 return cogl_vertex_buffer_indices_get_type(indices);
5251 // Unintrospectable function: vertex_buffer_indices_new() / cogl_vertex_buffer_indices_new()
5252 // Depending on how much geometry you are submitting it can be worthwhile
5253 // optimizing the number of redundant vertices you submit. Using an index
5254 // array allows you to reference vertices multiple times, for example
5255 // during triangle strips.
5257 // cogl_vertex_buffer_draw_elements().
5258 // RETURNS: A CoglHandle for the indices which you can pass to
5259 // <indices_type>: a #CoglIndicesType specifying the data type used for the indices.
5260 // <indices_array>: Specifies the address of your array of indices
5261 // <indices_len>: The number of indices in indices_array
5262 static Handle vertex_buffer_indices_new(IndicesType indices_type, void* indices_array, int indices_len) {
5263 return cogl_vertex_buffer_indices_new(indices_type, indices_array, indices_len);
5267 // Unintrospectable function: vertex_buffer_new() / cogl_vertex_buffer_new()
5268 // Creates a new vertex buffer that you can use to add attributes.
5269 // RETURNS: a new #CoglHandle
5270 // <n_vertices>: The number of vertices that your attributes will correspond to.
5271 static Handle vertex_buffer_new(uint n_vertices) {
5272 return cogl_vertex_buffer_new(n_vertices);
5276 // Unintrospectable function: vertex_buffer_ref() / cogl_vertex_buffer_ref()
5277 // Increment the reference count for a vertex buffer
5278 // RETURNS: the @handle.
5279 // <handle>: a @CoglHandle.
5280 static Handle vertex_buffer_ref(Handle handle) {
5281 return cogl_vertex_buffer_ref(handle);
5285 // Submits all the user added attributes to the GPU; once submitted, the
5286 // attributes can be used for drawing.
5288 // You should aim to minimize calls to this function since it implies
5289 // validating your data; it potentially incurs a transport cost (especially if
5290 // you are using GLX indirect rendering) and potentially a format conversion
5291 // cost if the GPU doesn't natively support any of the given attribute formats.
5292 // <handle>: A vertex buffer handle
5293 static void vertex_buffer_submit(Handle handle) {
5294 cogl_vertex_buffer_submit(handle);
5298 // Decrement the reference count for a vertex buffer
5299 // <handle>: a @CoglHandle.
5300 static void vertex_buffer_unref(Handle handle) {
5301 cogl_vertex_buffer_unref(handle);
5305 // Replace the current viewport with the given values.
5306 // <width>: Width of the viewport
5307 // <height>: Height of the viewport
5308 static void viewport(uint width, uint height) {
5309 cogl_viewport(width, height);
5312 // Unintrospectable function: xlib_renderer_add_filter_EXP() / cogl_xlib_renderer_add_filter_EXP()
5313 static void xlib_renderer_add_filter_EXP(CoglRenderer* renderer, XlibFilterFunc func, void* data) {
5314 cogl_xlib_renderer_add_filter_EXP(renderer, func, data);
5317 // Unintrospectable function: xlib_renderer_get_display_EXP() / cogl_xlib_renderer_get_display_EXP()
5318 static /*CTYPE*/ Display* xlib_renderer_get_display_EXP(CoglRenderer* renderer) {
5319 return cogl_xlib_renderer_get_display_EXP(renderer);
5322 // Unintrospectable function: xlib_renderer_get_foreign_display_EXP() / cogl_xlib_renderer_get_foreign_display_EXP()
5323 static /*CTYPE*/ Display* xlib_renderer_get_foreign_display_EXP(CoglRenderer* renderer) {
5324 return cogl_xlib_renderer_get_foreign_display_EXP(renderer);
5327 // Unintrospectable function: xlib_renderer_handle_event_EXP() / cogl_xlib_renderer_handle_event_EXP()
5328 static FilterReturn xlib_renderer_handle_event_EXP(CoglRenderer* renderer, XEvent* event) {
5329 return cogl_xlib_renderer_handle_event_EXP(renderer, event);
5332 // Unintrospectable function: xlib_renderer_remove_filter_EXP() / cogl_xlib_renderer_remove_filter_EXP()
5333 static void xlib_renderer_remove_filter_EXP(CoglRenderer* renderer, XlibFilterFunc func, void* data) {
5334 cogl_xlib_renderer_remove_filter_EXP(renderer, func, data);
5337 // Unintrospectable function: xlib_renderer_set_foreign_display_EXP() / cogl_xlib_renderer_set_foreign_display_EXP()
5338 static void xlib_renderer_set_foreign_display_EXP(CoglRenderer* renderer, Display* display) {
5339 cogl_xlib_renderer_set_foreign_display_EXP(renderer, display);
5343 // C prototypes:
5345 extern (C) {
5346 Attribute* cogl_attribute_new(AttributeBuffer* attribute_buffer, char* name, size_t stride, size_t offset, int components, AttributeType type);
5347 AttributeBuffer* cogl_attribute_buffer_new(size_t bytes, void* data);
5348 int cogl_bitmap_get_size_from_file(char* filename, /*out*/ int* width, /*out*/ int* height);
5349 Bitmap* cogl_bitmap_new_from_file(char* filename, GLib2.Error** error);
5350 uint cogl_buffer_get_size_EXP(Buffer* this_);
5351 BufferUpdateHint cogl_buffer_get_update_hint_EXP(Buffer* this_);
5352 void* cogl_buffer_map_EXP(Buffer* this_, BufferAccess access, BufferMapHint hints);
5353 int cogl_buffer_set_data_EXP(Buffer* this_, size_t offset, void* data, size_t size);
5354 void cogl_buffer_set_update_hint_EXP(Buffer* this_, BufferUpdateHint hint);
5355 void cogl_buffer_unmap_EXP(Buffer* this_);
5356 Color* cogl_color_copy(Color* this_);
5357 void cogl_color_free(Color* this_);
5358 float cogl_color_get_alpha(Color* this_);
5359 ubyte cogl_color_get_alpha_byte(Color* this_);
5360 float cogl_color_get_alpha_float(Color* this_);
5361 float cogl_color_get_blue(Color* this_);
5362 ubyte cogl_color_get_blue_byte(Color* this_);
5363 float cogl_color_get_blue_float(Color* this_);
5364 float cogl_color_get_green(Color* this_);
5365 ubyte cogl_color_get_green_byte(Color* this_);
5366 float cogl_color_get_green_float(Color* this_);
5367 float cogl_color_get_red(Color* this_);
5368 ubyte cogl_color_get_red_byte(Color* this_);
5369 float cogl_color_get_red_float(Color* this_);
5370 void cogl_color_init_from_4f(Color* this_, float red, float green, float blue, float alpha);
5371 void cogl_color_init_from_4fv(Color* this_, float* color_array);
5372 void cogl_color_init_from_4ub(Color* this_, ubyte red, ubyte green, ubyte blue, ubyte alpha);
5373 void cogl_color_premultiply(Color* this_);
5374 void cogl_color_set_alpha(Color* this_, float alpha);
5375 void cogl_color_set_alpha_byte(Color* this_, ubyte alpha);
5376 void cogl_color_set_alpha_float(Color* this_, float alpha);
5377 void cogl_color_set_blue(Color* this_, float blue);
5378 void cogl_color_set_blue_byte(Color* this_, ubyte blue);
5379 void cogl_color_set_blue_float(Color* this_, float blue);
5380 void cogl_color_set_from_4f(Color* this_, float red, float green, float blue, float alpha);
5381 void cogl_color_set_from_4ub(Color* this_, ubyte red, ubyte green, ubyte blue, ubyte alpha);
5382 void cogl_color_set_green(Color* this_, float green);
5383 void cogl_color_set_green_byte(Color* this_, ubyte green);
5384 void cogl_color_set_green_float(Color* this_, float green);
5385 void cogl_color_set_red(Color* this_, float red);
5386 void cogl_color_set_red_byte(Color* this_, ubyte red);
5387 void cogl_color_set_red_float(Color* this_, float red);
5388 void cogl_color_unpremultiply(Color* this_);
5389 int cogl_color_equal(const(void)* v1, const(void)* v2);
5390 Color* cogl_color_new();
5391 void cogl_depth_state_get_range(DepthState* this_, float* near_val, float* far_val);
5392 int cogl_depth_state_get_test_enabled(DepthState* this_);
5393 DepthTestFunction cogl_depth_state_get_test_function(DepthState* this_);
5394 int cogl_depth_state_get_write_enabled(DepthState* this_);
5395 void cogl_depth_state_init(DepthState* this_);
5396 void cogl_depth_state_set_range(DepthState* this_, float near_val, float far_val);
5397 void cogl_depth_state_set_test_enabled(DepthState* this_, int enable);
5398 void cogl_depth_state_set_test_function(DepthState* this_, DepthTestFunction function_);
5399 void cogl_depth_state_set_write_enabled(DepthState* this_, int enable);
5400 Euler* cogl_euler_copy(Euler* this_);
5401 void cogl_euler_free(Euler* this_);
5402 void cogl_euler_init(Euler* this_, float heading, float pitch, float roll);
5403 void cogl_euler_init_from_matrix(Euler* this_, Matrix* matrix);
5404 void cogl_euler_init_from_quaternion(Euler* this_, Quaternion* quaternion);
5405 int cogl_euler_equal(const(void)* v1, const(void)* v2);
5406 Fixed cogl_fixed_log2(uint x);
5407 uint cogl_fixed_pow(uint x, Fixed y);
5408 Fixed cogl_fixed_atan(Fixed* this_);
5409 Fixed cogl_fixed_atan2(Fixed* this_, Fixed b);
5410 Fixed cogl_fixed_cos(Fixed* this_);
5411 Fixed cogl_fixed_div(Fixed* this_, Fixed b);
5412 Fixed cogl_fixed_mul(Fixed* this_, Fixed b);
5413 Fixed cogl_fixed_mul_div(Fixed* this_, Fixed b, Fixed c);
5414 uint cogl_fixed_pow2(Fixed* this_);
5415 Fixed cogl_fixed_sin(Fixed* this_);
5416 Fixed cogl_fixed_sqrt(Fixed* this_);
5417 Fixed cogl_fixed_tan(Fixed* this_);
5418 IndexBuffer* cogl_index_buffer_new(size_t bytes);
5419 IndexBuffer* cogl_indices_get_buffer(Indices* this_);
5420 size_t cogl_indices_get_offset(Indices* this_);
5421 void cogl_indices_set_offset(Indices* this_, size_t offset);
5422 Indices* cogl_indices_new(IndicesType type, void* indices_data, int n_indices);
5423 Indices* cogl_indices_new_for_buffer(IndicesType type, IndexBuffer* buffer, size_t offset);
5424 Material* cogl_material_copy(Material* this_);
5425 void cogl_material_get_ambient(Material* this_, Color* ambient);
5426 void cogl_material_get_color(Material* this_, /*out*/ Color* color);
5427 void cogl_material_get_diffuse(Material* this_, Color* diffuse);
5428 void cogl_material_get_emission(Material* this_, Color* emission);
5429 int cogl_material_get_layer_point_sprite_coords_enabled(Material* this_, int layer_index);
5430 MaterialWrapMode cogl_material_get_layer_wrap_mode_p(Material* this_, int layer_index);
5431 MaterialWrapMode cogl_material_get_layer_wrap_mode_s(Material* this_, int layer_index);
5432 MaterialWrapMode cogl_material_get_layer_wrap_mode_t(Material* this_, int layer_index);
5433 GLib2.List* cogl_material_get_layers(Material* this_);
5434 int cogl_material_get_n_layers(Material* this_);
5435 float cogl_material_get_point_size(Material* this_);
5436 float cogl_material_get_shininess(Material* this_);
5437 void cogl_material_get_specular(Material* this_, Color* specular);
5438 Handle cogl_material_get_user_program(Material* this_);
5439 void cogl_material_remove_layer(Material* this_, int layer_index);
5440 void cogl_material_set_alpha_test_function(Material* this_, MaterialAlphaFunc alpha_func, float alpha_reference);
5441 void cogl_material_set_ambient(Material* this_, Color* ambient);
5442 void cogl_material_set_ambient_and_diffuse(Material* this_, Color* color);
5443 int cogl_material_set_blend(Material* this_, char* blend_string, GLib2.Error** error);
5444 void cogl_material_set_blend_constant(Material* this_, Color* constant_color);
5445 void cogl_material_set_color(Material* this_, Color* color);
5446 void cogl_material_set_color4f(Material* this_, float red, float green, float blue, float alpha);
5447 void cogl_material_set_color4ub(Material* this_, ubyte red, ubyte green, ubyte blue, ubyte alpha);
5448 void cogl_material_set_diffuse(Material* this_, Color* diffuse);
5449 void cogl_material_set_emission(Material* this_, Color* emission);
5450 void cogl_material_set_layer(Material* this_, int layer_index, Handle texture);
5451 int cogl_material_set_layer_combine(Material* this_, int layer_index, char* blend_string, GLib2.Error** error);
5452 void cogl_material_set_layer_combine_constant(Material* this_, int layer_index, Color* constant);
5453 void cogl_material_set_layer_filters(Material* this_, int layer_index, MaterialFilter min_filter, MaterialFilter mag_filter);
5454 void cogl_material_set_layer_matrix(Material* this_, int layer_index, Matrix* matrix);
5455 int cogl_material_set_layer_point_sprite_coords_enabled(Material* this_, int layer_index, int enable, GLib2.Error** error);
5456 void cogl_material_set_layer_wrap_mode(Material* this_, int layer_index, MaterialWrapMode mode);
5457 void cogl_material_set_layer_wrap_mode_p(Material* this_, int layer_index, MaterialWrapMode mode);
5458 void cogl_material_set_layer_wrap_mode_s(Material* this_, int layer_index, MaterialWrapMode mode);
5459 void cogl_material_set_layer_wrap_mode_t(Material* this_, int layer_index, MaterialWrapMode mode);
5460 void cogl_material_set_point_size(Material* this_, float point_size);
5461 void cogl_material_set_shininess(Material* this_, float shininess);
5462 void cogl_material_set_specular(Material* this_, Color* specular);
5463 void cogl_material_set_user_program(Material* this_, Handle program);
5464 Material* cogl_material_new();
5465 Handle cogl_material_ref(Handle material);
5466 void cogl_material_unref(Handle material);
5467 MaterialFilter cogl_material_layer_get_mag_filter(MaterialLayer* this_);
5468 MaterialFilter cogl_material_layer_get_min_filter(MaterialLayer* this_);
5469 Handle cogl_material_layer_get_texture(MaterialLayer* this_);
5470 MaterialWrapMode cogl_material_layer_get_wrap_mode_p(MaterialLayer* this_);
5471 MaterialWrapMode cogl_material_layer_get_wrap_mode_s(MaterialLayer* this_);
5472 MaterialWrapMode cogl_material_layer_get_wrap_mode_t(MaterialLayer* this_);
5473 Matrix* cogl_matrix_copy(Matrix* this_);
5474 void cogl_matrix_free(Matrix* this_);
5475 void cogl_matrix_frustum(Matrix* this_, float left, float right, float bottom, float top, float z_near, float z_far);
5476 float* cogl_matrix_get_array(Matrix* this_);
5477 int cogl_matrix_get_inverse(Matrix* this_, /*out*/ Matrix* inverse);
5478 void cogl_matrix_init_from_array(Matrix* this_, float* array);
5479 void cogl_matrix_init_identity(Matrix* this_);
5480 int cogl_matrix_is_identity(Matrix* this_);
5481 void cogl_matrix_look_at_EXP(Matrix* this_, float eye_position_x, float eye_position_y, float eye_position_z, float object_x, float object_y, float object_z, float world_up_x, float world_up_y, float world_up_z);
5482 void cogl_matrix_multiply(Matrix* this_, Matrix* a, Matrix* b);
5483 void cogl_matrix_ortho(Matrix* this_, float left, float right, float bottom, float top, float z_near, float z_far);
5484 void cogl_matrix_perspective(Matrix* this_, float fov_y, float aspect, float z_near, float z_far);
5485 void cogl_matrix_rotate(Matrix* this_, float angle, float x, float y, float z);
5486 void cogl_matrix_scale(Matrix* this_, float sx, float sy, float sz);
5487 void cogl_matrix_transform_point(Matrix* this_, /*inout*/ float* x, /*inout*/ float* y, /*inout*/ float* z, /*inout*/ float* w);
5488 void cogl_matrix_translate(Matrix* this_, float x, float y, float z);
5489 int cogl_matrix_equal(const(void)* v1, const(void)* v2);
5490 void* cogl_object_get_user_data(Object* this_, UserDataKey* key);
5491 void cogl_object_set_user_data(Object* this_, UserDataKey* key, void* user_data, UserDataDestroyCallback destroy);
5492 void* cogl_object_ref(void* object);
5493 void cogl_object_unref(void* object);
5494 Path* /*new*/ cogl_path_copy(Path* this_);
5495 void cogl_path_arc(float center_x, float center_y, float radius_x, float radius_y, float angle_1, float angle_2);
5496 void cogl_path_close();
5497 void cogl_path_curve_to(float x_1, float y_1, float x_2, float y_2, float x_3, float y_3);
5498 void cogl_path_ellipse(float center_x, float center_y, float radius_x, float radius_y);
5499 void cogl_path_fill();
5500 void cogl_path_fill_preserve();
5501 PathFillRule cogl_path_get_fill_rule();
5502 void cogl_path_line(float x_1, float y_1, float x_2, float y_2);
5503 void cogl_path_line_to(float x, float y);
5504 void cogl_path_move_to(float x, float y);
5505 void cogl_path_new();
5506 void cogl_path_polygon(float* coords, int num_points);
5507 void cogl_path_polyline(float* coords, int num_points);
5508 void cogl_path_rectangle(float x_1, float y_1, float x_2, float y_2);
5509 void cogl_path_rel_curve_to(float x_1, float y_1, float x_2, float y_2, float x_3, float y_3);
5510 void cogl_path_rel_line_to(float x, float y);
5511 void cogl_path_rel_move_to(float x, float y);
5512 void cogl_path_round_rectangle(float x_1, float y_1, float x_2, float y_2, float radius, float arc_step);
5513 void cogl_path_set_fill_rule(PathFillRule fill_rule);
5514 void cogl_path_stroke();
5515 void cogl_path_stroke_preserve();
5516 PixelBuffer* cogl_pixel_buffer_new_with_size_EXP(uint width, uint height, PixelFormat format, uint* stride);
5517 void cogl_primitive_draw(Primitive* this_);
5518 int cogl_primitive_get_first_vertex(Primitive* this_);
5519 VerticesMode cogl_primitive_get_mode(Primitive* this_);
5520 int cogl_primitive_get_n_vertices(Primitive* this_);
5521 void cogl_primitive_set_attributes(Primitive* this_, Attribute** attributes, int n_attributes);
5522 void cogl_primitive_set_first_vertex(Primitive* this_, int first_vertex);
5523 void cogl_primitive_set_indices(Primitive* this_, Indices* indices);
5524 void cogl_primitive_set_mode(Primitive* this_, VerticesMode mode);
5525 void cogl_primitive_set_n_vertices(Primitive* this_, int n_vertices);
5526 Primitive* cogl_primitive_new(VerticesMode mode, int n_vertices, ...);
5527 Primitive* cogl_primitive_new_p2(VerticesMode mode, int n_vertices, VertexP2* data);
5528 Primitive* cogl_primitive_new_p2c4(VerticesMode mode, int n_vertices, VertexP2C4* data);
5529 Primitive* cogl_primitive_new_p2t2(VerticesMode mode, int n_vertices, VertexP2T2* data);
5530 Primitive* cogl_primitive_new_p2t2c4(VerticesMode mode, int n_vertices, VertexP2T2C4* data);
5531 Primitive* cogl_primitive_new_p3(VerticesMode mode, int n_vertices, VertexP3* data);
5532 Primitive* cogl_primitive_new_p3c4(VerticesMode mode, int n_vertices, VertexP3C4* data);
5533 Primitive* cogl_primitive_new_p3t2(VerticesMode mode, int n_vertices, VertexP3T2* data);
5534 Primitive* cogl_primitive_new_p3t2c4(VerticesMode mode, int n_vertices, VertexP3T2C4* data);
5535 Primitive* cogl_primitive_new_with_attributes(VerticesMode mode, int n_vertices, Attribute** attributes, int n_attributes);
5536 Quaternion* cogl_quaternion_copy(Quaternion* this_);
5537 float cogl_quaternion_dot_product(Quaternion* this_, Quaternion* b);
5538 void cogl_quaternion_free(Quaternion* this_);
5539 float cogl_quaternion_get_rotation_angle(Quaternion* this_);
5540 void cogl_quaternion_get_rotation_axis(Quaternion* this_, Vector3* vector);
5541 void cogl_quaternion_init(Quaternion* this_, float angle, float x, float y, float z);
5542 void cogl_quaternion_init_from_angle_vector(Quaternion* this_, float angle, Vector3* axis);
5543 void cogl_quaternion_init_from_array(Quaternion* this_, float* array);
5544 void cogl_quaternion_init_from_euler(Quaternion* this_, Euler* euler);
5545 void cogl_quaternion_init_from_x_rotation(Quaternion* this_, float angle);
5546 void cogl_quaternion_init_from_y_rotation(Quaternion* this_, float angle);
5547 void cogl_quaternion_init_from_z_rotation(Quaternion* this_, float angle);
5548 void cogl_quaternion_init_identity(Quaternion* this_);
5549 void cogl_quaternion_invert(Quaternion* this_);
5550 void cogl_quaternion_multiply(Quaternion* this_, Quaternion* left, Quaternion* right);
5551 void cogl_quaternion_nlerp(Quaternion* this_, Quaternion* a, Quaternion* b, float t);
5552 void cogl_quaternion_normalize(Quaternion* this_);
5553 void cogl_quaternion_pow(Quaternion* this_, float exponent);
5554 void cogl_quaternion_slerp(Quaternion* this_, Quaternion* a, Quaternion* b, float t);
5555 void cogl_quaternion_squad(Quaternion* this_, Quaternion* prev, Quaternion* a, Quaternion* b, Quaternion* next, float t);
5556 int cogl_quaternion_equal(const(void)* v1, const(void)* v2);
5557 void cogl_vector3_add_EXP(Vector3* this_, Vector3* a, Vector3* b);
5558 Vector3* cogl_vector3_copy_EXP(Vector3* this_);
5559 void cogl_vector3_cross_product_EXP(Vector3* this_, Vector3* u, Vector3* v);
5560 float cogl_vector3_distance_EXP(Vector3* this_, Vector3* b);
5561 void cogl_vector3_divide_scalar_EXP(Vector3* this_, float scalar);
5562 float cogl_vector3_dot_product_EXP(Vector3* this_, Vector3* b);
5563 int cogl_vector3_equal_with_epsilon_EXP(Vector3* this_, Vector3* vector1, float epsilon);
5564 void cogl_vector3_free_EXP(Vector3* this_);
5565 void cogl_vector3_init_EXP(Vector3* this_, float x, float y, float z);
5566 void cogl_vector3_init_zero_EXP(Vector3* this_);
5567 void cogl_vector3_invert_EXP(Vector3* this_);
5568 float cogl_vector3_magnitude_EXP(Vector3* this_);
5569 void cogl_vector3_multiply_scalar_EXP(Vector3* this_, float scalar);
5570 void cogl_vector3_normalize_EXP(Vector3* this_);
5571 void cogl_vector3_subtract_EXP(Vector3* this_, Vector3* a, Vector3* b);
5572 int cogl_vector3_equal_EXP(const(void)* v1, const(void)* v2);
5573 Fixed cogl_angle_cos(Angle angle);
5574 Fixed cogl_angle_sin(Angle angle);
5575 Fixed cogl_angle_tan(Angle angle);
5576 void cogl_begin_gl();
5577 GLib2.Quark cogl_bitmap_error_quark();
5578 GLib2.Quark cogl_blend_string_error_quark();
5579 int cogl_check_extension(char* name, char* ext);
5580 void cogl_clear(Color* color, c_ulong buffers);
5581 void cogl_clip_ensure();
5582 void cogl_clip_pop();
5583 void cogl_clip_push(float x_offset, float y_offset, float width, float height);
5584 void cogl_clip_push_from_path();
5585 void cogl_clip_push_from_path_preserve();
5586 void cogl_clip_push_rectangle(float x0, float y0, float x1, float y1);
5587 void cogl_clip_push_window_rect(float x_offset, float y_offset, float width, float height);
5588 void cogl_clip_push_window_rectangle(int x_offset, int y_offset, int width, int height);
5589 void cogl_clip_stack_restore();
5590 void cogl_clip_stack_save();
5591 int cogl_clutter_check_extension_CLUTTER(char* name, char* ext);
5592 int cogl_clutter_winsys_has_feature_CLUTTER(WinsysFeature feature);
5593 /*CTYPE*/ XVisualInfo* cogl_clutter_winsys_xlib_get_visual_info_CLUTTER();
5594 Handle cogl_create_program();
5595 Handle cogl_create_shader(ShaderType shader_type);
5596 void cogl_disable_fog();
5597 Fixed cogl_double_to_fixed(double value);
5598 int cogl_double_to_int(double value);
5599 uint cogl_double_to_uint(double value);
5600 void cogl_draw_attributes(VerticesMode mode, int first_vertex, int n_vertices, Attribute** attributes, int n_attributes);
5601 void cogl_draw_indexed_attributes(VerticesMode mode, int first_vertex, int n_vertices, Indices* indices, Attribute** attributes, int n_attributes);
5602 void cogl_end_gl();
5603 int cogl_features_available(FeatureFlags features);
5604 void cogl_flush();
5605 void cogl_frustum(float left, float right, float bottom, float top, float z_near, float z_far);
5606 int cogl_get_backface_culling_enabled();
5607 void cogl_get_bitmasks(/*out*/ int* red, /*out*/ int* green, /*out*/ int* blue, /*out*/ int* alpha);
5608 int cogl_get_depth_test_enabled();
5609 FeatureFlags cogl_get_features();
5610 void cogl_get_modelview_matrix(/*out*/ Matrix* matrix);
5611 GLib2.OptionGroup* cogl_get_option_group();
5612 Path* cogl_get_path();
5613 FuncPtr cogl_get_proc_address(char* name);
5614 void cogl_get_projection_matrix(/*out*/ Matrix* matrix);
5615 Indices* cogl_get_rectangle_indices(int n_rectangles);
5616 void* cogl_get_source();
5617 Quaternion* cogl_get_static_identity_quaternion();
5618 Quaternion* cogl_get_static_zero_quaternion();
5619 void cogl_get_viewport(/*out*/ float v);
5620 Type cogl_handle_get_type();
5621 Handle cogl_handle_ref(Handle handle);
5622 void cogl_handle_unref(Handle handle);
5623 IndicesType cogl_indices_get_type(Indices* indices);
5624 int cogl_is_attribute(void* object);
5625 int cogl_is_attribute_buffer(void* object);
5626 int cogl_is_bitmap(Handle handle);
5627 int cogl_is_buffer_EXP(void* object);
5628 int cogl_is_index_buffer(void* object);
5629 int cogl_is_material(Handle handle);
5630 int cogl_is_offscreen(Handle handle);
5631 int cogl_is_path(Handle handle);
5632 int cogl_is_pixel_buffer_EXP(void* object);
5633 int cogl_is_primitive(void* object);
5634 int cogl_is_program(Handle handle);
5635 int cogl_is_shader(Handle handle);
5636 int cogl_is_texture(Handle handle);
5637 int cogl_is_texture_2d_EXP(void* object);
5638 int cogl_is_texture_3d_EXP(Handle handle);
5639 int cogl_is_vertex_buffer(Handle handle);
5640 int cogl_is_vertex_buffer_indices(Handle handle);
5641 MaterialLayerType cogl_material_layer_get_type(MaterialLayer* layer);
5642 Handle /*new*/ cogl_offscreen_new_to_texture(Handle handle);
5643 Handle cogl_offscreen_ref(Handle handle);
5644 void cogl_offscreen_unref(Handle handle);
5645 void cogl_onscreen_clutter_backend_set_size_CLUTTER(int width, int height);
5646 void cogl_ortho(float left, float right, float bottom, float top, float near, float far);
5647 void cogl_perspective(float fovy, float aspect, float z_near, float z_far);
5648 void cogl_polygon(TextureVertex* vertices, uint n_vertices, int use_color);
5649 void cogl_pop_draw_buffer();
5650 void cogl_pop_framebuffer();
5651 void cogl_pop_matrix();
5652 void cogl_pop_source();
5653 void cogl_program_attach_shader(Handle program_handle, Handle shader_handle);
5654 int cogl_program_get_uniform_location(Handle handle, char* uniform_name);
5655 void cogl_program_link(Handle handle);
5656 Handle cogl_program_ref(Handle handle);
5657 void cogl_program_set_uniform_1f(Handle program, int uniform_location, float value);
5658 void cogl_program_set_uniform_1i(Handle program, int uniform_location, int value);
5659 void cogl_program_set_uniform_float(Handle program, int uniform_location, int n_components, int count, float* value);
5660 void cogl_program_set_uniform_int(Handle program, int uniform_location, int n_components, int count, int* value);
5661 void cogl_program_set_uniform_matrix(Handle program, int uniform_location, int dimensions, int count, int transpose, float* value);
5662 void cogl_program_uniform_1f(int uniform_no, float value);
5663 void cogl_program_uniform_1i(int uniform_no, int value);
5664 void cogl_program_uniform_float(int uniform_no, int size, int count, float* value);
5665 void cogl_program_uniform_int(int uniform_no, int size, int count, int* value);
5666 void cogl_program_uniform_matrix(int uniform_no, int size, int count, int transpose, float* value);
5667 void cogl_program_unref(Handle handle);
5668 void cogl_program_use(Handle handle);
5669 void cogl_push_draw_buffer();
5670 void cogl_push_framebuffer(Framebuffer* buffer);
5671 void cogl_push_matrix();
5672 void cogl_push_source(void* material);
5673 void cogl_read_pixels(int x, int y, int width, int height, ReadPixelsFlags source, PixelFormat format, ubyte* pixels);
5674 void cogl_rectangle(float x_1, float y_1, float x_2, float y_2);
5675 void cogl_rectangle_with_multitexture_coords(float x1, float y1, float x2, float y2, float* tex_coords, int tex_coords_len);
5676 void cogl_rectangle_with_texture_coords(float x1, float y1, float x2, float y2, float tx1, float ty1, float tx2, float ty2);
5677 void cogl_rectangles(float* verts, uint n_rects);
5678 void cogl_rectangles_with_texture_coords(float* verts, uint n_rects);
5679 void cogl_rotate(float angle, float x, float y, float z);
5680 void cogl_scale(float x, float y, float z);
5681 void cogl_set_backface_culling_enabled(int setting);
5682 void cogl_set_depth_test_enabled(int setting);
5683 void cogl_set_draw_buffer(BufferTarget target, Handle offscreen);
5684 void cogl_set_fog(Color* fog_color, FogMode mode, float density, float z_near, float z_far);
5685 void cogl_set_framebuffer(Framebuffer* buffer);
5686 void cogl_set_modelview_matrix(Matrix* matrix);
5687 void cogl_set_path(Path* path);
5688 void cogl_set_projection_matrix(Matrix* matrix);
5689 void cogl_set_source(void* material);
5690 void cogl_set_source_color(Color* color);
5691 void cogl_set_source_color4f(float red, float green, float blue, float alpha);
5692 void cogl_set_source_color4ub(ubyte red, ubyte green, ubyte blue, ubyte alpha);
5693 void cogl_set_source_texture(Handle texture_handle);
5694 void cogl_set_viewport(int x, int y, int width, int height);
5695 void cogl_shader_compile(Handle handle);
5696 char* /*new*/ cogl_shader_get_info_log(Handle handle);
5697 ShaderType cogl_shader_get_type(Handle handle);
5698 int cogl_shader_is_compiled(Handle handle);
5699 Handle cogl_shader_ref(Handle handle);
5700 void cogl_shader_source(Handle shader, char* source);
5701 void cogl_shader_unref(Handle handle);
5702 int cogl_sqrti(int x);
5703 Texture2D* cogl_texture_2d_new_from_data_EXP(CoglContext* ctx, int width, int height, PixelFormat format, PixelFormat internal_format, int rowstride, ubyte* data, GLib2.Error** error);
5704 Texture2D* cogl_texture_2d_new_from_foreign_EXP(CoglContext* ctx, uint gl_handle, int width, int height, PixelFormat format, GLib2.Error** error);
5705 Texture2D* cogl_texture_2d_new_with_size_EXP(CoglContext* ctx, int width, int height, PixelFormat internal_format, GLib2.Error** error);
5706 Handle cogl_texture_3d_new_from_data_EXP(uint width, uint height, uint depth, TextureFlags flags, PixelFormat format, PixelFormat internal_format, uint rowstride, uint image_stride, ubyte* data, GLib2.Error** error);
5707 Handle cogl_texture_3d_new_with_size_EXP(uint width, uint height, uint depth, TextureFlags flags, PixelFormat internal_format, GLib2.Error** error);
5708 GLib2.Quark cogl_texture_error_quark();
5709 int cogl_texture_get_data(Handle handle, PixelFormat format, uint rowstride, ubyte* data);
5710 PixelFormat cogl_texture_get_format(Handle handle);
5711 int cogl_texture_get_gl_texture(Handle handle, /*out*/ GL.uint* out_gl_handle=null, /*out*/ GL.enum* out_gl_target=null);
5712 uint cogl_texture_get_height(Handle handle);
5713 int cogl_texture_get_max_waste(Handle handle);
5714 uint cogl_texture_get_rowstride(Handle handle);
5715 uint cogl_texture_get_width(Handle handle);
5716 int cogl_texture_is_sliced(Handle handle);
5717 Handle cogl_texture_new_from_bitmap(Handle bmp_handle, TextureFlags flags, PixelFormat internal_format);
5718 Handle cogl_texture_new_from_data(uint width, uint height, TextureFlags flags, PixelFormat format, PixelFormat internal_format, uint rowstride, ubyte* data);
5719 Handle cogl_texture_new_from_file(char* filename, TextureFlags flags, PixelFormat internal_format, GLib2.Error** error);
5720 Handle cogl_texture_new_from_foreign(GL.uint gl_handle, GL.enum gl_target, GL.uint width, GL.uint height, GL.uint x_pot_waste, GL.uint y_pot_waste, PixelFormat format);
5721 Handle cogl_texture_new_from_sub_texture(Handle full_texture, int sub_x, int sub_y, int sub_width, int sub_height);
5722 Handle cogl_texture_new_with_size(uint width, uint height, TextureFlags flags, PixelFormat internal_format);
5723 Handle cogl_texture_ref(Handle handle);
5724 int cogl_texture_set_region(Handle handle, int src_x, int src_y, int dst_x, int dst_y, uint dst_width, uint dst_height, int width, int height, PixelFormat format, uint rowstride, ubyte* data);
5725 void cogl_texture_unref(Handle handle);
5726 void cogl_transform(Matrix* matrix);
5727 void cogl_translate(float x, float y, float z);
5728 void cogl_vdraw_attributes(VerticesMode mode, int first_vertex, int n_vertices, ...);
5729 void cogl_vdraw_indexed_attributes(VerticesMode mode, int first_vertex, int n_vertices, Indices* indices, ...);
5730 void cogl_vertex_buffer_add(Handle handle, char* attribute_name, ubyte n_components, AttributeType type, int normalized, ushort stride, void* pointer);
5731 void cogl_vertex_buffer_delete(Handle handle, char* attribute_name);
5732 void cogl_vertex_buffer_disable(Handle handle, char* attribute_name);
5733 void cogl_vertex_buffer_draw(Handle handle, VerticesMode mode, int first, int count);
5734 void cogl_vertex_buffer_draw_elements(Handle handle, VerticesMode mode, Handle indices, int min_index, int max_index, int indices_offset, int count);
5735 void cogl_vertex_buffer_enable(Handle handle, char* attribute_name);
5736 uint cogl_vertex_buffer_get_n_vertices(Handle handle);
5737 Handle cogl_vertex_buffer_indices_get_for_quads(uint n_indices);
5738 IndicesType cogl_vertex_buffer_indices_get_type(Handle indices);
5739 Handle cogl_vertex_buffer_indices_new(IndicesType indices_type, void* indices_array, int indices_len);
5740 Handle cogl_vertex_buffer_new(uint n_vertices);
5741 Handle cogl_vertex_buffer_ref(Handle handle);
5742 void cogl_vertex_buffer_submit(Handle handle);
5743 void cogl_vertex_buffer_unref(Handle handle);
5744 void cogl_viewport(uint width, uint height);
5745 void cogl_xlib_renderer_add_filter_EXP(CoglRenderer* renderer, XlibFilterFunc func, void* data);
5746 /*CTYPE*/ Display* cogl_xlib_renderer_get_display_EXP(CoglRenderer* renderer);
5747 /*CTYPE*/ Display* cogl_xlib_renderer_get_foreign_display_EXP(CoglRenderer* renderer);
5748 FilterReturn cogl_xlib_renderer_handle_event_EXP(CoglRenderer* renderer, XEvent* event);
5749 void cogl_xlib_renderer_remove_filter_EXP(CoglRenderer* renderer, XlibFilterFunc func, void* data);
5750 void cogl_xlib_renderer_set_foreign_display_EXP(CoglRenderer* renderer, Display* display);