From 5c6664ca3142bda78c1e3d7b64e5cabc2d9ec643 Mon Sep 17 00:00:00 2001 From: Artur Skawina Date: Sun, 29 Jan 2012 17:04:47 +0100 Subject: [PATCH] Cogl bindings preview. Not really usable yet; not even compile tested, things like gtk.GL module missing. But shows how the API can look like. --- gtk2/cogl.d | 5751 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ gtk2/coglpango.d | 152 ++ 2 files changed, 5903 insertions(+) create mode 100644 gtk2/cogl.d create mode 100644 gtk2/coglpango.d diff --git a/gtk2/cogl.d b/gtk2/cogl.d new file mode 100644 index 0000000..e41f69d --- /dev/null +++ b/gtk2/cogl.d @@ -0,0 +1,5751 @@ +// *** DO NOT EDIT *** +// Automatically generated from "/usr/share/gir-1.0/Cogl-1.0.gir" + +module Cogl; +public import gtk2.gl; +alias gtk2.gl GL; +public import gtk2.glib2; +alias gtk2.glib2 GLib2; +public import gtk2.gobject2; +alias gtk2.gobject2 GObject2; + +// package: "cogl-1.0"; +// C header: "cogl/cogl.h"; + +// c:symbol-prefixes: ["cogl"] +// c:identifier-prefixes: ["Cogl"] + +// module Cogl; + + +// Integer representation of an angle such that 1024 corresponds to +// full circle (i.e., 2 * pi). +alias int Angle; + +// Type used for storing references to cogl objects, the CoglHandle is +// a fully opaque type without any public data members. +alias void* Handle; +enum int AFIRST_BIT = 64; +enum int A_BIT = 16; +struct Attribute { + + // Unintrospectable function: new() / cogl_attribute_new() + // Describes the layout for a list of vertex attribute values (For + // example, a list of texture coordinates or colors). + // + // The @name is used to access the attribute inside a GLSL vertex + // shader and there are some special names you should use if they are + // applicable: + // + // "cogl_position_in" (used for vertex positions) + // "cogl_color_in" (used for vertex colors) + // "cogl_tex_coord0_in", "cogl_tex_coord1", ... + // (used for vertex texture coordinates) + // "cogl_normal_in" (used for vertex normals) + // + // + // The attribute values corresponding to different vertices can either + // be tightly packed or interleaved with other attribute values. For + // example it's common to define a structure for a single vertex like: + // |[ + // typedef struct + // { + // float x, y, z; /* position attribute */ + // float s, t; /* texture coordinate attribute */ + // } MyVertex; + // ]| + // + // And then create an array of vertex data something like: + // |[ + // MyVertex vertices[100] = { .... } + // ]| + // + // In this case, to describe either the position or texture coordinate + // attribute you have to move
sizeof (MyVertex)
bytes to + // move from one vertex to the next. This is called the attribute + // @stride. If you weren't interleving attributes and you instead had + // a packed array of float x, y pairs then the attribute stride would + // be
(2 * sizeof (float))
. So the @stride is the number of + // bytes to move to find the attribute value of the next vertex. + // + // Normally a list of attributes starts at the beginning of an array. + // So for the
MyVertex
example above the @offset is the + // offset inside the
MyVertex
structure to the first + // component of the attribute. For the texture coordinate attribute + // the offset would be
offsetof (MyVertex, s)
or instead of + // using the offsetof macro you could use
sizeof (float) * 3
. + // If you've divided your @array into blocks of non-interleved + // attributes then you will need to calculate the @offset as the + // number of bytes in blocks preceding the attribute you're + // describing. + // + // An attribute often has more than one component. For example a color + // is often comprised of 4 red, green, blue and alpha @components, and a + // position may be comprised of 2 x and y @components. You should aim + // to keep the number of components to a minimum as more components + // means more data needs to be mapped into the GPU which can be a + // bottlneck when dealing with a large number of vertices. + // + // Finally you need to specify the component data type. Here you + // should aim to use the smallest type that meets your precision + // requirements. Again the larger the type then more data needs to be + // mapped into the GPU which can be a bottlneck when dealing with + // a large number of vertices. + // + // layout for a list of attribute values stored in @array. + // RETURNS: A newly allocated #CoglAttribute describing the + // : The #CoglAttributeBuffer containing the actual attribute data + // : The name of the attribute (used to reference it from GLSL) + // : The number of bytes to jump to get to the next attribute value for the next vertex. (Usually
sizeof (MyVertex)
) + // : The byte offset from the start of @attribute_buffer for the first attribute value. (Usually
offsetof (MyVertex, component0)
+ // : The number of components (e.g. 4 for an rgba color or 3 for and (x,y,z) position) + // : FIXME + static Attribute* new_(AttributeBuffer* attribute_buffer, char* name, size_t stride, size_t offset, int components, AttributeType type) { + return cogl_attribute_new(attribute_buffer, name, stride, offset, components, type); + } +} + +struct AttributeBuffer { + + // Unintrospectable function: new() / cogl_attribute_buffer_new() + // Declares a new #CoglAttributeBuffer of @size bytes to contain arrays of vertex + // attribute data. Once declared, data can be set using cogl_buffer_set_data() + // or by mapping it into the application's address space using cogl_buffer_map(). + // + // If @data isn't %NULL then @size bytes will be read from @data and + // immediately copied into the new buffer. + // : The number of bytes to allocate for vertex attribute data. + // : An optional pointer to vertex data to upload immediately. + static AttributeBuffer* new_(size_t bytes, void* data) { + return cogl_attribute_buffer_new(bytes, data); + } +} + +// Data types for the components of a vertex attribute. +enum AttributeType /* Version 1.0 */ { + BYTE = 5120, + UNSIGNED_BYTE = 5121, + SHORT = 5122, + UNSIGNED_SHORT = 5123, + FLOAT = 5126 +} +enum int BGR_BIT = 32; +struct Bitmap { + + // Parses an image file enough to extract the width and height + // of the bitmap. + // RETURNS: %TRUE if the image was successfully parsed + // : the file to check + // : return location for the bitmap width, or %NULL + // : return location for the bitmap height, or %NULL + static int get_size_from_file(char* filename, /*out*/ int* width, /*out*/ int* height) { + return cogl_bitmap_get_size_from_file(filename, width, height); + } + + // Unintrospectable function: new_from_file() / cogl_bitmap_new_from_file() + // Loads an image file from disk. This function can be safely called from + // within a thread. + // + // %NULL if loading the image failed. + // RETURNS: a #CoglBitmap to the new loaded image data, or + // : the file to load. + static Bitmap* new_from_file(char* filename, GLib2.Error** error=null) { + return cogl_bitmap_new_from_file(filename, error); + } +} + + +// Error codes that can be thrown when performing bitmap +// operations. Note that gdk_pixbuf_new_from_file() can also throw +// errors directly from the underlying image loading library. For +// example, if GdkPixbuf is used then errors #GdkPixbufErrors +// will be used directly. +enum BitmapError /* Version 1.4 */ { + FAILED = 0, + UNKNOWN_TYPE = 1, + CORRUPT_IMAGE = 2 +} +// Error enumeration for the blend strings parser +enum BlendStringError /* Version 1.0 */ { + PARSE_ERROR = 0, + ARGUMENT_PARSE_ERROR = 1, + INVALID_ERROR = 2, + GPU_UNSUPPORTED_ERROR = 3 +} +struct Buffer { + uint get_size_EXP() { + return cogl_buffer_get_size_EXP(&this); + } + BufferUpdateHint get_update_hint_EXP() { + return cogl_buffer_get_update_hint_EXP(&this); + } + // Unintrospectable method: map_EXP() / cogl_buffer_map_EXP() + void* map_EXP(BufferAccess access, BufferMapHint hints) { + return cogl_buffer_map_EXP(&this, access, hints); + } + int set_data_EXP(size_t offset, void* data, size_t size) { + return cogl_buffer_set_data_EXP(&this, offset, data, size); + } + void set_update_hint_EXP(BufferUpdateHint hint) { + cogl_buffer_set_update_hint_EXP(&this, hint); + } + void unmap_EXP() { + cogl_buffer_unmap_EXP(&this); + } +} + +// The access hints for cogl_buffer_set_update_hint() +enum BufferAccess /* Version 1.2 */ { + READ = 1, + WRITE = 2, + READ_WRITE = 3 +} +// Types of auxiliary buffers +enum BufferBit /* Version 1.0 */ { + COLOR = 1, + DEPTH = 2, + STENCIL = 4 +} + +// Hints to Cogl about how you are planning to modify the data once it +// is mapped. +enum BufferMapHint /* Version 1.4 */ { + DISCARD = 1 +} +// Target flags for FBOs. +enum BufferTarget /* Version 0.8 */ { + WINDOW_BUFFER = 2, + OFFSCREEN_BUFFER = 4 +} + +// The update hint on a buffer allows the user to give some detail on how often +// the buffer data is going to be updated. +enum BufferUpdateHint /* Version 1.2 */ { + STATIC = 0, + DYNAMIC = 1, + STREAM = 2 +} + +// A structure for holding a color definition. The contents of +// the CoglColor structure are private and should never by accessed +// directly. +struct Color /* Version 1.0 */ { + private ubyte red, green, blue, alpha; + private uint padding0, padding1, padding2; + + + // Unintrospectable method: copy() / cogl_color_copy() + // Creates a copy of @color + // + // to free the allocate resources + // RETURNS: a newly-allocated #CoglColor. Use cogl_color_free() + Color* copy() { + return cogl_color_copy(&this); + } + // Frees the resources allocated by cogl_color_new() and cogl_color_copy() + void free() { + cogl_color_free(&this); + } + + // Retrieves the alpha channel of @color as a fixed point + // value between 0 and %1.0. + // RETURNS: the alpha channel of the passed color + float get_alpha() { + return cogl_color_get_alpha(&this); + } + + // Retrieves the alpha channel of @color as a byte value + // between 0 and 255 + // RETURNS: the alpha channel of the passed color + ubyte get_alpha_byte() { + return cogl_color_get_alpha_byte(&this); + } + + // Retrieves the alpha channel of @color as a floating point + // value between 0.0 and 1.0 + // RETURNS: the alpha channel of the passed color + float get_alpha_float() { + return cogl_color_get_alpha_float(&this); + } + + // Retrieves the blue channel of @color as a fixed point + // value between 0 and %1.0. + // RETURNS: the blue channel of the passed color + float get_blue() { + return cogl_color_get_blue(&this); + } + + // Retrieves the blue channel of @color as a byte value + // between 0 and 255 + // RETURNS: the blue channel of the passed color + ubyte get_blue_byte() { + return cogl_color_get_blue_byte(&this); + } + + // Retrieves the blue channel of @color as a floating point + // value between 0.0 and 1.0 + // RETURNS: the blue channel of the passed color + float get_blue_float() { + return cogl_color_get_blue_float(&this); + } + + // Retrieves the green channel of @color as a fixed point + // value between 0 and %1.0. + // RETURNS: the green channel of the passed color + float get_green() { + return cogl_color_get_green(&this); + } + + // Retrieves the green channel of @color as a byte value + // between 0 and 255 + // RETURNS: the green channel of the passed color + ubyte get_green_byte() { + return cogl_color_get_green_byte(&this); + } + + // Retrieves the green channel of @color as a floating point + // value between 0.0 and 1.0 + // RETURNS: the green channel of the passed color + float get_green_float() { + return cogl_color_get_green_float(&this); + } + + // Retrieves the red channel of @color as a fixed point + // value between 0 and %1.0. + // RETURNS: the red channel of the passed color + float get_red() { + return cogl_color_get_red(&this); + } + + // Retrieves the red channel of @color as a byte value + // between 0 and 255 + // RETURNS: the red channel of the passed color + ubyte get_red_byte() { + return cogl_color_get_red_byte(&this); + } + + // Retrieves the red channel of @color as a floating point + // value between 0.0 and 1.0 + // RETURNS: the red channel of the passed color + float get_red_float() { + return cogl_color_get_red_float(&this); + } + + // Sets the values of the passed channels into a #CoglColor + // : value of the red channel, between 0 and %1.0 + // : value of the green channel, between 0 and %1.0 + // : value of the blue channel, between 0 and %1.0 + // : value of the alpha channel, between 0 and %1.0 + void init_from_4f(float red, float green, float blue, float alpha) { + cogl_color_init_from_4f(&this, red, green, blue, alpha); + } + + // Sets the values of the passed channels into a #CoglColor + // : a pointer to an array of 4 float color components + void init_from_4fv(float* color_array) { + cogl_color_init_from_4fv(&this, color_array); + } + + // Sets the values of the passed channels into a #CoglColor. + // : value of the red channel, between 0 and 255 + // : value of the green channel, between 0 and 255 + // : value of the blue channel, between 0 and 255 + // : value of the alpha channel, between 0 and 255 + void init_from_4ub(ubyte red, ubyte green, ubyte blue, ubyte alpha) { + cogl_color_init_from_4ub(&this, red, green, blue, alpha); + } + + // Converts a non-premultiplied color to a pre-multiplied color. For + // example, semi-transparent red is (1.0, 0, 0, 0.5) when non-premultiplied + // and (0.5, 0, 0, 0.5) when premultiplied. + void premultiply() { + cogl_color_premultiply(&this); + } + + // Sets the alpha channel of @color to @alpha. + // : a float value between 0.0f and 1.0f + void set_alpha(float alpha) { + cogl_color_set_alpha(&this, alpha); + } + + // Sets the alpha channel of @color to @alpha. + // : a byte value between 0 and 255 + void set_alpha_byte(ubyte alpha) { + cogl_color_set_alpha_byte(&this, alpha); + } + + // Sets the alpha channel of @color to @alpha. + // : a float value between 0.0f and 1.0f + void set_alpha_float(float alpha) { + cogl_color_set_alpha_float(&this, alpha); + } + + // Sets the blue channel of @color to @blue. + // : a float value between 0.0f and 1.0f + void set_blue(float blue) { + cogl_color_set_blue(&this, blue); + } + + // Sets the blue channel of @color to @blue. + // : a byte value between 0 and 255 + void set_blue_byte(ubyte blue) { + cogl_color_set_blue_byte(&this, blue); + } + + // Sets the blue channel of @color to @blue. + // : a float value between 0.0f and 1.0f + void set_blue_float(float blue) { + cogl_color_set_blue_float(&this, blue); + } + + // Sets the values of the passed channels into a #CoglColor + // : value of the red channel, between 0 and %1.0 + // : value of the green channel, between 0 and %1.0 + // : value of the blue channel, between 0 and %1.0 + // : value of the alpha channel, between 0 and %1.0 + void set_from_4f(float red, float green, float blue, float alpha) { + cogl_color_set_from_4f(&this, red, green, blue, alpha); + } + + // Sets the values of the passed channels into a #CoglColor. + // : value of the red channel, between 0 and 255 + // : value of the green channel, between 0 and 255 + // : value of the blue channel, between 0 and 255 + // : value of the alpha channel, between 0 and 255 + void set_from_4ub(ubyte red, ubyte green, ubyte blue, ubyte alpha) { + cogl_color_set_from_4ub(&this, red, green, blue, alpha); + } + + // Sets the green channel of @color to @green. + // : a float value between 0.0f and 1.0f + void set_green(float green) { + cogl_color_set_green(&this, green); + } + + // Sets the green channel of @color to @green. + // : a byte value between 0 and 255 + void set_green_byte(ubyte green) { + cogl_color_set_green_byte(&this, green); + } + + // Sets the green channel of @color to @green. + // : a float value between 0.0f and 1.0f + void set_green_float(float green) { + cogl_color_set_green_float(&this, green); + } + + // Sets the red channel of @color to @red. + // : a float value between 0.0f and 1.0f + void set_red(float red) { + cogl_color_set_red(&this, red); + } + + // Sets the red channel of @color to @red. + // : a byte value between 0 and 255 + void set_red_byte(ubyte red) { + cogl_color_set_red_byte(&this, red); + } + + // Sets the red channel of @color to @red. + // : a float value between 0.0f and 1.0f + void set_red_float(float red) { + cogl_color_set_red_float(&this, red); + } + + // Converts a pre-multiplied color to a non-premultiplied color. For + // example, semi-transparent red is (0.5, 0, 0, 0.5) when premultiplied + // and (1.0, 0, 0, 0.5) when non-premultiplied. + void unpremultiply() { + cogl_color_unpremultiply(&this); + } + + // Compares two #CoglColors and checks if they are the same. + // + // This function can be passed to g_hash_table_new() as the @key_equal_func + // parameter, when using #CoglColors as keys in a #GHashTable. + // RETURNS: %TRUE if the two colors are the same. + // : a #CoglColor + // : a #CoglColor + static int equal(const(void)* v1, const(void)* v2) { + return cogl_color_equal(v1, v2); + } + + // Unintrospectable function: new() / cogl_color_new() + // Creates a new (empty) color + // + // to free the allocated resources + // RETURNS: a newly-allocated #CoglColor. Use cogl_color_free() + static Color* new_() { + return cogl_color_new(); + } +} + + +// Defines a bit mask of color channels. This can be used with +// cogl_pipeline_set_color_mask() for example to define which color +// channels should be written to the current framebuffer when +// drawing something. +enum ColorMask { + NONE = 0, + RED = 1, + GREEN = 2, + BLUE = 4, + ALPHA = 8, + ALL = 15 +} + +// A callback function to use for cogl_debug_object_foreach_type(). +// : A pointer to a struct containing information about the type. +extern (C) alias void function (DebugObjectTypeInfo* info, void* user_data) DebugObjectForeachTypeCallback; + + +// This struct is used to pass information to the callback when +// cogl_debug_object_foreach_type() is called. +struct DebugObjectTypeInfo /* Version 1.8 */ { + char* name; + uint instance_count; +} + +struct DepthState { + uint magic; + int test_enabled; + DepthTestFunction test_function; + int write_enabled; + float range_near, range_far; + uint padding0, padding1, padding2, padding3, padding4, padding5, padding6, padding7, padding8, padding9; + + + // Gets the current range to which normalized depth values are mapped + // before writing to the depth buffer. This corresponds to the range + // set with cogl_pipeline_set_depth_range(). + // : A pointer to store the near component of the depth range + // : A pointer to store the far component of the depth range + void get_range(float* near_val, float* far_val) { + cogl_depth_state_get_range(&this, near_val, far_val); + } + + // Gets the current depth test enabled state as previously set by + // cogl_depth_state_set_test_enabled(). + // RETURNS: The pipeline's current depth test enabled state. + int get_test_enabled() { + return cogl_depth_state_get_test_enabled(&this); + } + + // Gets the current depth test enable state as previously set via + // cogl_pipeline_set_depth_test_enabled(). + // RETURNS: The current depth test enable state. + DepthTestFunction get_test_function() { + return cogl_depth_state_get_test_function(&this); + } + + // Gets the depth writing enable state as set by the corresponding + // cogl_pipeline_set_depth_writing_enabled. + // RETURNS: The current depth writing enable state + int get_write_enabled() { + return cogl_depth_state_get_write_enabled(&this); + } + + // Initializes the members of @state to their default values. + // + // You should never pass an un initialized #CoglDepthState structure + // to cogl_pipeline_set_depth_state(). + void init() { + cogl_depth_state_init(&this); + } + + // Sets the range to map depth values in normalized device coordinates + // to before writing out to a depth buffer. + // + // After your geometry has be transformed, clipped and had perspective + // division applied placing it in normalized device + // coordinates all depth values between the near and far z clipping + // planes are in the range -1 to 1. Before writing any depth value to + // the depth buffer though the value is mapped into the range [0, 1]. + // + // With this function you can change the range which depth values are + // mapped too although the range must still lye within the range [0, + // 1]. + // + // If your driver does not support this feature (for example you are + // using GLES 1 drivers) then if you don't use the default range + // values you will get an error reported when calling + // cogl_pipeline_set_depth_state (). You can check ahead of time for + // the %COGL_FEATURE_DEPTH_RANGE feature with + // cogl_features_available() to know if this function will succeed. + // + // By default normalized device coordinate depth values are mapped to + // the full range of depth buffer values, [0, 1]. + // + // NB: this won't directly affect the state of the GPU. You have + // to then set the state on a #CoglPipeline using + // cogl_pipeline_set_depth_state(). + // : The near component of the desired depth range which will be clamped to the range [0, 1] + // : The far component of the desired depth range which will be clamped to the range [0, 1] + void set_range(float near_val, float far_val) { + cogl_depth_state_set_range(&this, near_val, far_val); + } + + // Enables or disables depth testing according to the value of + // @enable. + // + // If depth testing is enable then the #CoglDepthTestFunction set + // using cogl_pipeline_set_depth_test_function() us used to evaluate + // the depth value of incoming fragments against the corresponding + // value stored in the current depth buffer, and if the test passes + // then the fragments depth value is used to update the depth buffer. + // (unless you have disabled depth writing via + // cogl_pipeline_set_depth_writing_enabled ()) + // + // By default depth testing is disabled. + // + // NB: this won't directly affect the state of the GPU. You have + // to then set the state on a #CoglPipeline using + // cogl_pipeline_set_depth_state() + // : The enable state you want + void set_test_enabled(int enable) { + cogl_depth_state_set_test_enabled(&this, enable); + } + + // Sets the #CoglDepthTestFunction used to compare the depth value of + // an incoming fragment against the corresponding value in the current + // depth buffer. + // + // By default the depth test function is %COGL_DEPTH_TEST_FUNCTION_LESS + // + // NB: this won't directly affect the state of the GPU. You have + // to then set the state on a #CoglPipeline using + // cogl_pipeline_set_depth_state() + // : The #CoglDepthTestFunction to set + void set_test_function(DepthTestFunction function_) { + cogl_depth_state_set_test_function(&this, function_); + } + + // Enables or disables depth buffer writing according to the value of + // @enable. Normally when depth testing is enabled and the comparison + // between a fragment's depth value and the corresponding depth buffer + // value passes then the fragment's depth is written to the depth + // buffer unless writing is disabled here. + // + // By default depth writing is enabled + // + // NB: this won't directly affect the state of the GPU. You have + // to then set the state on a #CoglPipeline using + // cogl_pipeline_set_depth_state() + // : The enable state you want + void set_write_enabled(int enable) { + cogl_depth_state_set_write_enabled(&this, enable); + } +} + + +// When using depth testing one of these functions is used to compare +// the depth of an incoming fragment against the depth value currently +// stored in the depth buffer. The function is changed using +// cogl_material_set_depth_test_function(). +// +// The test is only done when depth testing is explicitly enabled. (See +// cogl_material_set_depth_test_enabled()) +enum DepthTestFunction { + NEVER = 512, + LESS = 513, + EQUAL = 514, + LEQUAL = 515, + GREATER = 516, + NOTEQUAL = 517, + GEQUAL = 518, + ALWAYS = 519 +} + +// Error enumeration for Cogl +// +// The @COGL_ERROR_UNSUPPORTED error can be thrown for a variety of +// reasons. For example: +// +// +// You've tried to use a feature that is not +// advertised by cogl_get_features(). This could happen if you create +// a non-sliced texture with a non-power-of-two size when +// %COGL_FEATURE_TEXTURE_NPOT is not advertised. +// The GPU can not handle the configuration you have +// requested. An example might be if you try to use too many texture +// layers in a single #CoglPipeline +// The driver does not support some +// configuration. +// +// +// Currently this is only used by Cogl API marked as experimental so +// this enum should also be considered experimental. +enum Error /* Version 1.4 */ { + UNSUPPORTED = 0 +} + +// Represents an ordered rotation first of @heading degrees around an +// object's y axis, then @pitch degrees around an object's x axis and +// finally @roll degrees around an object's z axis. +// +// It's important to understand the that axis are associated +// with the object being rotated, so the axis also rotate in sequence +// with the rotations being applied. +// +// The members of a #CoglEuler can be initialized, for example, with +// cogl_euler_init() and cogl_euler_init_from_quaternion (). +// +// You may also want to look at cogl_quaternion_init_from_euler() if +// you want to do interpolation between 3d rotations. +struct Euler /* Version 2.0 */ { + float heading, pitch, roll; + private float padding0, padding1, padding2, padding3, padding4; + + + // Unintrospectable method: copy() / cogl_euler_copy() + // Allocates a new #CoglEuler and initilizes it with the component + // angles of @src. The newly allocated euler should be freed using + // cogl_euler_free(). + // RETURNS: A newly allocated #CoglEuler + Euler* copy() { + return cogl_euler_copy(&this); + } + + // Frees a #CoglEuler that was previously allocated using + // cogl_euler_copy(). + void free() { + cogl_euler_free(&this); + } + + // Initializes @euler to represent a rotation of @x_angle degrees + // around the x axis, then @y_angle degrees around the y_axis and + // @z_angle degrees around the z axis. + // : Angle to rotate around an object's y axis + // : Angle to rotate around an object's x axis + // : Angle to rotate around an object's z axis + void init(float heading, float pitch, float roll) { + cogl_euler_init(&this, heading, pitch, roll); + } + + // Extracts a euler rotation from the given @matrix and + // initializses @euler with the component x, y and z rotation angles. + // : A #CoglMatrix containing a rotation, but no scaling, mirroring or skewing. + void init_from_matrix(Matrix* matrix) { + cogl_euler_init_from_matrix(&this, matrix); + } + + // Initializes a @euler rotation with the equivalent rotation + // represented by the given @quaternion. + // : A #CoglEuler with the rotation to initialize with + void init_from_quaternion(Quaternion* quaternion) { + cogl_euler_init_from_quaternion(&this, quaternion); + } + + // Compares the two given euler angles @v1 and @v1 and it they are + // equal returns %TRUE else %FALSE. + // + // This function only checks that all three components rotations + // are numerically equal, it does not consider that some rotations + // can be represented with different component rotations + // RETURNS: %TRUE if @v1 and @v2 are equal else %FALSE. + // : The second euler angle to compare + static int equal(const(void)* v1, const(void)* v2) { + return cogl_euler_equal(v1, v2); + } +} + +enum int FIXED_0_5 = 32768; +enum int FIXED_1 = 1; +enum int FIXED_2_PI = 411775; +enum int FIXED_BITS = 32; +enum int FIXED_EPSILON = 1; +enum int FIXED_MAX = 2147483647; +enum int FIXED_MIN = cast(int)2147483648; +enum int FIXED_PI = 205887; +enum int FIXED_PI_2 = 102944; +enum int FIXED_PI_4 = 51472; +enum int FIXED_Q = -16; +// Flags for the supported features. +enum FeatureFlags /* Version 0.8 */ { + TEXTURE_RECTANGLE = 2, + TEXTURE_NPOT = 4, + TEXTURE_YUV = 8, + TEXTURE_READ_PIXELS = 16, + SHADERS_GLSL = 32, + OFFSCREEN = 64, + OFFSCREEN_MULTISAMPLE = 128, + OFFSCREEN_BLIT = 256, + FOUR_CLIP_PLANES = 512, + STENCIL_BUFFER = 1024, + VBOS = 2048, + PBOS = 4096, + UNSIGNED_INT_INDICES = 8192, + DEPTH_RANGE = 16384, + TEXTURE_NPOT_BASIC = 32768, + TEXTURE_NPOT_MIPMAP = 65536, + TEXTURE_NPOT_REPEAT = 131072, + POINT_SPRITE = 262144, + TEXTURE_3D = 524288, + SHADERS_ARBFP = 1048576, + MAP_BUFFER_FOR_READ = 2097152, + MAP_BUFFER_FOR_WRITE = 4194304, + ONSCREEN_MULTIPLE = 8388608 +} +enum FilterReturn { + CONTINUE = 0, + REMOVE = 1 +} +// Fixed point number using a (16.16) notation. +struct Fixed { + + // Unintrospectable function: log2() / cogl_fixed_log2() + // Calculates base 2 logarithm. + // + // This function is some 2.5 times faster on x86, and over 12 times faster on + // fpu-less arm, than using libc log(). + // RETURNS: base 2 logarithm. + // : value to calculate base 2 logarithm from + static Fixed log2(uint x) { + return cogl_fixed_log2(x); + } + + // Calculates @x to the @y power. + // RETURNS: the power of @x to the @y + // : base + // : #CoglFixed exponent + static uint pow(uint x, Fixed y) { + return cogl_fixed_pow(x, y); + } + + // Unintrospectable method: atan() / cogl_fixed_atan() + // Computes the arc tangent of @a. + // RETURNS: the arc tangent of the passed value, in fixed point notation + Fixed atan() { + return cogl_fixed_atan(&this); + } + + // Unintrospectable method: atan2() / cogl_fixed_atan2() + // Computes the arc tangent of @a / @b but uses the sign of both + // arguments to return the angle in right quadrant. + // + // notation + // RETURNS: the arc tangent of the passed fraction, in fixed point + // : the denominator as a #CoglFixed number + Fixed atan2(Fixed b) { + return cogl_fixed_atan2(&this, b); + } + + // Unintrospectable method: cos() / cogl_fixed_cos() + // Computes the cosine of @angle. + // RETURNS: the cosine of the passed angle, in fixed point notation + Fixed cos() { + return cogl_fixed_cos(&this); + } + // Unintrospectable method: div() / cogl_fixed_div() + Fixed div(Fixed b) { + return cogl_fixed_div(&this, b); + } + // Unintrospectable method: mul() / cogl_fixed_mul() + Fixed mul(Fixed b) { + return cogl_fixed_mul(&this, b); + } + // Unintrospectable method: mul_div() / cogl_fixed_mul_div() + Fixed mul_div(Fixed b, Fixed c) { + return cogl_fixed_mul_div(&this, b, c); + } + + // Calculates 2 to the @x power. + // + // This function is around 11 times faster on x86, and around 22 times faster + // on fpu-less arm than libc pow(2, x). + // RETURNS: the power of 2 to the passed value + uint pow2() { + return cogl_fixed_pow2(&this); + } + + // Unintrospectable method: sin() / cogl_fixed_sin() + // Computes the sine of @angle. + // RETURNS: the sine of the passed angle, in fixed point notation + Fixed sin() { + return cogl_fixed_sin(&this); + } + + // Unintrospectable method: sqrt() / cogl_fixed_sqrt() + // Computes the square root of @x. + // + // notation + // RETURNS: the square root of the passed value, in floating point + Fixed sqrt() { + return cogl_fixed_sqrt(&this); + } + + // Unintrospectable method: tan() / cogl_fixed_tan() + // Computes the tangent of @angle. + // RETURNS: the tangent of the passed angle, in fixed point notation + Fixed tan() { + return cogl_fixed_tan(&this); + } +} + + +// The fog mode determines the equation used to calculate the fogging blend +// factor while fogging is enabled. The simplest %COGL_FOG_MODE_LINEAR mode +// determines f as: +// +// |[ +// f = end - eye_distance / end - start +// ]| +// +// Where eye_distance is the distance of the current fragment in eye +// coordinates from the origin. +enum FogMode /* Version 1.0 */ { + LINEAR = 0, + EXPONENTIAL = 1, + EXPONENTIAL_SQUARED = 2 +} +struct Framebuffer { +} + + +// The type used by cogl for function pointers, note that this type +// is used as a generic catch-all cast for function pointers and the +// actual arguments and return type may be different. +extern (C) alias void function () FuncPtr; + +struct IndexBuffer { + + // Unintrospectable function: new() / cogl_index_buffer_new() + // Declares a new #CoglIndexBuffer of @size bytes to contain vertex + // indices. Once declared, data can be set using + // cogl_buffer_set_data() or by mapping it into the application's + // address space using cogl_buffer_map(). + // : The number of bytes to allocate for vertex attribute data. + static IndexBuffer* new_(size_t bytes) { + return cogl_index_buffer_new(bytes); + } +} + +struct Indices { + // Unintrospectable method: get_buffer() / cogl_indices_get_buffer() + IndexBuffer* get_buffer() { + return cogl_indices_get_buffer(&this); + } + size_t get_offset() { + return cogl_indices_get_offset(&this); + } + void set_offset(size_t offset) { + cogl_indices_set_offset(&this, offset); + } + // Unintrospectable function: new() / cogl_indices_new() + static Indices* new_(IndicesType type, void* indices_data, int n_indices) { + return cogl_indices_new(type, indices_data, n_indices); + } + // Unintrospectable function: new_for_buffer() / cogl_indices_new_for_buffer() + static Indices* new_for_buffer(IndicesType type, IndexBuffer* buffer, size_t offset) { + return cogl_indices_new_for_buffer(type, buffer, offset); + } +} + + +// You should aim to use the smallest data type that gives you enough +// range, since it reduces the size of your index array and can help +// reduce the demand on memory bandwidth. +// +// Note that %COGL_INDICES_TYPE_UNSIGNED_INT is only supported if the +// %COGL_FEATURE_UNSIGNED_INT_INDICES feature is available. This +// should always be available on OpenGL but on OpenGL ES it will only +// be available if the GL_OES_element_index_uint extension is +// advertized. +enum IndicesType { + BYTE = 0, + SHORT = 1, + INT = 2 +} +struct Material { + + // Unintrospectable method: copy() / cogl_material_copy() + // Creates a new material with the configuration copied from the + // source material. + // + // We would strongly advise developers to always aim to use + // cogl_material_copy() instead of cogl_material_new() whenever there will + // be any similarity between two materials. Copying a material helps Cogl + // keep track of a materials ancestry which we may use to help minimize GPU + // state changes. + // RETURNS: a pointer to the newly allocated #CoglMaterial + Material* copy() { + return cogl_material_copy(&this); + } + + // Retrieves the current ambient color for @material + // : The location to store the ambient color + void get_ambient(Color* ambient) { + cogl_material_get_ambient(&this, ambient); + } + + // Retrieves the current material color. + // : The location to store the color + void get_color(/*out*/ Color* color) { + cogl_material_get_color(&this, color); + } + + // Retrieves the current diffuse color for @material + // : The location to store the diffuse color + void get_diffuse(Color* diffuse) { + cogl_material_get_diffuse(&this, diffuse); + } + + // Retrieves the materials current emission color. + // : The location to store the emission color + void get_emission(Color* emission) { + cogl_material_get_emission(&this, emission); + } + + // Gets whether point sprite coordinate generation is enabled for this + // texture layer. + // + // point sprite coordinates. + // RETURNS: whether the texture coordinates will be replaced with + // : the layer number to check. + int get_layer_point_sprite_coords_enabled(int layer_index) { + return cogl_material_get_layer_point_sprite_coords_enabled(&this, layer_index); + } + + // Returns the wrap mode for the 'p' coordinate of texture lookups on this + // layer. + // + // this layer. + // RETURNS: the wrap mode for the 'p' coordinate of texture lookups on + // : the layer number to change. + MaterialWrapMode get_layer_wrap_mode_p(int layer_index) { + return cogl_material_get_layer_wrap_mode_p(&this, layer_index); + } + + // Returns the wrap mode for the 's' coordinate of texture lookups on this + // layer. + // + // this layer. + // RETURNS: the wrap mode for the 's' coordinate of texture lookups on + // : the layer number to change. + MaterialWrapMode get_layer_wrap_mode_s(int layer_index) { + return cogl_material_get_layer_wrap_mode_s(&this, layer_index); + } + + // Returns the wrap mode for the 't' coordinate of texture lookups on this + // layer. + // + // this layer. + // RETURNS: the wrap mode for the 't' coordinate of texture lookups on + // : the layer number to change. + MaterialWrapMode get_layer_wrap_mode_t(int layer_index) { + return cogl_material_get_layer_wrap_mode_t(&this, layer_index); + } + + // This function lets you access a material's internal list of layers + // for iteration. + // + // You should avoid using this API if possible since it was only + // made public by mistake and will be deprecated when we have + // suitable alternative. + // + // It's important to understand that the list returned may not + // remain valid if you modify the material or any of the layers in any + // way and so you would have to re-get the list in that + // situation. + // + // list of #CoglMaterialLayer's that can be passed to the + // cogl_material_layer_* functions. The list is owned by Cogl and it + // should not be modified or freed + // RETURNS: A + GLib2.List* get_layers() { + return cogl_material_get_layers(&this); + } + + // Retrieves the number of layers defined for the given @material + // RETURNS: the number of layers + int get_n_layers() { + return cogl_material_get_n_layers(&this); + } + + // Get the size of points drawn when %COGL_VERTICES_MODE_POINTS is + // used with the vertex buffer API. + // RETURNS: the point size of the material. + float get_point_size() { + return cogl_material_get_point_size(&this); + } + + // Retrieves the materials current emission color. + // RETURNS: The materials current shininess value + float get_shininess() { + return cogl_material_get_shininess(&this); + } + + // Retrieves the materials current specular color. + // : The location to store the specular color + void get_specular(Color* specular) { + cogl_material_get_specular(&this, specular); + } + + // Queries what user program has been associated with the given + // @material using cogl_material_set_user_program(). + // + // or %COGL_INVALID_HANDLE. + // RETURNS: The current user program + Handle get_user_program() { + return cogl_material_get_user_program(&this); + } + + // This function removes a layer from your material + // : Specifies the layer you want to remove + void remove_layer(int layer_index) { + cogl_material_remove_layer(&this, layer_index); + } + + // Before a primitive is blended with the framebuffer, it goes through an + // alpha test stage which lets you discard fragments based on the current + // alpha value. This function lets you change the function used to evaluate + // the alpha channel, and thus determine which fragments are discarded + // and which continue on to the blending stage. + // + // The default is %COGL_MATERIAL_ALPHA_FUNC_ALWAYS + // : A @CoglMaterialAlphaFunc constant + // : A reference point that the chosen alpha function uses to compare incoming fragments to. + void set_alpha_test_function(MaterialAlphaFunc alpha_func, float alpha_reference) { + cogl_material_set_alpha_test_function(&this, alpha_func, alpha_reference); + } + + // Sets the material's ambient color, in the standard OpenGL lighting + // model. The ambient color affects the overall color of the object. + // + // Since the diffuse color will be intense when the light hits the surface + // directly, the ambient will be most apparent where the light hits at a + // slant. + // + // The default value is (0.2, 0.2, 0.2, 1.0) + // : The components of the desired ambient color + void set_ambient(Color* ambient) { + cogl_material_set_ambient(&this, ambient); + } + + // Conveniently sets the diffuse and ambient color of @material at the same + // time. See cogl_material_set_ambient() and cogl_material_set_diffuse(). + // + // The default ambient color is (0.2, 0.2, 0.2, 1.0) + // + // The default diffuse color is (0.8, 0.8, 0.8, 1.0) + // : The components of the desired ambient and diffuse colors + void set_ambient_and_diffuse(Color* color) { + cogl_material_set_ambient_and_diffuse(&this, color); + } + + // If not already familiar; please refer here + // for an overview of what blend strings are, and their syntax. + // + // Blending occurs after the alpha test function, and combines fragments with + // the framebuffer. + // Currently the only blend function Cogl exposes is ADD(). So any valid + // blend statements will be of the form: + // + // |[ + // <channel-mask>=ADD(SRC_COLOR*(<factor>), DST_COLOR*(<factor>)) + // ]| + // + // The brackets around blend factors are currently not + // optional! + // + // This is the list of source-names usable as blend factors: + // + // SRC_COLOR: The color of the in comming fragment + // DST_COLOR: The color of the framebuffer + // CONSTANT: The constant set via cogl_material_set_blend_constant() + // + // + // The source names can be used according to the + // color-source and factor syntax, + // so for example "(1-SRC_COLOR[A])" would be a valid factor, as would + // "(CONSTANT[RGB])" + // + // These can also be used as factors: + // + // 0: (0, 0, 0, 0) + // 1: (1, 1, 1, 1) + // SRC_ALPHA_SATURATE_FACTOR: (f,f,f,1) where f = MIN(SRC_COLOR[A],1-DST_COLOR[A]) + // + // + // Remember; all color components are normalized to the range [0, 1] + // before computing the result of blending. + // + // + // Blend Strings/1 + // Blend a non-premultiplied source over a destination with + // premultiplied alpha: + // + // "RGB = ADD(SRC_COLOR*(SRC_COLOR[A]), DST_COLOR*(1-SRC_COLOR[A]))" + // "A = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))" + // + // + // + // + // Blend Strings/2 + // Blend a premultiplied source over a destination with + // premultiplied alpha + // + // "RGBA = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))" + // + // + // + // The default blend string is: + // |[ + // RGBA = ADD (SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A])) + // ]| + // + // That gives normal alpha-blending when the calculated color for the material + // is in premultiplied form. + // + // described blending is supported by the underlying driver/hardware. If + // there was an error, %FALSE is returned and @error is set accordingly (if + // present). + // RETURNS: %TRUE if the blend string was successfully parsed, and the + // : A Cogl blend string describing the desired blend function. + int set_blend(char* blend_string, GLib2.Error** error=null) { + return cogl_material_set_blend(&this, blend_string, error); + } + + // When blending is setup to reference a CONSTANT blend factor then + // blending will depend on the constant set with this function. + // : The constant color you want + void set_blend_constant(Color* constant_color) { + cogl_material_set_blend_constant(&this, constant_color); + } + + // Sets the basic color of the material, used when no lighting is enabled. + // + // Note that if you don't add any layers to the material then the color + // will be blended unmodified with the destination; the default blend + // expects premultiplied colors: for example, use (0.5, 0.0, 0.0, 0.5) for + // semi-transparent red. See cogl_color_premultiply(). + // + // The default value is (1.0, 1.0, 1.0, 1.0) + // : The components of the color + void set_color(Color* color) { + cogl_material_set_color(&this, color); + } + + // Sets the basic color of the material, used when no lighting is enabled. + // + // The default value is (1.0, 1.0, 1.0, 1.0) + // : The red component + // : The green component + // : The blue component + // : The alpha component + void set_color4f(float red, float green, float blue, float alpha) { + cogl_material_set_color4f(&this, red, green, blue, alpha); + } + + // Sets the basic color of the material, used when no lighting is enabled. + // + // The default value is (0xff, 0xff, 0xff, 0xff) + // : The red component + // : The green component + // : The blue component + // : The alpha component + void set_color4ub(ubyte red, ubyte green, ubyte blue, ubyte alpha) { + cogl_material_set_color4ub(&this, red, green, blue, alpha); + } + + // Sets the material's diffuse color, in the standard OpenGL lighting + // model. The diffuse color is most intense where the light hits the + // surface directly - perpendicular to the surface. + // + // The default value is (0.8, 0.8, 0.8, 1.0) + // : The components of the desired diffuse color + void set_diffuse(Color* diffuse) { + cogl_material_set_diffuse(&this, diffuse); + } + + // Sets the material's emissive color, in the standard OpenGL lighting + // model. It will look like the surface is a light source emitting this + // color. + // + // The default value is (0.0, 0.0, 0.0, 1.0) + // : The components of the desired emissive color + void set_emission(Color* emission) { + cogl_material_set_emission(&this, emission); + } + + // In addition to the standard OpenGL lighting model a Cogl material may have + // one or more layers comprised of textures that can be blended together in + // order, with a number of different texture combine modes. This function + // defines a new texture layer. + // + // The index values of multiple layers do not have to be consecutive; it is + // only their relative order that is important. + // + // In the future, we may define other types of material layers, such + // as purely GLSL based layers. + // : the index of the layer + // : a #CoglHandle for the layer object + void set_layer(int layer_index, Handle texture) { + cogl_material_set_layer(&this, layer_index, texture); + } + + // If not already familiar; you can refer + // here for an overview of what blend + // strings are and there syntax. + // + // These are all the functions available for texture combining: + // + // REPLACE(arg0) = arg0 + // MODULATE(arg0, arg1) = arg0 x arg1 + // ADD(arg0, arg1) = arg0 + arg1 + // ADD_SIGNED(arg0, arg1) = arg0 + arg1 - 0.5 + // INTERPOLATE(arg0, arg1, arg2) = arg0 x arg2 + arg1 x (1 - arg2) + // SUBTRACT(arg0, arg1) = arg0 - arg1 + // + // + // DOT3_RGB(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) + + // (arg0[G] - 0.5)) * (arg1[G] - 0.5) + + // (arg0[B] - 0.5)) * (arg1[B] - 0.5)) + // + // + // + // + // DOT3_RGBA(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) + + // (arg0[G] - 0.5)) * (arg1[G] - 0.5) + + // (arg0[B] - 0.5)) * (arg1[B] - 0.5)) + // + // + // + // + // Refer to the + // color-source syntax for + // describing the arguments. The valid source names for texture combining + // are: + // + // + // TEXTURE + // Use the color from the current texture layer + // + // + // TEXTURE_0, TEXTURE_1, etc + // Use the color from the specified texture layer + // + // + // CONSTANT + // Use the color from the constant given with + // cogl_material_set_layer_constant() + // + // + // PRIMARY + // Use the color of the material as set with + // cogl_material_set_color() + // + // + // PREVIOUS + // Either use the texture color from the previous layer, or + // if this is layer 0, use the color of the material as set with + // cogl_material_set_color() + // + // + // + // + // Layer Combine Examples + // This is effectively what the default blending is: + // + // RGBA = MODULATE (PREVIOUS, TEXTURE) + // + // This could be used to cross-fade between two images, using + // the alpha component of a constant as the interpolator. The constant + // color is given by calling cogl_material_set_layer_constant. + // + // RGBA = INTERPOLATE (PREVIOUS, TEXTURE, CONSTANT[A]) + // + // + // + // You can't give a multiplication factor for arguments as you can + // with blending. + // + // described texture combining is supported by the underlying driver and + // or hardware. On failure, %FALSE is returned and @error is set + // RETURNS: %TRUE if the blend string was successfully parsed, and the + // : Specifies the layer you want define a combine function for + // : A Cogl blend string describing the desired texture combine function. + int set_layer_combine(int layer_index, char* blend_string, GLib2.Error** error=null) { + return cogl_material_set_layer_combine(&this, layer_index, blend_string, error); + } + + // When you are using the 'CONSTANT' color source in a layer combine + // description then you can use this function to define its value. + // : Specifies the layer you want to specify a constant used for texture combining + // : The constant color you want + void set_layer_combine_constant(int layer_index, Color* constant) { + cogl_material_set_layer_combine_constant(&this, layer_index, constant); + } + + // Changes the decimation and interpolation filters used when a texture is + // drawn at other scales than 100%. + // : the layer number to change. + // : the filter used when scaling a texture down. + // : the filter used when magnifying a texture. + void set_layer_filters(int layer_index, MaterialFilter min_filter, MaterialFilter mag_filter) { + cogl_material_set_layer_filters(&this, layer_index, min_filter, mag_filter); + } + + // This function lets you set a matrix that can be used to e.g. translate + // and rotate a single layer of a material used to fill your geometry. + // : the index for the layer inside @material + // : the transformation matrix for the layer + void set_layer_matrix(int layer_index, Matrix* matrix) { + cogl_material_set_layer_matrix(&this, layer_index, matrix); + } + + // When rendering points, if @enable is %TRUE then the texture + // coordinates for this layer will be replaced with coordinates that + // vary from 0.0 to 1.0 across the primitive. The top left of the + // point will have the coordinates 0.0,0.0 and the bottom right will + // have 1.0,1.0. If @enable is %FALSE then the coordinates will be + // fixed for the entire point. + // + // This function will only work if %COGL_FEATURE_POINT_SPRITE is + // available. If the feature is not available then the function will + // return %FALSE and set @error. + // RETURNS: %TRUE if the function succeeds, %FALSE otherwise. + // : the layer number to change. + // : whether to enable point sprite coord generation. + int set_layer_point_sprite_coords_enabled(int layer_index, int enable, GLib2.Error** error=null) { + return cogl_material_set_layer_point_sprite_coords_enabled(&this, layer_index, enable, error); + } + + // Sets the wrap mode for all three coordinates of texture lookups on + // this layer. This is equivalent to calling + // cogl_material_set_layer_wrap_mode_s(), + // cogl_material_set_layer_wrap_mode_t() and + // cogl_material_set_layer_wrap_mode_p() separately. + // : the layer number to change. + // : the new wrap mode + void set_layer_wrap_mode(int layer_index, MaterialWrapMode mode) { + cogl_material_set_layer_wrap_mode(&this, layer_index, mode); + } + + // Sets the wrap mode for the 'p' coordinate of texture lookups on + // this layer. 'p' is the third coordinate. + // : the layer number to change. + // : the new wrap mode + void set_layer_wrap_mode_p(int layer_index, MaterialWrapMode mode) { + cogl_material_set_layer_wrap_mode_p(&this, layer_index, mode); + } + + // Sets the wrap mode for the 's' coordinate of texture lookups on this layer. + // : the layer number to change. + // : the new wrap mode + void set_layer_wrap_mode_s(int layer_index, MaterialWrapMode mode) { + cogl_material_set_layer_wrap_mode_s(&this, layer_index, mode); + } + + // Sets the wrap mode for the 't' coordinate of texture lookups on this layer. + // : the layer number to change. + // : the new wrap mode + void set_layer_wrap_mode_t(int layer_index, MaterialWrapMode mode) { + cogl_material_set_layer_wrap_mode_t(&this, layer_index, mode); + } + + // Changes the size of points drawn when %COGL_VERTICES_MODE_POINTS is + // used with the vertex buffer API. Note that typically the GPU will + // only support a limited minimum and maximum range of point sizes. If + // the chosen point size is outside that range then the nearest value + // within that range will be used instead. The size of a point is in + // screen space so it will be the same regardless of any + // transformations. The default point size is 1.0. + // : the new point size. + void set_point_size(float point_size) { + cogl_material_set_point_size(&this, point_size); + } + + // Sets the shininess of the material, in the standard OpenGL lighting + // model, which determines the size of the specular highlights. A + // higher @shininess will produce smaller highlights which makes the + // object appear more shiny. + // + // The default value is 0.0 + // : The desired shininess; must be >= 0.0 + void set_shininess(float shininess) { + cogl_material_set_shininess(&this, shininess); + } + + // Sets the material's specular color, in the standard OpenGL lighting + // model. The intensity of the specular color depends on the viewport + // position, and is brightest along the lines of reflection. + // + // The default value is (0.0, 0.0, 0.0, 1.0) + // : The components of the desired specular color + void set_specular(Color* specular) { + cogl_material_set_specular(&this, specular); + } + + // Associates a linked CoglProgram with the given material so that the + // program can take full control of vertex and/or fragment processing. + // + // This is an example of how it can be used to associate an ARBfp + // program with a #CoglMaterial: + // |[ + // CoglHandle shader; + // CoglHandle program; + // CoglMaterial *material; + // + // shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); + // cogl_shader_source (shader, + // "!!ARBfp1.0\n" + // "MOV result.color,fragment.color;\n" + // "END\n"); + // cogl_shader_compile (shader); + // + // program = cogl_create_program (); + // cogl_program_attach_shader (program, shader); + // cogl_program_link (program); + // + // material = cogl_material_new (); + // cogl_material_set_user_program (material, program); + // + // cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff); + // cogl_rectangle (0, 0, 100, 100); + // ]| + // + // It is possibly worth keeping in mind that this API is not part of + // the long term design for how we want to expose shaders to Cogl + // developers (We are planning on deprecating the cogl_program and + // cogl_shader APIs in favour of a "snippet" framework) but in the + // meantime we hope this will handle most practical GLSL and ARBfp + // requirements. + // + // Also remember you need to check for either the + // %COGL_FEATURE_SHADERS_GLSL or %COGL_FEATURE_SHADERS_ARBFP before + // using the cogl_program or cogl_shader API. + // : A #CoglHandle to a linked CoglProgram + void set_user_program(Handle program) { + cogl_material_set_user_program(&this, program); + } + + // Unintrospectable function: new() / cogl_material_new() + // Allocates and initializes a blank white material + // RETURNS: a pointer to a new #CoglMaterial + static Material* new_() { + return cogl_material_new(); + } + + // Unintrospectable function: ref() / cogl_material_ref() + // Increment the reference count for a #CoglMaterial. + // RETURNS: the @material. + // : a #CoglMaterial object. + static Handle ref_(Handle material) { + return cogl_material_ref(material); + } + + // Decrement the reference count for a #CoglMaterial. + // : a #CoglMaterial object. + static void unref(Handle material) { + cogl_material_unref(material); + } +} + + +// Alpha testing happens before blending primitives with the framebuffer and +// gives an opportunity to discard fragments based on a comparison with the +// incoming alpha value and a reference alpha value. The #CoglMaterialAlphaFunc +// determines how the comparison is done. +enum MaterialAlphaFunc { + NEVER = 512, + LESS = 513, + EQUAL = 514, + LEQUAL = 515, + GREATER = 516, + NOTEQUAL = 517, + GEQUAL = 518, + ALWAYS = 519 +} + +// Texture filtering is used whenever the current pixel maps either to more +// than one texture element (texel) or less than one. These filter enums +// correspond to different strategies used to come up with a pixel color, by +// possibly referring to multiple neighbouring texels and taking a weighted +// average or simply using the nearest texel. +enum MaterialFilter { + NEAREST = 9728, + LINEAR = 9729, + NEAREST_MIPMAP_NEAREST = 9984, + LINEAR_MIPMAP_NEAREST = 9985, + NEAREST_MIPMAP_LINEAR = 9986, + LINEAR_MIPMAP_LINEAR = 9987 +} +struct MaterialLayer { + + // Queries the currently set downscaling filter for a material later + // RETURNS: the current downscaling filter + MaterialFilter get_mag_filter() { + return cogl_material_layer_get_mag_filter(&this); + } + + // Queries the currently set downscaling filter for a material layer + // RETURNS: the current downscaling filter + MaterialFilter get_min_filter() { + return cogl_material_layer_get_min_filter(&this); + } + + // Extracts a texture handle for a specific layer. + // + // In the future Cogl may support purely GLSL based layers; for those + // layers this function which will likely return %COGL_INVALID_HANDLE if you + // try to get the texture handle from them. Considering this scenario, you + // should call cogl_material_layer_get_type() first in order check it is of + // type %COGL_MATERIAL_LAYER_TYPE_TEXTURE before calling this function. + // RETURNS: a #CoglHandle for the texture inside the layer + Handle get_texture() { + return cogl_material_layer_get_texture(&this); + } + + // Gets the wrap mode for the 'p' coordinate of texture lookups on + // this layer. 'p' is the third coordinate. + // RETURNS: the wrap mode value for the p coordinate. + MaterialWrapMode get_wrap_mode_p() { + return cogl_material_layer_get_wrap_mode_p(&this); + } + + // Gets the wrap mode for the 's' coordinate of texture lookups on this layer. + // RETURNS: the wrap mode value for the s coordinate. + MaterialWrapMode get_wrap_mode_s() { + return cogl_material_layer_get_wrap_mode_s(&this); + } + + // Gets the wrap mode for the 't' coordinate of texture lookups on this layer. + // RETURNS: the wrap mode value for the t coordinate. + MaterialWrapMode get_wrap_mode_t() { + return cogl_material_layer_get_wrap_mode_t(&this); + } +} + + +// Available types of layers for a #CoglMaterial. This enumeration +// might be expanded in later versions. +enum MaterialLayerType /* Version 1.0 */ { + TEXTURE = 0 +} + +// The wrap mode specifies what happens when texture coordinates +// outside the range 0→1 are used. Note that if the filter mode is +// anything but %COGL_MATERIAL_FILTER_NEAREST then texels outside the +// range 0→1 might be used even when the coordinate is exactly 0 or 1 +// because OpenGL will try to sample neighbouring pixels. For example +// if you are trying to render the full texture then you may get +// artifacts around the edges when the pixels from the other side are +// merged in if the wrap mode is set to repeat. +enum MaterialWrapMode /* Version 1.4 */ { + REPEAT = 10497, + CLAMP_TO_EDGE = 33071, + AUTOMATIC = 519 +} + +// A CoglMatrix holds a 4x4 transform matrix. This is a single precision, +// column-major matrix which means it is compatible with what OpenGL expects. +// +// A CoglMatrix can represent transforms such as, rotations, scaling, +// translation, sheering, and linear projections. You can combine these +// transforms by multiplying multiple matrices in the order you want them +// applied. +// +// The transformation of a vertex (x, y, z, w) by a CoglMatrix is given by: +// +// |[ +// x_new = xx * x + xy * y + xz * z + xw * w +// y_new = yx * x + yy * y + yz * z + yw * w +// z_new = zx * x + zy * y + zz * z + zw * w +// w_new = wx * x + wy * y + wz * z + ww * w +// ]| +// +// Where w is normally 1 +// +// You must consider the members of the CoglMatrix structure read only, +// and all matrix modifications must be done via the cogl_matrix API. This +// allows Cogl to annotate the matrices internally. Violation of this will give +// undefined results. If you need to initialize a matrix with a constant other +// than the identity matrix you can use cogl_matrix_init_from_array(). +struct Matrix { + float xx, yx, zx, wx, xy, yy, zy, wy, xz, yz, zz, wz, xw, yw, zw, ww; + private float[16] inv; + private uint type, flags, _padding3; + + + // Unintrospectable method: copy() / cogl_matrix_copy() + // Allocates a new #CoglMatrix on the heap and initializes it with + // the same values as @matrix. + // + // cogl_matrix_free() + // RETURNS: A newly allocated #CoglMatrix which should be freed using + Matrix* copy() { + return cogl_matrix_copy(&this); + } + + // Frees a #CoglMatrix that was previously allocated via a call to + // cogl_matrix_copy(). + void free() { + cogl_matrix_free(&this); + } + + // Multiplies @matrix by the given frustum perspective matrix. + // : coord of left vertical clipping plane + // : coord of right vertical clipping plane + // : coord of bottom horizontal clipping plane + // : coord of top horizontal clipping plane + // : positive distance to near depth clipping plane + // : positive distance to far depth clipping plane + void frustum(float left, float right, float bottom, float top, float z_near, float z_far) { + cogl_matrix_frustum(&this, left, right, bottom, top, z_near, z_far); + } + + // Casts @matrix to a float array which can be directly passed to OpenGL. + // RETURNS: a pointer to the float array + float* get_array() { + return cogl_matrix_get_array(&this); + } + + // Gets the inverse transform of a given matrix and uses it to initialize + // a new #CoglMatrix. + // + // Although the first parameter is annotated as const to indicate + // that the transform it represents isn't modified this function may + // technically save a copy of the inverse transform within the given + // #CoglMatrix so that subsequent requests for the inverse transform may + // avoid costly inversion calculations. + // + // for degenerate transformations that can't be inverted (in this case the + // @inverse matrix will simply be initialized with the identity matrix) + // RETURNS: %TRUE if the inverse was successfully calculated or %FALSE + // : The destination for a 4x4 inverse transformation matrix + int get_inverse(/*out*/ Matrix* inverse) { + return cogl_matrix_get_inverse(&this, inverse); + } + + // Initializes @matrix with the contents of @array + // : A linear array of 16 floats (column-major order) + void init_from_array(float* array) { + cogl_matrix_init_from_array(&this, array); + } + + // Resets matrix to the identity matrix: + // + // |[ + // .xx=1; .xy=0; .xz=0; .xw=0; + // .yx=0; .yy=1; .yz=0; .yw=0; + // .zx=0; .zy=0; .zz=1; .zw=0; + // .wx=0; .wy=0; .wz=0; .ww=1; + // ]| + void init_identity() { + cogl_matrix_init_identity(&this); + } + + // Determines if the given matrix is an identity matrix. + // RETURNS: %TRUE if @matrix is an identity matrix else %FALSE + int is_identity() { + return cogl_matrix_is_identity(&this); + } + 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) { + 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); + } + + // Multiplies the two supplied matrices together and stores + // the resulting matrix inside @result. + // + // It is possible to multiply the @a matrix in-place, so + // @result can be equal to @a but can't be equal to @b. + // : A 4x4 transformation matrix + // : A 4x4 transformation matrix + void multiply(Matrix* a, Matrix* b) { + cogl_matrix_multiply(&this, a, b); + } + + // Multiplies @matrix by a parallel projection matrix. + // : The coordinate for the left clipping plane + // : The coordinate for the right clipping plane + // : The coordinate for the bottom clipping plane + // : The coordinate for the top clipping plane + // : The coordinate for the near clipping plane (may be negative if the plane is behind the viewer) + // : The coordinate for the far clipping plane (may be negative if the plane is behind the viewer) + void ortho(float left, float right, float bottom, float top, float z_near, float z_far) { + cogl_matrix_ortho(&this, left, right, bottom, top, z_near, z_far); + } + + // Multiplies @matrix by the described perspective matrix + // + // You should be careful not to have to great a @z_far / @z_near ratio + // since that will reduce the effectiveness of depth testing since there wont + // be enough precision to identify the depth of objects near to each + // other. + // : A field of view angle for the Y axis + // : The ratio of width to height determining the field of view angle for the x axis. + // : The distance to the near clip plane. Never pass 0 and always pass a positive number. + // : The distance to the far clip plane. (Should always be positive) + void perspective(float fov_y, float aspect, float z_near, float z_far) { + cogl_matrix_perspective(&this, fov_y, aspect, z_near, z_far); + } + + // Multiplies @matrix with a rotation matrix that applies a rotation + // of @angle degrees around the specified 3D vector. + // : The angle you want to rotate in degrees + // : X component of your rotation vector + // : Y component of your rotation vector + // : Z component of your rotation vector + void rotate(float angle, float x, float y, float z) { + cogl_matrix_rotate(&this, angle, x, y, z); + } + + // Multiplies @matrix with a transform matrix that scales along the X, + // Y and Z axis. + // : The X scale factor + // : The Y scale factor + // : The Z scale factor + void scale(float sx, float sy, float sz) { + cogl_matrix_scale(&this, sx, sy, sz); + } + + // Transforms a point whos position is given and returned as four float + // components. + // : The X component of your points position + // : The Y component of your points position + // : The Z component of your points position + // : The W component of your points position + void transform_point(/*inout*/ float* x, /*inout*/ float* y, /*inout*/ float* z, /*inout*/ float* w) { + cogl_matrix_transform_point(&this, x, y, z, w); + } + + // Multiplies @matrix with a transform matrix that translates along + // the X, Y and Z axis. + // : The X translation you want to apply + // : The Y translation you want to apply + // : The Z translation you want to apply + void translate(float x, float y, float z) { + cogl_matrix_translate(&this, x, y, z); + } + + // Compares two matrices to see if they represent the same + // transformation. Although internally the matrices may have different + // annotations associated with them and may potentially have a cached + // inverse matrix these are not considered in the comparison. + // : A 4x4 transformation matrix + // : A 4x4 transformation matrix + static int equal(const(void)* v1, const(void)* v2) { + return cogl_matrix_equal(v1, v2); + } +} + +struct Object { + + // Unintrospectable method: get_user_data() / cogl_object_get_user_data() + // Finds the user data previously associated with @object using + // the given @key. If no user data has been associated with @object + // for the given @key this function returns NULL. + // + // with @object using the given @key; or %NULL if no associated + // data is found. + // RETURNS: The user data previously associated + // : The address of a #CoglUserDataKey which provides a unique value with which to index the private data. + void* get_user_data(UserDataKey* key) { + return cogl_object_get_user_data(&this, key); + } + + // Unintrospectable method: set_user_data() / cogl_object_set_user_data() + // Associates some private @user_data with a given #CoglObject. To + // later remove the association call cogl_object_set_user_data() with + // the same @key but NULL for the @user_data. + // : The address of a #CoglUserDataKey which provides a unique value with which to index the private data. + // : The data to associate with the given object, or %NULL to remove a previous association. + // : A #CoglUserDataDestroyCallback to call if the object is destroyed or if the association is removed by later setting %NULL data for the same key. + void set_user_data(UserDataKey* key, void* user_data, UserDataDestroyCallback destroy) { + cogl_object_set_user_data(&this, key, user_data, destroy); + } + + // Unintrospectable function: ref() / cogl_object_ref() + // Increases the reference count of @handle by 1 + // RETURNS: the @object, with its reference count increased + // : a #CoglObject + static void* ref_(void* object) { + return cogl_object_ref(object); + } + + // Unintrospectable function: unref() / cogl_object_unref() + // Drecreases the reference count of @object by 1; if the reference + // count reaches 0, the resources allocated by @object will be freed + // : a #CoglObject + static void unref(void* object) { + cogl_object_unref(object); + } +} + +enum int PIXEL_FORMAT_24 = 2; +enum int PIXEL_FORMAT_32 = 3; +enum int PREMULT_BIT = 128; +struct Path { + + // Unintrospectable method: copy() / cogl_path_copy() + // Returns a new copy of the path in @path. The new path has a + // reference count of 1 so you should unref it with + // cogl_object_unref() if you no longer need it. + // + // Internally the path will share the data until one of the paths is + // modified so copying paths should be relatively cheap. + // RETURNS: a copy of the path in @path. + Path* /*new*/ copy() { + return cogl_path_copy(&this); + } + + // Adds an elliptical arc segment to the current path. A straight line + // segment will link the current pen location with the first vertex + // of the arc. If you perform a move_to to the arcs start just before + // drawing it you create a free standing arc. + // + // The angles are measured in degrees where 0° is in the direction of + // the positive X axis and 90° is in the direction of the positive Y + // axis. The angle of the arc begins at @angle_1 and heads towards + // @angle_2 (so if @angle_2 is less than @angle_1 it will decrease, + // otherwise it will increase). + // : X coordinate of the elliptical arc center + // : Y coordinate of the elliptical arc center + // : X radius of the elliptical arc + // : Y radius of the elliptical arc + // : Angle in degrees at which the arc begin + // : Angle in degrees at which the arc ends + static void arc(float center_x, float center_y, float radius_x, float radius_y, float angle_1, float angle_2) { + cogl_path_arc(center_x, center_y, radius_x, radius_y, angle_1, angle_2); + } + + // Closes the path being constructed by adding a straight line segment + // to it that ends at the first vertex of the path. + static void close() { + cogl_path_close(); + } + + // Adds a cubic bezier curve segment to the current path with the given + // second, third and fourth control points and using current pen location + // as the first control point. + // : X coordinate of the second bezier control point + // : Y coordinate of the second bezier control point + // : X coordinate of the third bezier control point + // : Y coordinate of the third bezier control point + // : X coordinate of the fourth bezier control point + // : Y coordinate of the fourth bezier control point + static void curve_to(float x_1, float y_1, float x_2, float y_2, float x_3, float y_3) { + cogl_path_curve_to(x_1, y_1, x_2, y_2, x_3, y_3); + } + + // Constructs an ellipse shape. If there is an existing path this will + // start a new disjoint sub-path. + // : X coordinate of the ellipse center + // : Y coordinate of the ellipse center + // : X radius of the ellipse + // : Y radius of the ellipse + static void ellipse(float center_x, float center_y, float radius_x, float radius_y) { + cogl_path_ellipse(center_x, center_y, radius_x, radius_y); + } + + // Fills the interior of the constructed shape using the current + // drawing color. The current path is then cleared. To use the path + // again, call cogl_path_fill_preserve() instead. + // + // The interior of the shape is determined using the fill rule of the + // path. See %CoglPathFillRule for details. + static void fill() { + cogl_path_fill(); + } + + // Fills the interior of the constructed shape using the current + // drawing color and preserves the path to be used again. See + // cogl_path_fill() for a description what is considered the interior + // of the shape. + static void fill_preserve() { + cogl_path_fill_preserve(); + } + + // Retrieves the fill rule set using cogl_path_set_fill_rule(). + // RETURNS: the fill rule that is used for the current path. + static PathFillRule get_fill_rule() { + return cogl_path_get_fill_rule(); + } + + // Constructs a straight line shape starting and ending at the given + // coordinates. If there is an existing path this will start a new + // disjoint sub-path. + // : X coordinate of the start line vertex + // : Y coordinate of the start line vertex + // : X coordinate of the end line vertex + // : Y coordinate of the end line vertex + static void line(float x_1, float y_1, float x_2, float y_2) { + cogl_path_line(x_1, y_1, x_2, y_2); + } + + // Adds a straight line segment to the current path that ends at the + // given coordinates. + // : X coordinate of the end line vertex + // : Y coordinate of the end line vertex + static void line_to(float x, float y) { + cogl_path_line_to(x, y); + } + + // Moves the pen to the given location. If there is an existing path + // this will start a new disjoint subpath. + // : X coordinate of the pen location to move to. + // : Y coordinate of the pen location to move to. + static void move_to(float x, float y) { + cogl_path_move_to(x, y); + } + + // Clears the current path and starts a new one. Creating a new path + // also resets the fill rule to the default which is + // %COGL_PATH_FILL_RULE_EVEN_ODD. + static void new_() { + cogl_path_new(); + } + + // Constructs a polygonal shape of the given number of vertices. If + // there is an existing path this will start a new disjoint sub-path. + // + // The coords array must contain 2 * num_points values. The first value + // represents the X coordinate of the first vertex, the second value + // represents the Y coordinate of the first vertex, continuing in the same + // fashion for the rest of the vertices. + // : A pointer to the first element of an array of fixed-point values that specify the vertex coordinates. + // : The total number of vertices. + static void polygon(float* coords, int num_points) { + cogl_path_polygon(coords, num_points); + } + + // Constructs a series of straight line segments, starting from the + // first given vertex coordinate. If there is an existing path this + // will start a new disjoint sub-path. Each subsequent segment starts + // where the previous one ended and ends at the next given vertex + // coordinate. + // + // The coords array must contain 2 * num_points values. The first value + // represents the X coordinate of the first vertex, the second value + // represents the Y coordinate of the first vertex, continuing in the same + // fashion for the rest of the vertices. (num_points - 1) segments will + // be constructed. + // : A pointer to the first element of an array of fixed-point values that specify the vertex coordinates. + // : The total number of vertices. + static void polyline(float* coords, int num_points) { + cogl_path_polyline(coords, num_points); + } + + // Constructs a rectangular shape at the given coordinates. If there + // is an existing path this will start a new disjoint sub-path. + // : X coordinate of the top-left corner. + // : Y coordinate of the top-left corner. + // : X coordinate of the bottom-right corner. + // : Y coordinate of the bottom-right corner. + static void rectangle(float x_1, float y_1, float x_2, float y_2) { + cogl_path_rectangle(x_1, y_1, x_2, y_2); + } + + // Adds a cubic bezier curve segment to the current path with the given + // second, third and fourth control points and using current pen location + // as the first control point. The given coordinates are relative to the + // current pen location. + // : X coordinate of the second bezier control point + // : Y coordinate of the second bezier control point + // : X coordinate of the third bezier control point + // : Y coordinate of the third bezier control point + // : X coordinate of the fourth bezier control point + // : Y coordinate of the fourth bezier control point + static void rel_curve_to(float x_1, float y_1, float x_2, float y_2, float x_3, float y_3) { + cogl_path_rel_curve_to(x_1, y_1, x_2, y_2, x_3, y_3); + } + + // Adds a straight line segment to the current path that ends at the + // given coordinates relative to the current pen location. + // : X offset from the current pen location of the end line vertex + // : Y offset from the current pen location of the end line vertex + static void rel_line_to(float x, float y) { + cogl_path_rel_line_to(x, y); + } + + // Moves the pen to the given offset relative to the current pen + // location. If there is an existing path this will start a new + // disjoint subpath. + // : X offset from the current pen location to move the pen to. + // : Y offset from the current pen location to move the pen to. + static void rel_move_to(float x, float y) { + cogl_path_rel_move_to(x, y); + } + + // Constructs a rectangular shape with rounded corners. If there is an + // existing path this will start a new disjoint sub-path. + // : X coordinate of the top-left corner. + // : Y coordinate of the top-left corner. + // : X coordinate of the bottom-right corner. + // : Y coordinate of the bottom-right corner. + // : Radius of the corner arcs. + // : Angle increment resolution for subdivision of the corner arcs. + static void round_rectangle(float x_1, float y_1, float x_2, float y_2, float radius, float arc_step) { + cogl_path_round_rectangle(x_1, y_1, x_2, y_2, radius, arc_step); + } + + // Sets the fill rule of the current path to @fill_rule. This will + // affect how the path is filled when cogl_path_fill() is later + // called. Note that the fill rule state is attached to the path so + // calling cogl_get_path() will preserve the fill rule and calling + // cogl_path_new() will reset the fill rule back to the default. + // : The new fill rule. + static void set_fill_rule(PathFillRule fill_rule) { + cogl_path_set_fill_rule(fill_rule); + } + + // Strokes the constructed shape using the current drawing color and a + // width of 1 pixel (regardless of the current transformation + // matrix). To current path is then cleared. To use the path again, + // call cogl_path_stroke_preserve() instead. + static void stroke() { + cogl_path_stroke(); + } + + // Strokes the constructed shape using the current drawing color and + // preserves the path to be used again. + static void stroke_preserve() { + cogl_path_stroke_preserve(); + } +} + + +// #CoglPathFillRule is used to determine how a path is filled. There +// are two options - 'non-zero' and 'even-odd'. To work out whether any +// point will be filled imagine drawing an infinetely long line in any +// direction from that point. The number of times and the direction +// that the edges of the path crosses this line determines whether the +// line is filled as described below. Any open sub paths are treated +// as if there was an extra line joining the first point and the last +// point. +// +// The default fill rule is %COGL_PATH_FILL_RULE_EVEN_ODD. The fill +// rule is attached to the current path so preserving a path with +// cogl_get_path() also preserves the fill rule. Calling +// cogl_path_new() resets the current fill rule to the default. +// +//
+// Example of filling various paths using the non-zero rule +// +//
+// +//
+// Example of filling various paths using the even-odd rule +// +//
+enum PathFillRule /* Version 1.4 */ { + NON_ZERO = 0, + EVEN_ODD = 1 +} +struct PixelBuffer { + // Unintrospectable function: new_with_size_EXP() / cogl_pixel_buffer_new_with_size_EXP() + static PixelBuffer* new_with_size_EXP(uint width, uint height, PixelFormat format, uint* stride) { + return cogl_pixel_buffer_new_with_size_EXP(width, height, format, stride); + } +} + + +// Pixel formats used by COGL. For the formats with a byte per +// component, the order of the components specify the order in +// increasing memory addresses. So for example +// %COGL_PIXEL_FORMAT_RGB_888 would have the red component in the +// lowest address, green in the next address and blue after that +// regardless of the endinanness of the system. +// +// For the 16-bit formats the component order specifies the order +// within a 16-bit number from most significant bit to least +// significant. So for %COGL_PIXEL_FORMAT_RGB_565, the red component +// would be in bits 11-15, the green component would be in 6-11 and +// the blue component would be in 1-5. Therefore the order in memory +// depends on the endianness of the system. +// +// When uploading a texture %COGL_PIXEL_FORMAT_ANY can be used as the +// internal format. Cogl will try to pick the best format to use +// internally and convert the texture data if necessary. +enum PixelFormat /* Version 0.8 */ { + ANY = 0, + A_8 = 17, + RGB_565 = 4, + RGBA_4444 = 21, + RGBA_5551 = 22, + YUV = 7, + G_8 = 8, + RGB_888 = 2, + BGR_888 = 34, + RGBA_8888 = 19, + BGRA_8888 = 51, + ARGB_8888 = 83, + ABGR_8888 = 115, + RGBA_8888_PRE = 147, + BGRA_8888_PRE = 179, + ARGB_8888_PRE = 211, + ABGR_8888_PRE = 243, + RGBA_4444_PRE = 149, + RGBA_5551_PRE = 150 +} +struct Primitive { + // Draw the given @primitive with the current source material. + void draw() { + cogl_primitive_draw(&this); + } + int get_first_vertex() { + return cogl_primitive_get_first_vertex(&this); + } + VerticesMode get_mode() { + return cogl_primitive_get_mode(&this); + } + int get_n_vertices() { + return cogl_primitive_get_n_vertices(&this); + } + + // Replaces all the attributes of the given #CoglPrimitive object. + // : A %NULL terminated array of #CoglAttribute pointers + void set_attributes(Attribute** attributes, int n_attributes) { + cogl_primitive_set_attributes(&this, attributes, n_attributes); + } + void set_first_vertex(int first_vertex) { + cogl_primitive_set_first_vertex(&this, first_vertex); + } + void set_indices(Indices* indices) { + cogl_primitive_set_indices(&this, indices); + } + void set_mode(VerticesMode mode) { + cogl_primitive_set_mode(&this, mode); + } + void set_n_vertices(int n_vertices) { + cogl_primitive_set_n_vertices(&this, n_vertices); + } + + // Unintrospectable function: new() / cogl_primitive_new() + // Combines a set of #CoglAttributes with a specific draw @mode + // and defines a vertex count so a #CoglPrimitive object can be retained and + // drawn later with no addition information required. + // RETURNS: A newly allocated #CoglPrimitive object + // : A #CoglVerticesMode defining how to draw the vertices + // : The number of vertices to process when drawing + alias cogl_primitive_new new_; // Variadic + + // Unintrospectable function: new_p2() / cogl_primitive_new_p2() + // Provides a convenient way to describe a primitive, such as a single + // triangle strip or a triangle fan, that will internally allocate the + // necessary #CoglAttributeBuffer storage, describe the position + // attribute with a #CoglAttribute and upload your data. + // + // For example to draw a convex polygon you can do: + // |[ + // CoglVertexP2 triangle[] = + // { + // { 0, 300 }, + // { 150, 0, }, + // { 300, 300 } + // }; + // prim = cogl_primitive_new_p2 (COGL_VERTICES_MODE_TRIANGLE_FAN, + // 3, triangle); + // cogl_primitive_draw (prim); + // ]| + // + // The primitive API doesn't support drawing with sliced + // textures (since switching between slices implies changing state and + // so that implies multiple primitives need to be submitted). You + // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that + // might be used while drawing with this API. If your hardware doesn't + // support non-power of two textures (For example you are using GLES + // 1.1) then you will need to make sure your assets are resized to a + // power-of-two size (though they don't have to be square) + // + // 1. This can be freed using cogl_object_unref(). + // RETURNS: A newly allocated #CoglPrimitive with a reference of + // : A #CoglVerticesMode defining how to draw the vertices + // : The number of vertices to process when drawing + // : An array of #CoglVertexP2 vertices + static Primitive* new_p2(VerticesMode mode, int n_vertices, VertexP2* data) { + return cogl_primitive_new_p2(mode, n_vertices, data); + } + + // Unintrospectable function: new_p2c4() / cogl_primitive_new_p2c4() + // Provides a convenient way to describe a primitive, such as a single + // triangle strip or a triangle fan, that will internally allocate the + // necessary #CoglAttributeBuffer storage, describe the position + // and color attributes with #CoglAttributes and upload + // your data. + // + // For example to draw a convex polygon with a linear gradient you + // can do: + // |[ + // CoglVertexP2C4 triangle[] = + // { + // { 0, 300, 0xff, 0x00, 0x00, 0xff }, + // { 150, 0, 0x00, 0xff, 0x00, 0xff }, + // { 300, 300, 0xff, 0x00, 0x00, 0xff } + // }; + // prim = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN, + // 3, triangle); + // cogl_primitive_draw (prim); + // ]| + // + // The primitive API doesn't support drawing with sliced + // textures (since switching between slices implies changing state and + // so that implies multiple primitives need to be submitted). You + // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that + // might be used while drawing with this API. If your hardware doesn't + // support non-power of two textures (For example you are using GLES + // 1.1) then you will need to make sure your assets are resized to a + // power-of-two size (though they don't have to be square) + // + // 1. This can be freed using cogl_object_unref(). + // RETURNS: A newly allocated #CoglPrimitive with a reference of + // : A #CoglVerticesMode defining how to draw the vertices + // : The number of vertices to process when drawing + // : An array of #CoglVertexP2C4 vertices + static Primitive* new_p2c4(VerticesMode mode, int n_vertices, VertexP2C4* data) { + return cogl_primitive_new_p2c4(mode, n_vertices, data); + } + + // Unintrospectable function: new_p2t2() / cogl_primitive_new_p2t2() + // Provides a convenient way to describe a primitive, such as a single + // triangle strip or a triangle fan, that will internally allocate the + // necessary #CoglAttributeBuffer storage, describe the position and + // texture coordinate attributes with #CoglAttributes and + // upload your data. + // + // For example to draw a convex polygon with texture mapping you can + // do: + // |[ + // CoglVertexP2T2 triangle[] = + // { + // { 0, 300, 0.0, 1.0}, + // { 150, 0, 0.5, 0.0}, + // { 300, 300, 1.0, 1.0} + // }; + // prim = cogl_primitive_new_p2t2 (COGL_VERTICES_MODE_TRIANGLE_FAN, + // 3, triangle); + // cogl_primitive_draw (prim); + // ]| + // + // The primitive API doesn't support drawing with sliced + // textures (since switching between slices implies changing state and + // so that implies multiple primitives need to be submitted). You + // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that + // might be used while drawing with this API. If your hardware doesn't + // support non-power of two textures (For example you are using GLES + // 1.1) then you will need to make sure your assets are resized to a + // power-of-two size (though they don't have to be square) + // + // 1. This can be freed using cogl_object_unref(). + // RETURNS: A newly allocated #CoglPrimitive with a reference of + // : A #CoglVerticesMode defining how to draw the vertices + // : The number of vertices to process when drawing + // : An array of #CoglVertexP2T2 vertices + static Primitive* new_p2t2(VerticesMode mode, int n_vertices, VertexP2T2* data) { + return cogl_primitive_new_p2t2(mode, n_vertices, data); + } + + // Unintrospectable function: new_p2t2c4() / cogl_primitive_new_p2t2c4() + // Provides a convenient way to describe a primitive, such as a single + // triangle strip or a triangle fan, that will internally allocate the + // necessary #CoglAttributeBuffer storage, describe the position, texture + // coordinate and color attributes with #CoglAttributes and + // upload your data. + // + // For example to draw a convex polygon with texture mapping and a + // linear gradient you can do: + // |[ + // CoglVertexP2T2C4 triangle[] = + // { + // { 0, 300, 0.0, 1.0, 0xff, 0x00, 0x00, 0xff}, + // { 150, 0, 0.5, 0.0, 0x00, 0xff, 0x00, 0xff}, + // { 300, 300, 1.0, 1.0, 0xff, 0x00, 0x00, 0xff} + // }; + // prim = cogl_primitive_new_p2t2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN, + // 3, triangle); + // cogl_primitive_draw (prim); + // ]| + // + // The primitive API doesn't support drawing with sliced + // textures (since switching between slices implies changing state and + // so that implies multiple primitives need to be submitted). You + // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that + // might be used while drawing with this API. If your hardware doesn't + // support non-power of two textures (For example you are using GLES + // 1.1) then you will need to make sure your assets are resized to a + // power-of-two size (though they don't have to be square) + // + // 1. This can be freed using cogl_object_unref(). + // RETURNS: A newly allocated #CoglPrimitive with a reference of + // : A #CoglVerticesMode defining how to draw the vertices + // : The number of vertices to process when drawing + // : An array of #CoglVertexP2T2C4 vertices + static Primitive* new_p2t2c4(VerticesMode mode, int n_vertices, VertexP2T2C4* data) { + return cogl_primitive_new_p2t2c4(mode, n_vertices, data); + } + + // Unintrospectable function: new_p3() / cogl_primitive_new_p3() + // Provides a convenient way to describe a primitive, such as a single + // triangle strip or a triangle fan, that will internally allocate the + // necessary #CoglAttributeBuffer storage, describe the position + // attribute with a #CoglAttribute and upload your data. + // + // For example to draw a convex polygon you can do: + // |[ + // CoglVertexP3 triangle[] = + // { + // { 0, 300, 0 }, + // { 150, 0, 0 }, + // { 300, 300, 0 } + // }; + // prim = cogl_primitive_new_p3 (COGL_VERTICES_MODE_TRIANGLE_FAN, + // 3, triangle); + // cogl_primitive_draw (prim); + // ]| + // + // The primitive API doesn't support drawing with sliced + // textures (since switching between slices implies changing state and + // so that implies multiple primitives need to be submitted). You + // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that + // might be used while drawing with this API. If your hardware doesn't + // support non-power of two textures (For example you are using GLES + // 1.1) then you will need to make sure your assets are resized to a + // power-of-two size (though they don't have to be square) + // + // 1. This can be freed using cogl_object_unref(). + // RETURNS: A newly allocated #CoglPrimitive with a reference of + // : A #CoglVerticesMode defining how to draw the vertices + // : The number of vertices to process when drawing + // : An array of #CoglVertexP3 vertices + static Primitive* new_p3(VerticesMode mode, int n_vertices, VertexP3* data) { + return cogl_primitive_new_p3(mode, n_vertices, data); + } + + // Unintrospectable function: new_p3c4() / cogl_primitive_new_p3c4() + // Provides a convenient way to describe a primitive, such as a single + // triangle strip or a triangle fan, that will internally allocate the + // necessary #CoglAttributeBuffer storage, describe the position + // and color attributes with #CoglAttributes and upload + // your data. + // + // For example to draw a convex polygon with a linear gradient you + // can do: + // |[ + // CoglVertexP3C4 triangle[] = + // { + // { 0, 300, 0, 0xff, 0x00, 0x00, 0xff }, + // { 150, 0, 0, 0x00, 0xff, 0x00, 0xff }, + // { 300, 300, 0, 0xff, 0x00, 0x00, 0xff } + // }; + // prim = cogl_primitive_new_p3c4 (COGL_VERTICES_MODE_TRIANGLE_FAN, + // 3, triangle); + // cogl_primitive_draw (prim); + // ]| + // + // The primitive API doesn't support drawing with sliced + // textures (since switching between slices implies changing state and + // so that implies multiple primitives need to be submitted). You + // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that + // might be used while drawing with this API. If your hardware doesn't + // support non-power of two textures (For example you are using GLES + // 1.1) then you will need to make sure your assets are resized to a + // power-of-two size (though they don't have to be square) + // + // 1. This can be freed using cogl_object_unref(). + // RETURNS: A newly allocated #CoglPrimitive with a reference of + // : A #CoglVerticesMode defining how to draw the vertices + // : The number of vertices to process when drawing + // : An array of #CoglVertexP3C4 vertices + static Primitive* new_p3c4(VerticesMode mode, int n_vertices, VertexP3C4* data) { + return cogl_primitive_new_p3c4(mode, n_vertices, data); + } + + // Unintrospectable function: new_p3t2() / cogl_primitive_new_p3t2() + // Provides a convenient way to describe a primitive, such as a single + // triangle strip or a triangle fan, that will internally allocate the + // necessary #CoglAttributeBuffer storage, describe the position and + // texture coordinate attributes with #CoglAttributes and + // upload your data. + // + // For example to draw a convex polygon with texture mapping you can + // do: + // |[ + // CoglVertexP3T2 triangle[] = + // { + // { 0, 300, 0, 0.0, 1.0}, + // { 150, 0, 0, 0.5, 0.0}, + // { 300, 300, 0, 1.0, 1.0} + // }; + // prim = cogl_primitive_new_p3t2 (COGL_VERTICES_MODE_TRIANGLE_FAN, + // 3, triangle); + // cogl_primitive_draw (prim); + // ]| + // + // The primitive API doesn't support drawing with sliced + // textures (since switching between slices implies changing state and + // so that implies multiple primitives need to be submitted). You + // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that + // might be used while drawing with this API. If your hardware doesn't + // support non-power of two textures (For example you are using GLES + // 1.1) then you will need to make sure your assets are resized to a + // power-of-two size (though they don't have to be square) + // + // 1. This can be freed using cogl_object_unref(). + // RETURNS: A newly allocated #CoglPrimitive with a reference of + // : A #CoglVerticesMode defining how to draw the vertices + // : The number of vertices to process when drawing + // : An array of #CoglVertexP3T2 vertices + static Primitive* new_p3t2(VerticesMode mode, int n_vertices, VertexP3T2* data) { + return cogl_primitive_new_p3t2(mode, n_vertices, data); + } + + // Unintrospectable function: new_p3t2c4() / cogl_primitive_new_p3t2c4() + // Provides a convenient way to describe a primitive, such as a single + // triangle strip or a triangle fan, that will internally allocate the + // necessary #CoglAttributeBuffer storage, describe the position, texture + // coordinate and color attributes with #CoglAttributes and + // upload your data. + // + // For example to draw a convex polygon with texture mapping and a + // linear gradient you can do: + // |[ + // CoglVertexP3T2C4 triangle[] = + // { + // { 0, 300, 0, 0.0, 1.0, 0xff, 0x00, 0x00, 0xff}, + // { 150, 0, 0, 0.5, 0.0, 0x00, 0xff, 0x00, 0xff}, + // { 300, 300, 0, 1.0, 1.0, 0xff, 0x00, 0x00, 0xff} + // }; + // prim = cogl_primitive_new_p3t2c4 (COGL_VERTICES_MODE_TRIANGLE_FAN, + // 3, triangle); + // cogl_primitive_draw (prim); + // ]| + // + // The primitive API doesn't support drawing with sliced + // textures (since switching between slices implies changing state and + // so that implies multiple primitives need to be submitted). You + // should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that + // might be used while drawing with this API. If your hardware doesn't + // support non-power of two textures (For example you are using GLES + // 1.1) then you will need to make sure your assets are resized to a + // power-of-two size (though they don't have to be square) + // + // 1. This can be freed using cogl_object_unref(). + // RETURNS: A newly allocated #CoglPrimitive with a reference of + // : A #CoglVerticesMode defining how to draw the vertices + // : The number of vertices to process when drawing + // : An array of #CoglVertexP3T2C4 vertices + static Primitive* new_p3t2c4(VerticesMode mode, int n_vertices, VertexP3T2C4* data) { + return cogl_primitive_new_p3t2c4(mode, n_vertices, data); + } + // Unintrospectable function: new_with_attributes() / cogl_primitive_new_with_attributes() + static Primitive* new_with_attributes(VerticesMode mode, int n_vertices, Attribute** attributes, int n_attributes) { + return cogl_primitive_new_with_attributes(mode, n_vertices, attributes, n_attributes); + } +} + + +// A quaternion is comprised of a scalar component and a 3D vector +// component. The scalar component is normally referred to as w and the +// vector might either be referred to as v or a (for axis) or expanded +// with the individual components: (x, y, z) A full quaternion would +// then be written as
[w (x, y, z)]
. +// +// Quaternions can be considered to represent an axis and angle +// pair although sadly these numbers are buried somewhat under some +// maths... +// +// For the curious you can see here that a given axis (a) and angle (𝜃) +// pair are represented in a quaternion as follows: +// |[ +// [w=cos(𝜃/2) ( x=sin(𝜃/2)*a.x, y=sin(𝜃/2)*a.y, z=sin(𝜃/2)*a.x )] +// ]| +// +// Unit Quaternions: +// When using Quaternions to represent spatial orientations for 3D +// graphics it's always assumed you have a unit quaternion. The +// magnitude of a quaternion is defined as: +// |[ +// sqrt (w² + x² + y² + z²) +// ]| +// and a unit quaternion satisfies this equation: +// |[ +// w² + x² + y² + z² = 1 +// ]| +// +// Thankfully most of the time we don't actually have to worry about +// the maths that goes on behind the scenes but if you are curious to +// learn more here are some external references: +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// 3D Maths Primer for Graphics and Game Development ISBN-10: 1556229119 +// +// +// +// +// +// +// +// +// +// rotation it is sin(𝜃/2)*axis.x +// rotation it is sin(𝜃/2)*axis.y +// rotation it is sin(𝜃/2)*axis.z +struct Quaternion { + float w, x, y, z, padding0, padding1, padding2, padding3; + + + // Unintrospectable method: copy() / cogl_quaternion_copy() + // Allocates a new #CoglQuaternion on the stack and initializes it with + // the same values as @src. + // + // using cogl_quaternion_free() + // RETURNS: A newly allocated #CoglQuaternion which should be freed + Quaternion* copy() { + return cogl_quaternion_copy(&this); + } + float dot_product(Quaternion* b) { + return cogl_quaternion_dot_product(&this, b); + } + + // Frees a #CoglQuaternion that was previously allocated via + // cogl_quaternion_copy(). + void free() { + cogl_quaternion_free(&this); + } + float get_rotation_angle() { + return cogl_quaternion_get_rotation_angle(&this); + } + void get_rotation_axis(Vector3* vector) { + cogl_quaternion_get_rotation_axis(&this, vector); + } + + // Initializes a quaternion that rotates @angle degrees around the + // axis vector (@x, @y, @z). The axis vector does not need to be + // normalized. + // + // rotated @angle degrees around the axis vector (@x, @y, @z) + // RETURNS: A normalized, unit quaternion representing an orientation + // : The angle you want to rotate around the given axis + // : The x component of your axis vector about which you want to rotate. + // : The y component of your axis vector about which you want to rotate. + // : The z component of your axis vector about which you want to rotate. + void init(float angle, float x, float y, float z) { + cogl_quaternion_init(&this, angle, x, y, z); + } + + // Initializes a quaternion that rotates @angle degrees around the + // given @axis vector. The axis vector does not need to be + // normalized. + // + // rotated @angle degrees around the given @axis vector. + // RETURNS: A normalized, unit quaternion representing an orientation + // : your axis vector about which you want to rotate. + void init_from_angle_vector(float angle, Vector3* axis) { + cogl_quaternion_init_from_angle_vector(&this, angle, axis); + } + + // Initializes a [w (x, y,z)] quaternion directly from an array of 4 + // floats: [w,x,y,z]. + // : An array of 4 floats (x,y,z),w + void init_from_array(float* array) { + cogl_quaternion_init_from_array(&this, array); + } + void init_from_euler(Euler* euler) { + cogl_quaternion_init_from_euler(&this, euler); + } + + // XXX: check which direction this rotates + // : The angle to rotate around the x axis + void init_from_x_rotation(float angle) { + cogl_quaternion_init_from_x_rotation(&this, angle); + } + // : The angle to rotate around the y axis + void init_from_y_rotation(float angle) { + cogl_quaternion_init_from_y_rotation(&this, angle); + } + // : The angle to rotate around the y axis + void init_from_z_rotation(float angle) { + cogl_quaternion_init_from_z_rotation(&this, angle); + } + + // Initializes the quaternion with the canonical quaternion identity + // [1 (0, 0, 0)] which represents no rotation. Multiplying a + // quaternion with this identity leaves the quaternion unchanged. + // + // You might also want to consider using + // cogl_get_static_identity_quaternion(). + void init_identity() { + cogl_quaternion_init_identity(&this); + } + void invert() { + cogl_quaternion_invert(&this); + } + + // This combines the rotations of two quaternions into @result. The + // operation is not commutative so the order is important because AxB + // != BxA. Cogl follows the standard convention for quaternions here + // so the rotations are applied @right to @left. This is similar to the + // combining of matrices. + // : The second #CoglQuaternion rotation to apply + // : The first #CoglQuaternion rotation to apply + void multiply(Quaternion* left, Quaternion* right) { + cogl_quaternion_multiply(&this, left, right); + } + + // Performs a normalized linear interpolation between two quaternions. + // That is it does a linear interpolation of the quaternion components + // and then normalizes the result. This will follow the shortest arc + // between the two orientations (just like the slerp() function) but + // will not progress at a constant speed. Unlike slerp() nlerp is + // commutative which is useful if you are blending animations + // together. (I.e. nlerp (tmp, a, b) followed by nlerp (result, tmp, + // d) is the same as nlerp (tmp, a, d) followed by nlerp (result, tmp, + // b)). Finally nlerp is cheaper than slerp so it can be a good choice + // if you don't need the constant speed property of the slerp() function. + // + // Notable properties: + // + // + // commutative: Yes + // + // + // constant velocity: No + // + // + // torque minimal (travels along the surface of the 4-sphere): Yes + // + // + // faster than cogl_quaternion_slerp() + // + // + // : The first #CoglQuaternion + // : The second #CoglQuaternion + // : The factor in the range [0,1] used to interpolate between quaterion @a and @b. + void nlerp(Quaternion* a, Quaternion* b, float t) { + cogl_quaternion_nlerp(&this, a, b, t); + } + void normalize() { + cogl_quaternion_normalize(&this); + } + void pow(float exponent) { + cogl_quaternion_pow(&this, exponent); + } + + // Performs a spherical linear interpolation between two quaternions. + // + // Noteable properties: + // + // + // commutative: No + // + // + // constant velocity: Yes + // + // + // torque minimal (travels along the surface of the 4-sphere): Yes + // + // + // more expensive than cogl_quaternion_nlerp() + // + // + void slerp(Quaternion* a, Quaternion* b, float t) { + cogl_quaternion_slerp(&this, a, b, t); + } + void squad(Quaternion* prev, Quaternion* a, Quaternion* b, Quaternion* next, float t) { + cogl_quaternion_squad(&this, prev, a, b, next, t); + } + + // Compares that all the components of quaternions @a and @b are + // equal. + // + // An epsilon value is not used to compare the float components, but + // the == operator is at least used so that 0 and -0 are considered + // equal. + // RETURNS: %TRUE if the quaternions are equal else %FALSE. + // : A #CoglQuaternion + // : A #CoglQuaternion + static int equal(const(void)* v1, const(void)* v2) { + return cogl_quaternion_equal(v1, v2); + } +} + +enum int RADIANS_TO_DEGREES = 3754936; +// Flags for cogl_read_pixels() +enum ReadPixelsFlags /* Version 1.0 */ { + COLOR_BUFFER = 1 +} +enum RendererError { + NOT_FOUND = 0, + XLIB_DISPLAY_OPEN = 1 +} +enum int SQRTI_ARG_10_PERCENT = 5590; +enum int SQRTI_ARG_5_PERCENT = 210; +enum int SQRTI_ARG_MAX = 4194303; +// Types of shaders +enum ShaderType /* Version 1.0 */ { + VERTEX = 0, + FRAGMENT = 1 +} +enum int TEXTURE_MAX_WASTE = 127; +struct Texture2D { +} + +// Error codes that can be thrown when allocating textures. +enum TextureError /* Version 2.0 */ { + SIZE = 0, + FORMAT = 1, + BAD_PARAMETER = 2 +} +// Flags to pass to the cogl_texture_new_* family of functions. +enum TextureFlags /* Version 1.0 */ { + NONE = 0, + NO_AUTO_MIPMAP = 1, + NO_SLICING = 2, + NO_ATLAS = 4 +} +// Used to specify vertex information when calling cogl_polygon() +struct TextureVertex { + float x, y, z, tx, ty; + Color color; +} + +enum int UNORDERED_MASK = 15; +enum int UNPREMULT_MASK = 127; + +// When associating private data with a #CoglObject a callback can be +// given which will be called either if the object is destroyed or if +// cogl_object_set_user_data() is called with NULL user_data for the +// same key. +// : The data whos association with a #CoglObject has been destoyed. +extern (C) alias void function (void* user_data) UserDataDestroyCallback; + + +// A #CoglUserDataKey is used to declare a key for attaching data to a +// #CoglObject using cogl_object_set_user_data. The typedef only exists as a +// formality to make code self documenting since only the unique address of a +// #CoglUserDataKey is used. +// +// Typically you would declare a static #CoglUserDataKey and set private data +// on an object something like this: +// +// |[ +// static CoglUserDataKey path_private_key; +// +// static void +// destroy_path_private_cb (void *data) +// { +// g_free (data); +// } +// +// static void +// my_path_set_data (CoglPath *path, void *data) +// { +// cogl_object_set_user_data (COGL_OBJECT (path), +// &private_key, +// data, +// destroy_path_private_cb); +// } +// ]| +struct UserDataKey /* Version 1.4 */ { + int unused; +} + +struct Vector3 { + float x, y, z; + + void add_EXP(Vector3* a, Vector3* b) { + cogl_vector3_add_EXP(&this, a, b); + } + // Unintrospectable method: copy_EXP() / cogl_vector3_copy_EXP() + Vector3* copy_EXP() { + return cogl_vector3_copy_EXP(&this); + } + void cross_product_EXP(Vector3* u, Vector3* v) { + cogl_vector3_cross_product_EXP(&this, u, v); + } + float distance_EXP(Vector3* b) { + return cogl_vector3_distance_EXP(&this, b); + } + void divide_scalar_EXP(float scalar) { + cogl_vector3_divide_scalar_EXP(&this, scalar); + } + float dot_product_EXP(Vector3* b) { + return cogl_vector3_dot_product_EXP(&this, b); + } + int equal_with_epsilon_EXP(Vector3* vector1, float epsilon) { + return cogl_vector3_equal_with_epsilon_EXP(&this, vector1, epsilon); + } + void free_EXP() { + cogl_vector3_free_EXP(&this); + } + void init_EXP(float x, float y, float z) { + cogl_vector3_init_EXP(&this, x, y, z); + } + void init_zero_EXP() { + cogl_vector3_init_zero_EXP(&this); + } + void invert_EXP() { + cogl_vector3_invert_EXP(&this); + } + float magnitude_EXP() { + return cogl_vector3_magnitude_EXP(&this); + } + void multiply_scalar_EXP(float scalar) { + cogl_vector3_multiply_scalar_EXP(&this, scalar); + } + void normalize_EXP() { + cogl_vector3_normalize_EXP(&this); + } + void subtract_EXP(Vector3* a, Vector3* b) { + cogl_vector3_subtract_EXP(&this, a, b); + } + static int equal_EXP(const(void)* v1, const(void)* v2) { + return cogl_vector3_equal_EXP(v1, v2); + } +} + + +// A convenience vertex definition that can be used with +// cogl_primitive_new_with_v2_attributes(). +struct VertexP2 /* Version 1.6 */ { + float x, y; +} + + +// A convenience vertex definition that can be used with +// cogl_primitive_new_with_v2c4_attributes(). +struct VertexP2C4 /* Version 1.6 */ { + float x, y; + ubyte r, g, b, a; +} + + +// A convenience vertex definition that can be used with +// cogl_primitive_new_with_v2t2_attributes(). +struct VertexP2T2 /* Version 1.6 */ { + float x, y, s, t; +} + + +// A convenience vertex definition that can be used with +// cogl_primitive_new_with_v3t2c4_attributes(). +struct VertexP2T2C4 /* Version 1.6 */ { + float x, y, s, t; + ubyte r, g, b, a; +} + + +// A convenience vertex definition that can be used with +// cogl_primitive_new_with_v3_attributes(). +struct VertexP3 /* Version 1.6 */ { + float x, y, z; +} + + +// A convenience vertex definition that can be used with +// cogl_primitive_new_with_v3c4_attributes(). +struct VertexP3C4 /* Version 1.6 */ { + float x, y, z; + ubyte r, g, b, a; +} + + +// A convenience vertex definition that can be used with +// cogl_primitive_new_with_v3t2_attributes(). +struct VertexP3T2 /* Version 1.6 */ { + float x, y, z, s, t; +} + + +// A convenience vertex definition that can be used with +// cogl_primitive_new_with_v3t2c4_attributes(). +struct VertexP3T2C4 /* Version 1.6 */ { + float x, y, z, s, t; + ubyte r, g, b, a; +} + +// Different ways of interpreting vertices when drawing. +enum VerticesMode /* Version 1.0 */ { + POINTS = 0, + LINES = 1, + LINE_LOOP = 2, + LINE_STRIP = 3, + TRIANGLES = 4, + TRIANGLE_STRIP = 5, + TRIANGLE_FAN = 6 +} +enum WinsysFeature { + MULTIPLE_ONSCREEN = 0, + SWAP_THROTTLE = 1, + VBLANK_COUNTER = 2, + VBLANK_WAIT = 3, + TEXTURE_FROM_PIXMAP = 4, + SWAP_BUFFERS_EVENT = 5, + SWAP_REGION = 6, + SWAP_REGION_THROTTLE = 7, + SWAP_REGION_SYNCHRONIZED = 8, + N_FEATURES = 9 +} +// Unintrospectable callback: XlibFilterFunc() / () +extern (C) alias FilterReturn function (XEvent* event, void* data) XlibFilterFunc; + +struct _ColorSizeCheck { + char[/*GIR: -1*/ 0] compile_time_assert_CoglColor_size; +} + +struct _EulerSizeCheck { + char[/*GIR: -1*/ 0] compile_time_assert_CoglEuler_size; +} + +struct _MatrixSizeCheck { + char[/*GIR: -1*/ 0] compile_time_assert_CoglMatrix_size; +} + +struct _QuaternionSizeCheck { + char[/*GIR: -1*/ 0] compile_time_assert_CoglQuaternion_size; +} + +struct _TextureVertexSizeCheck { + char[/*GIR: -1*/ 0] compile_time_assert_CoglTextureVertex_size; +} + + +// Unintrospectable function: angle_cos() / cogl_angle_cos() +// Computes the cosine of @angle +// RETURNS: the cosine of the passed angle +// : an angle expressed using #CoglAngle +static Fixed angle_cos(Angle angle) { + return cogl_angle_cos(angle); +} + + +// Unintrospectable function: angle_sin() / cogl_angle_sin() +// Computes the sine of @angle +// RETURNS: the sine of the passed angle +// : an angle expressed using #CoglAngle +static Fixed angle_sin(Angle angle) { + return cogl_angle_sin(angle); +} + + +// Unintrospectable function: angle_tan() / cogl_angle_tan() +// Computes the tangent of @angle +// RETURNS: the tangent of the passed angle +// : an angle expressed using #CoglAngle +static Fixed angle_tan(Angle angle) { + return cogl_angle_tan(angle); +} + + +// We do not advise nor reliably support the interleaving of raw GL drawing and +// Cogl drawing functions, but if you insist, cogl_begin_gl() and cogl_end_gl() +// provide a simple mechanism that may at least give you a fighting chance of +// succeeding. +// +// Note: this doesn't help you modify the behaviour of Cogl drawing functions +// through the modification of GL state; that will never be reliably supported, +// but if you are trying to do something like: +// +// |[ +// { +// - setup some OpenGL state. +// - draw using OpenGL (e.g. glDrawArrays() ) +// - reset modified OpenGL state. +// - continue using Cogl to draw +// } +// ]| +// +// You should surround blocks of drawing using raw GL with cogl_begin_gl() +// and cogl_end_gl(): +// +// |[ +// { +// cogl_begin_gl (); +// - setup some OpenGL state. +// - draw using OpenGL (e.g. glDrawArrays() ) +// - reset modified OpenGL state. +// cogl_end_gl (); +// - continue using Cogl to draw +// } +// ]| +// +// Don't ever try and do: +// +// |[ +// { +// - setup some OpenGL state. +// - use Cogl to draw +// - reset modified OpenGL state. +// } +// ]| +// +// When the internals of Cogl evolves, this is very liable to break. +// +// This function will flush all batched primitives, and subsequently flush +// all internal Cogl state to OpenGL as if it were going to draw something +// itself. +// +// The result is that the OpenGL modelview matrix will be setup; the state +// corresponding to the current source material will be set up and other world +// state such as backface culling, depth and fogging enabledness will be sent +// to OpenGL. +// +// No special material state is flushed, so if you want Cogl to setup a +// simplified material state it is your responsibility to set a simple source +// material before calling cogl_begin_gl(). E.g. by calling +// cogl_set_source_color4ub(). +// +// It is your responsibility to restore any OpenGL state that you modify +// to how it was after calling cogl_begin_gl() if you don't do this then the +// result of further Cogl calls is undefined. +// +// You can not nest begin/end blocks. +// +// Again we would like to stress, we do not advise the use of this API and if +// possible we would prefer to improve Cogl than have developers require raw +// OpenGL. +static void begin_gl() { + cogl_begin_gl(); +} + +static GLib2.Quark bitmap_error_quark() { + return cogl_bitmap_error_quark(); +} + + +// Parses an image file enough to extract the width and height +// of the bitmap. +// RETURNS: %TRUE if the image was successfully parsed +// : the file to check +// : return location for the bitmap width, or %NULL +// : return location for the bitmap height, or %NULL +static int bitmap_get_size_from_file(char* filename, /*out*/ int* width, /*out*/ int* height) { + return cogl_bitmap_get_size_from_file(filename, width, height); +} + +static GLib2.Quark blend_string_error_quark() { + return cogl_blend_string_error_quark(); +} + + +// Check whether @name occurs in list of extensions in @ext. +// +// +// not appropriate to expose OpenGL extensions through the Cogl API. This +// function can be replaced by the following equivalent code: +// |[ +// gboolean retval = (strstr (ext, name) != NULL) ? TRUE : FALSE; +// ]| +// RETURNS: %TRUE if the extension occurs in the list, %FALSE otherwise. +// : extension to check for +// : list of extensions +static int check_extension(char* name, char* ext) { + return cogl_check_extension(name, ext); +} + + +// Clears all the auxiliary buffers identified in the @buffers mask, and if +// that includes the color buffer then the specified @color is used. +// : Background color to clear to +// : A mask of #CoglBufferBit's identifying which auxiliary buffers to clear +static void clear(Color* color, c_ulong buffers) { + cogl_clear(color, buffers); +} + + +// Ensures that the current clipping region has been set in GL. This +// will automatically be called before any Cogl primitives but it +// maybe be neccessary to call if you are using raw GL calls with +// clipping. +static void clip_ensure() { + cogl_clip_ensure(); +} + + +// Reverts the clipping region to the state before the last call to +// cogl_clip_push(). +static void clip_pop() { + cogl_clip_pop(); +} + + +// Specifies a rectangular clipping area for all subsequent drawing +// operations. Any drawing commands that extend outside the rectangle +// will be clipped so that only the portion inside the rectangle will +// be displayed. The rectangle dimensions are transformed by the +// current model-view matrix. +// +// The rectangle is intersected with the current clip region. To undo +// the effect of this function, call cogl_clip_pop(). +// +// with other API that specify rectangles in model space, and when used +// with a coordinate space that puts the origin at the center and y+ +// extending up, it's awkward to use. Please use cogl_clip_push_rectangle() +// instead +// : left edge of the clip rectangle +// : top edge of the clip rectangle +// : width of the clip rectangle +// : height of the clip rectangle +static void clip_push(float x_offset, float y_offset, float width, float height) { + cogl_clip_push(x_offset, y_offset, width, height); +} + + +// Sets a new clipping area using the current path. The current path +// is then cleared. The clipping area is intersected with the previous +// clipping area. To restore the previous clipping area, call +// cogl_clip_pop(). +static void clip_push_from_path() { + cogl_clip_push_from_path(); +} + + +// Sets a new clipping area using the current path. The current path +// is then cleared. The clipping area is intersected with the previous +// clipping area. To restore the previous clipping area, call +// cogl_clip_pop(). +static void clip_push_from_path_preserve() { + cogl_clip_push_from_path_preserve(); +} + + +// Specifies a rectangular clipping area for all subsequent drawing +// operations. Any drawing commands that extend outside the rectangle +// will be clipped so that only the portion inside the rectangle will +// be displayed. The rectangle dimensions are transformed by the +// current model-view matrix. +// +// The rectangle is intersected with the current clip region. To undo +// the effect of this function, call cogl_clip_pop(). +// : x coordinate for top left corner of the clip rectangle +// : y coordinate for top left corner of the clip rectangle +// : x coordinate for bottom right corner of the clip rectangle +// : y coordinate for bottom right corner of the clip rectangle +static void clip_push_rectangle(float x0, float y0, float x1, float y1) { + cogl_clip_push_rectangle(x0, y0, x1, y1); +} + + +// Specifies a rectangular clipping area for all subsequent drawing +// operations. Any drawing commands that extend outside the rectangle +// will be clipped so that only the portion inside the rectangle will +// be displayed. The rectangle dimensions are not transformed by the +// current model-view matrix. +// +// The rectangle is intersected with the current clip region. To undo +// the effect of this function, call cogl_clip_pop(). +// : left edge of the clip rectangle in window coordinates +// : top edge of the clip rectangle in window coordinates +// : width of the clip rectangle +// : height of the clip rectangle +static void clip_push_window_rect(float x_offset, float y_offset, float width, float height) { + cogl_clip_push_window_rect(x_offset, y_offset, width, height); +} + + +// Specifies a rectangular clipping area for all subsequent drawing +// operations. Any drawing commands that extend outside the rectangle +// will be clipped so that only the portion inside the rectangle will +// be displayed. The rectangle dimensions are not transformed by the +// current model-view matrix. +// +// The rectangle is intersected with the current clip region. To undo +// the effect of this function, call cogl_clip_pop(). +// : left edge of the clip rectangle in window coordinates +// : top edge of the clip rectangle in window coordinates +// : width of the clip rectangle +// : height of the clip rectangle +static void clip_push_window_rectangle(int x_offset, int y_offset, int width, int height) { + cogl_clip_push_window_rectangle(x_offset, y_offset, width, height); +} + + +// Restore the state of the clipping stack that was previously saved +// by cogl_clip_stack_save(). +// +// the clip stack when switching back from an offscreen framebuffer, +// but it's not necessary anymore given that framebuffers now own +// separate clip stacks which will be automatically switched between +// when a new buffer is set. Calling this function has no effect +static void clip_stack_restore() { + cogl_clip_stack_restore(); +} + + +// Save the entire state of the clipping stack and then clear all +// clipping. The previous state can be returned to with +// cogl_clip_stack_restore(). Each call to cogl_clip_push() after this +// must be matched by a call to cogl_clip_pop() before calling +// cogl_clip_stack_restore(). +// +// clip stack when switching to an offscreen framebuffer, but it's +// not necessary anymore given that framebuffers now own separate +// clip stacks which will be automatically switched between when a +// new buffer is set. Calling this function has no effect +static void clip_stack_save() { + cogl_clip_stack_save(); +} + +static int clutter_check_extension_CLUTTER(char* name, char* ext) { + return cogl_clutter_check_extension_CLUTTER(name, ext); +} + +static int clutter_winsys_has_feature_CLUTTER(WinsysFeature feature) { + return cogl_clutter_winsys_has_feature_CLUTTER(feature); +} + +// Unintrospectable function: clutter_winsys_xlib_get_visual_info_CLUTTER() / cogl_clutter_winsys_xlib_get_visual_info_CLUTTER() +static /*CTYPE*/ XVisualInfo* clutter_winsys_xlib_get_visual_info_CLUTTER() { + return cogl_clutter_winsys_xlib_get_visual_info_CLUTTER(); +} + + +// Compares two #CoglColors and checks if they are the same. +// +// This function can be passed to g_hash_table_new() as the @key_equal_func +// parameter, when using #CoglColors as keys in a #GHashTable. +// RETURNS: %TRUE if the two colors are the same. +// : a #CoglColor +// : a #CoglColor +static int color_equal(const(void)* v1, const(void)* v2) { + return cogl_color_equal(v1, v2); +} + + +// Unintrospectable function: create_program() / cogl_create_program() +// Create a new cogl program object that can be used to replace parts of the GL +// rendering pipeline with custom code. +// RETURNS: a new cogl program. +static Handle create_program() { + return cogl_create_program(); +} + + +// Unintrospectable function: create_shader() / cogl_create_shader() +// Create a new shader handle, use #cogl_shader_source to set the source code +// to be used on it. +// RETURNS: a new shader handle. +// : COGL_SHADER_TYPE_VERTEX or COGL_SHADER_TYPE_FRAGMENT. +static Handle create_shader(ShaderType shader_type) { + return cogl_create_shader(shader_type); +} + + +// This function disables fogging, so primitives drawn afterwards will not be +// blended with any previously set fog color. +static void disable_fog() { + cogl_disable_fog(); +} + +// Unintrospectable function: double_to_fixed() / cogl_double_to_fixed() +static Fixed double_to_fixed(double value) { + return cogl_double_to_fixed(value); +} + +static int double_to_int(double value) { + return cogl_double_to_int(value); +} + +static uint double_to_uint(double value) { + return cogl_double_to_uint(value); +} + +static void draw_attributes(VerticesMode mode, int first_vertex, int n_vertices, Attribute** attributes, int n_attributes) { + cogl_draw_attributes(mode, first_vertex, n_vertices, attributes, n_attributes); +} + +static void draw_indexed_attributes(VerticesMode mode, int first_vertex, int n_vertices, Indices* indices, Attribute** attributes, int n_attributes) { + cogl_draw_indexed_attributes(mode, first_vertex, n_vertices, indices, attributes, n_attributes); +} + + +// This is the counterpart to cogl_begin_gl() used to delimit blocks of drawing +// code using raw OpenGL. Please refer to cogl_begin_gl() for full details. +static void end_gl() { + cogl_end_gl(); +} + + +// Compares the two given euler angles @v1 and @v1 and it they are +// equal returns %TRUE else %FALSE. +// +// This function only checks that all three components rotations +// are numerically equal, it does not consider that some rotations +// can be represented with different component rotations +// RETURNS: %TRUE if @v1 and @v2 are equal else %FALSE. +// : The second euler angle to compare +static int euler_equal(const(void)* v1, const(void)* v2) { + return cogl_euler_equal(v1, v2); +} + + +// Checks whether the given COGL features are available. Multiple +// features can be checked for by or-ing them together with the '|' +// operator. %TRUE is only returned if all of the requested features +// are available. +// RETURNS: %TRUE if the features are available, %FALSE otherwise. +// : A bitmask of features to check for +static int features_available(FeatureFlags features) { + return cogl_features_available(features); +} + + +// This function should only need to be called in exceptional circumstances. +// +// As an optimization Cogl drawing functions may batch up primitives +// internally, so if you are trying to use raw GL outside of Cogl you stand a +// better chance of being successful if you ask Cogl to flush any batched +// geometry before making your state changes. +// +// It only ensure that the underlying driver is issued all the commands +// necessary to draw the batched primitives. It provides no guarantees about +// when the driver will complete the rendering. +// +// This provides no guarantees about the GL state upon returning and to avoid +// confusing Cogl you should aim to restore any changes you make before +// resuming use of Cogl. +// +// If you are making state changes with the intention of affecting Cogl drawing +// primitives you are 100% on your own since you stand a good chance of +// conflicting with Cogl internals. For example clutter-gst which currently +// uses direct GL calls to bind ARBfp programs will very likely break when Cogl +// starts to use ARBfb programs itself for the material API. +static void flush() { + cogl_flush(); +} + + +// Replaces the current projection matrix with a perspective matrix +// for the given viewing frustum. +// : Left clipping plane +// : Right clipping plane +// : Bottom clipping plane +// : Top clipping plane +// : Nearest visible point +// : Furthest visible point along the z-axis +static void frustum(float left, float right, float bottom, float top, float z_near, float z_far) { + cogl_frustum(left, right, bottom, top, z_near, z_far); +} + + +// Queries if backface culling has been enabled via +// cogl_set_backface_culling_enabled() +// RETURNS: %TRUE if backface culling is enabled, and %FALSE otherwise +static int get_backface_culling_enabled() { + return cogl_get_backface_culling_enabled(); +} + + +// Gets the number of bitplanes used for each of the color components +// in the color buffer. Pass %NULL for any of the arguments if the +// value is not required. +// : Return location for the number of red bits or %NULL +// : Return location for the number of green bits or %NULL +// : Return location for the number of blue bits or %NULL +// : Return location for the number of alpha bits or %NULL +static void get_bitmasks(/*out*/ int* red, /*out*/ int* green, /*out*/ int* blue, /*out*/ int* alpha) { + cogl_get_bitmasks(red, green, blue, alpha); +} + + +// Queries if depth testing has been enabled via cogl_set_depth_test_enable() +// +// +// instead. +// RETURNS: %TRUE if depth testing is enabled, and %FALSE otherwise +static int get_depth_test_enabled() { + return cogl_get_depth_test_enabled(); +} + + +// Returns all of the features supported by COGL. +// RETURNS: A logical OR of all the supported COGL features. +static FeatureFlags get_features() { + return cogl_get_features(); +} + + +// Stores the current model-view matrix in @matrix. +// : return location for the model-view matrix +static void get_modelview_matrix(/*out*/ Matrix* matrix) { + cogl_get_modelview_matrix(matrix); +} + + +// Unintrospectable function: get_option_group() / cogl_get_option_group() +// Retrieves the #GOptionGroup used by COGL to parse the command +// line options. Clutter uses this to handle the COGL command line +// options during its initialization process. +// RETURNS: a #GOptionGroup +static GLib2.OptionGroup* get_option_group() { + return cogl_get_option_group(); +} + + +// Unintrospectable function: get_path() / cogl_get_path() +// Gets a pointer to the current path. The path can later be used +// again by calling cogl_path_set(). Note that the path isn't copied +// so if you later call any functions to add to the path it will +// affect the returned object too. No reference is taken on the path +// so if you want to retain it you should take your own reference with +// cogl_object_ref(). +// RETURNS: a pointer to the current path. +static Path* get_path() { + return cogl_get_path(); +} + + +// Unintrospectable function: get_proc_address() / cogl_get_proc_address() +// Gets a pointer to a given GL or GL ES extension function. This acts +// as a wrapper around glXGetProcAddress() or whatever is the +// appropriate function for the current backend. +// +// function is not available. +// RETURNS: a pointer to the requested function or %NULL if the +// : the name of the function. +static FuncPtr get_proc_address(char* name) { + return cogl_get_proc_address(name); +} + + +// Stores the current projection matrix in @matrix. +// : return location for the projection matrix +static void get_projection_matrix(/*out*/ Matrix* matrix) { + cogl_get_projection_matrix(matrix); +} + +// Unintrospectable function: get_rectangle_indices() / cogl_get_rectangle_indices() +static Indices* get_rectangle_indices(int n_rectangles) { + return cogl_get_rectangle_indices(n_rectangles); +} + + +// Unintrospectable function: get_source() / cogl_get_source() +// Returns the current source material as previously set using +// cogl_set_source(). +// +// You should typically consider the returned material immutable +// and not try to change any of its properties unless you own a +// reference to that material. At times you may be able to get a +// reference to an internally managed materials and the result of +// modifying such materials is undefined. +// RETURNS: The current source material. +static void* get_source() { + return cogl_get_source(); +} + + +// Returns a pointer to a singleton quaternion constant describing the +// canonical identity [1 (0, 0, 0)] which represents no rotation. +// +// If you multiply a quaternion with the identity quaternion you will +// get back the same value as the original quaternion. +// RETURNS: A pointer to an identity quaternion +static Quaternion* get_static_identity_quaternion() { + return cogl_get_static_identity_quaternion(); +} + + +// rotation of 180 degrees around a degenerate axis: +// [0 (0, 0, 0)] +// RETURNS: a pointer to a singleton quaternion constant describing a +static Quaternion* get_static_zero_quaternion() { + return cogl_get_static_zero_quaternion(); +} + + +// Stores the current viewport in @v. @v[0] and @v[1] get the x and y +// position of the viewport and @v[2] and @v[3] get the width and +// height. +// : pointer to a 4 element array of #floats to receive the viewport dimensions. +static void get_viewport(/*out*/ float v) { + cogl_get_viewport(v); +} + +static Type handle_get_type() { + return cogl_handle_get_type(); +} + + +// Increases the reference count of @handle by 1 +// RETURNS: the handle, with its reference count increased +// : a #CoglHandle +static Handle handle_ref(Handle handle) { + return cogl_handle_ref(handle); +} + + +// Drecreases the reference count of @handle by 1; if the reference +// count reaches 0, the resources allocated by @handle will be freed +// : a #CoglHandle +static void handle_unref(Handle handle) { + cogl_handle_unref(handle); +} + +static IndicesType indices_get_type(Indices* indices) { + return cogl_indices_get_type(indices); +} + + +// Gets whether the given object references a #CoglAttribute. +// +// %FALSE otherwise +// RETURNS: %TRUE if the handle references a #CoglAttribute, +// : A #CoglObject +static int is_attribute(void* object) { + return cogl_is_attribute(object); +} + + +// Gets whether the given object references a #CoglAttributeBuffer. +// +// %FALSE otherwise +// RETURNS: %TRUE if the handle references a #CoglAttributeBuffer, +// : A #CoglObject +static int is_attribute_buffer(void* object) { + return cogl_is_attribute_buffer(object); +} + + +// Checks whether @handle is a #CoglHandle for a bitmap +// +// and %FALSE otherwise +// RETURNS: %TRUE if the passed handle represents a bitmap, +// : a #CoglHandle for a bitmap +static int is_bitmap(Handle handle) { + return cogl_is_bitmap(handle); +} + +static int is_buffer_EXP(void* object) { + return cogl_is_buffer_EXP(object); +} + + +// Gets whether the given object references a #CoglIndexBuffer. +// +// %FALSE otherwise +// RETURNS: %TRUE if the handle references a #CoglIndexBuffer, +// : A #CoglObject +static int is_index_buffer(void* object) { + return cogl_is_index_buffer(object); +} + + +// Gets whether the given handle references an existing material object. +// +// %FALSE otherwise +// RETURNS: %TRUE if the handle references a #CoglMaterial, +// : A CoglHandle +static int is_material(Handle handle) { + return cogl_is_material(handle); +} + + +// Determines whether the given #CoglHandle references an offscreen buffer +// object. +// +// %FALSE otherwise +// RETURNS: %TRUE if the handle references an offscreen buffer, +// : A CoglHandle for an offscreen buffer +static int is_offscreen(Handle handle) { + return cogl_is_offscreen(handle); +} + + +// Gets whether the given handle references an existing path object. +// +// %FALSE otherwise +// RETURNS: %TRUE if the handle references a #CoglPath, +// : A CoglHandle +static int is_path(Handle handle) { + return cogl_is_path(handle); +} + +static int is_pixel_buffer_EXP(void* object) { + return cogl_is_pixel_buffer_EXP(object); +} + + +// Gets whether the given object references a #CoglPrimitive. +// +// %FALSE otherwise +// RETURNS: %TRUE if the handle references a #CoglPrimitive, +// : A #CoglObject +static int is_primitive(void* object) { + return cogl_is_primitive(object); +} + + +// Gets whether the given handle references an existing program object. +// +// %FALSE otherwise +// RETURNS: %TRUE if the handle references a program, +// : A CoglHandle +static int is_program(Handle handle) { + return cogl_is_program(handle); +} + + +// Gets whether the given handle references an existing shader object. +// +// %FALSE otherwise +// RETURNS: %TRUE if the handle references a shader, +// : A CoglHandle +static int is_shader(Handle handle) { + return cogl_is_shader(handle); +} + + +// Gets whether the given handle references an existing texture object. +// +// %FALSE otherwise +// RETURNS: %TRUE if the handle references a texture, and +// : A CoglHandle +static int is_texture(Handle handle) { + return cogl_is_texture(handle); +} + +static int is_texture_2d_EXP(void* object) { + return cogl_is_texture_2d_EXP(object); +} + +static int is_texture_3d_EXP(Handle handle) { + return cogl_is_texture_3d_EXP(handle); +} + + +// Checks whether @handle is a Vertex Buffer Object +// +// otherwise +// RETURNS: %TRUE if the handle is a VBO, and %FALSE +// : a #CoglHandle for a vertex buffer object +static int is_vertex_buffer(Handle handle) { + return cogl_is_vertex_buffer(handle); +} + + +// Checks whether @handle is a handle to the indices for a vertex +// buffer object +// +// otherwise +// RETURNS: %TRUE if the handle is indices, and %FALSE +// : a #CoglHandle +static int is_vertex_buffer_indices(Handle handle) { + return cogl_is_vertex_buffer_indices(handle); +} + + +// Retrieves the type of the layer +// +// Currently there is only one type of layer defined: +// %COGL_MATERIAL_LAYER_TYPE_TEXTURE, but considering we may add purely GLSL +// based layers in the future, you should write code that checks the type +// first. +// RETURNS: the type of the layer +// : A #CoglMaterialLayer object +static MaterialLayerType material_layer_get_type(MaterialLayer* layer) { + return cogl_material_layer_get_type(layer); +} + + +// Decrement the reference count for a #CoglMaterial. +// : a #CoglMaterial object. +static void material_unref(Handle material) { + cogl_material_unref(material); +} + + +// Compares two matrices to see if they represent the same +// transformation. Although internally the matrices may have different +// annotations associated with them and may potentially have a cached +// inverse matrix these are not considered in the comparison. +// : A 4x4 transformation matrix +// : A 4x4 transformation matrix +static int matrix_equal(const(void)* v1, const(void)* v2) { + return cogl_matrix_equal(v1, v2); +} + + +// Unintrospectable function: object_ref() / cogl_object_ref() +// Increases the reference count of @handle by 1 +// RETURNS: the @object, with its reference count increased +// : a #CoglObject +static void* object_ref(void* object) { + return cogl_object_ref(object); +} + + +// Unintrospectable function: object_unref() / cogl_object_unref() +// Drecreases the reference count of @object by 1; if the reference +// count reaches 0, the resources allocated by @object will be freed +// : a #CoglObject +static void object_unref(void* object) { + cogl_object_unref(object); +} + + +// This creates an offscreen buffer object using the given texture as the +// primary color buffer. It doesn't just initialize the contents of the +// offscreen buffer with the texture; they are tightly bound so that +// drawing to the offscreen buffer effectivly updates the contents of the +// given texture. You don't need to destroy the offscreen buffer before +// you can use the texture again. +// +// Note: This does not work with sliced Cogl textures. +// +// buffer or %COGL_INVALID_HANDLE if it wasn't possible to create the +// buffer. +// RETURNS: a #CoglHandle for the new offscreen +// : A CoglHandle for a Cogl texture +static Handle /*new*/ offscreen_new_to_texture(Handle handle) { + return cogl_offscreen_new_to_texture(handle); +} + + +// Increments the reference count on the offscreen buffer. +// RETURNS: For convenience it returns the given CoglHandle +// : A CoglHandle for an offscreen buffer +static Handle offscreen_ref(Handle handle) { + return cogl_offscreen_ref(handle); +} + + +// Decreases the reference count for the offscreen buffer and frees it when +// the count reaches 0. +// : A CoglHandle for an offscreen buffer +static void offscreen_unref(Handle handle) { + cogl_offscreen_unref(handle); +} + +static void onscreen_clutter_backend_set_size_CLUTTER(int width, int height) { + cogl_onscreen_clutter_backend_set_size_CLUTTER(width, height); +} + + +// Replaces the current projection matrix with an orthographic projection +// matrix. See to see how the matrix is +// calculated. +// +//
+// +// +//
+// +// This function copies the arguments from OpenGL's glOrtho() even +// though they are unnecessarily confusing due to the z near and z far +// arguments actually being a "distance" from the origin, where +// negative values are behind the viewer, instead of coordinates for +// the z clipping planes which would have been consistent with the +// left, right bottom and top arguments. +// : The coordinate for the left clipping plane +// : The coordinate for the right clipping plane +// : The coordinate for the bottom clipping plane +// : The coordinate for the top clipping plane +// : The distance to the near clipping plane (negative if the plane is behind the viewer) +// : The distance for the far clipping plane (negative if the plane is behind the viewer) +static void ortho(float left, float right, float bottom, float top, float near, float far) { + cogl_ortho(left, right, bottom, top, near, far); +} + + +// Adds an elliptical arc segment to the current path. A straight line +// segment will link the current pen location with the first vertex +// of the arc. If you perform a move_to to the arcs start just before +// drawing it you create a free standing arc. +// +// The angles are measured in degrees where 0° is in the direction of +// the positive X axis and 90° is in the direction of the positive Y +// axis. The angle of the arc begins at @angle_1 and heads towards +// @angle_2 (so if @angle_2 is less than @angle_1 it will decrease, +// otherwise it will increase). +// : X coordinate of the elliptical arc center +// : Y coordinate of the elliptical arc center +// : X radius of the elliptical arc +// : Y radius of the elliptical arc +// : Angle in degrees at which the arc begin +// : Angle in degrees at which the arc ends +static void path_arc(float center_x, float center_y, float radius_x, float radius_y, float angle_1, float angle_2) { + cogl_path_arc(center_x, center_y, radius_x, radius_y, angle_1, angle_2); +} + + +// Closes the path being constructed by adding a straight line segment +// to it that ends at the first vertex of the path. +static void path_close() { + cogl_path_close(); +} + + +// Adds a cubic bezier curve segment to the current path with the given +// second, third and fourth control points and using current pen location +// as the first control point. +// : X coordinate of the second bezier control point +// : Y coordinate of the second bezier control point +// : X coordinate of the third bezier control point +// : Y coordinate of the third bezier control point +// : X coordinate of the fourth bezier control point +// : Y coordinate of the fourth bezier control point +static void path_curve_to(float x_1, float y_1, float x_2, float y_2, float x_3, float y_3) { + cogl_path_curve_to(x_1, y_1, x_2, y_2, x_3, y_3); +} + + +// Constructs an ellipse shape. If there is an existing path this will +// start a new disjoint sub-path. +// : X coordinate of the ellipse center +// : Y coordinate of the ellipse center +// : X radius of the ellipse +// : Y radius of the ellipse +static void path_ellipse(float center_x, float center_y, float radius_x, float radius_y) { + cogl_path_ellipse(center_x, center_y, radius_x, radius_y); +} + + +// Fills the interior of the constructed shape using the current +// drawing color. The current path is then cleared. To use the path +// again, call cogl_path_fill_preserve() instead. +// +// The interior of the shape is determined using the fill rule of the +// path. See %CoglPathFillRule for details. +static void path_fill() { + cogl_path_fill(); +} + + +// Fills the interior of the constructed shape using the current +// drawing color and preserves the path to be used again. See +// cogl_path_fill() for a description what is considered the interior +// of the shape. +static void path_fill_preserve() { + cogl_path_fill_preserve(); +} + + +// Retrieves the fill rule set using cogl_path_set_fill_rule(). +// RETURNS: the fill rule that is used for the current path. +static PathFillRule path_get_fill_rule() { + return cogl_path_get_fill_rule(); +} + + +// Constructs a straight line shape starting and ending at the given +// coordinates. If there is an existing path this will start a new +// disjoint sub-path. +// : X coordinate of the start line vertex +// : Y coordinate of the start line vertex +// : X coordinate of the end line vertex +// : Y coordinate of the end line vertex +static void path_line(float x_1, float y_1, float x_2, float y_2) { + cogl_path_line(x_1, y_1, x_2, y_2); +} + + +// Adds a straight line segment to the current path that ends at the +// given coordinates. +// : X coordinate of the end line vertex +// : Y coordinate of the end line vertex +static void path_line_to(float x, float y) { + cogl_path_line_to(x, y); +} + + +// Moves the pen to the given location. If there is an existing path +// this will start a new disjoint subpath. +// : X coordinate of the pen location to move to. +// : Y coordinate of the pen location to move to. +static void path_move_to(float x, float y) { + cogl_path_move_to(x, y); +} + + +// Clears the current path and starts a new one. Creating a new path +// also resets the fill rule to the default which is +// %COGL_PATH_FILL_RULE_EVEN_ODD. +static void path_new() { + cogl_path_new(); +} + + +// Constructs a polygonal shape of the given number of vertices. If +// there is an existing path this will start a new disjoint sub-path. +// +// The coords array must contain 2 * num_points values. The first value +// represents the X coordinate of the first vertex, the second value +// represents the Y coordinate of the first vertex, continuing in the same +// fashion for the rest of the vertices. +// : A pointer to the first element of an array of fixed-point values that specify the vertex coordinates. +// : The total number of vertices. +static void path_polygon(float* coords, int num_points) { + cogl_path_polygon(coords, num_points); +} + + +// Constructs a series of straight line segments, starting from the +// first given vertex coordinate. If there is an existing path this +// will start a new disjoint sub-path. Each subsequent segment starts +// where the previous one ended and ends at the next given vertex +// coordinate. +// +// The coords array must contain 2 * num_points values. The first value +// represents the X coordinate of the first vertex, the second value +// represents the Y coordinate of the first vertex, continuing in the same +// fashion for the rest of the vertices. (num_points - 1) segments will +// be constructed. +// : A pointer to the first element of an array of fixed-point values that specify the vertex coordinates. +// : The total number of vertices. +static void path_polyline(float* coords, int num_points) { + cogl_path_polyline(coords, num_points); +} + + +// Constructs a rectangular shape at the given coordinates. If there +// is an existing path this will start a new disjoint sub-path. +// : X coordinate of the top-left corner. +// : Y coordinate of the top-left corner. +// : X coordinate of the bottom-right corner. +// : Y coordinate of the bottom-right corner. +static void path_rectangle(float x_1, float y_1, float x_2, float y_2) { + cogl_path_rectangle(x_1, y_1, x_2, y_2); +} + + +// Adds a cubic bezier curve segment to the current path with the given +// second, third and fourth control points and using current pen location +// as the first control point. The given coordinates are relative to the +// current pen location. +// : X coordinate of the second bezier control point +// : Y coordinate of the second bezier control point +// : X coordinate of the third bezier control point +// : Y coordinate of the third bezier control point +// : X coordinate of the fourth bezier control point +// : Y coordinate of the fourth bezier control point +static void path_rel_curve_to(float x_1, float y_1, float x_2, float y_2, float x_3, float y_3) { + cogl_path_rel_curve_to(x_1, y_1, x_2, y_2, x_3, y_3); +} + + +// Adds a straight line segment to the current path that ends at the +// given coordinates relative to the current pen location. +// : X offset from the current pen location of the end line vertex +// : Y offset from the current pen location of the end line vertex +static void path_rel_line_to(float x, float y) { + cogl_path_rel_line_to(x, y); +} + + +// Moves the pen to the given offset relative to the current pen +// location. If there is an existing path this will start a new +// disjoint subpath. +// : X offset from the current pen location to move the pen to. +// : Y offset from the current pen location to move the pen to. +static void path_rel_move_to(float x, float y) { + cogl_path_rel_move_to(x, y); +} + + +// Constructs a rectangular shape with rounded corners. If there is an +// existing path this will start a new disjoint sub-path. +// : X coordinate of the top-left corner. +// : Y coordinate of the top-left corner. +// : X coordinate of the bottom-right corner. +// : Y coordinate of the bottom-right corner. +// : Radius of the corner arcs. +// : Angle increment resolution for subdivision of the corner arcs. +static void path_round_rectangle(float x_1, float y_1, float x_2, float y_2, float radius, float arc_step) { + cogl_path_round_rectangle(x_1, y_1, x_2, y_2, radius, arc_step); +} + + +// Sets the fill rule of the current path to @fill_rule. This will +// affect how the path is filled when cogl_path_fill() is later +// called. Note that the fill rule state is attached to the path so +// calling cogl_get_path() will preserve the fill rule and calling +// cogl_path_new() will reset the fill rule back to the default. +// : The new fill rule. +static void path_set_fill_rule(PathFillRule fill_rule) { + cogl_path_set_fill_rule(fill_rule); +} + + +// Strokes the constructed shape using the current drawing color and a +// width of 1 pixel (regardless of the current transformation +// matrix). To current path is then cleared. To use the path again, +// call cogl_path_stroke_preserve() instead. +static void path_stroke() { + cogl_path_stroke(); +} + + +// Strokes the constructed shape using the current drawing color and +// preserves the path to be used again. +static void path_stroke_preserve() { + cogl_path_stroke_preserve(); +} + + +// Replaces the current projection matrix with a perspective matrix +// based on the provided values. +// : Vertical of view angle in degrees. +// : Aspect ratio of diesplay +// : Nearest visible point +// : Furthest visible point along the z-axis +static void perspective(float fovy, float aspect, float z_near, float z_far) { + cogl_perspective(fovy, aspect, z_near, z_far); +} + + +// Draws a convex polygon using the current source material to fill / texture +// with according to the texture coordinates passed. +// +// If @use_color is %TRUE then the color will be changed for each vertex using +// the value specified in the color member of #CoglTextureVertex. This can be +// used for example to make the texture fade out by setting the alpha value of +// the color. +// +// All of the texture coordinates must be in the range [0,1] and repeating the +// texture is not supported. +// +// Because of the way this function is implemented it will currently +// only work if either the texture is not sliced or the backend is not +// OpenGL ES and the minifying and magnifying functions are both set +// to COGL_MATERIAL_FILTER_NEAREST. +// : An array of #CoglTextureVertex structs +// : The length of the vertices array +// : %TRUE if the color member of #CoglTextureVertex should be used +static void polygon(TextureVertex* vertices, uint n_vertices, int use_color) { + cogl_polygon(vertices, n_vertices, use_color); +} + +// Restore cogl_set_draw_buffer() state. +static void pop_draw_buffer() { + cogl_pop_draw_buffer(); +} + + +// Restores the framebuffer that was previously at the top of the stack. +// All subsequent drawing will be redirected to this framebuffer. +static void pop_framebuffer() { + cogl_pop_framebuffer(); +} + +// Restores the current model-view matrix from the matrix stack. +static void pop_matrix() { + cogl_pop_matrix(); +} + + +// Removes the material at the top of the source stack. The material +// at the top of this stack defines the GPU state used to process +// later primitives as defined by cogl_set_source(). +static void pop_source() { + cogl_pop_source(); +} + + +// Attaches a shader to a program object, a program can have one vertex shader +// and one fragment shader attached. +// : a #CoglHandle for a shdaer program. +// : a #CoglHandle for a vertex of fragment shader. +static void program_attach_shader(Handle program_handle, Handle shader_handle) { + cogl_program_attach_shader(program_handle, shader_handle); +} + + +// Retrieve the location (offset) of a uniform variable in a shader program, +// a uniform is a variable that is constant for all vertices/fragments for a +// shader object and is possible to modify as an external parameter. +// +// This uniform can be set using cogl_program_uniform_1f() when the +// program is in use. +// RETURNS: the offset of a uniform in a specified program. +// : a #CoglHandle for a shader program. +// : the name of a uniform. +static int program_get_uniform_location(Handle handle, char* uniform_name) { + return cogl_program_get_uniform_location(handle, uniform_name); +} + + +// Links a program making it ready for use. +// : a #CoglHandle for a shader program. +static void program_link(Handle handle) { + cogl_program_link(handle); +} + + +// Unintrospectable function: program_ref() / cogl_program_ref() +// Add an extra reference to a program. +// RETURNS: @handle +// : A #CoglHandle to a program. +static Handle program_ref(Handle handle) { + return cogl_program_ref(handle); +} + + +// Changes the value of a floating point uniform for the given linked +// @program. +// : A #CoglHandle for a linked program +// : the uniform location retrieved from cogl_program_get_uniform_location(). +// : the new value of the uniform. +static void program_set_uniform_1f(Handle program, int uniform_location, float value) { + cogl_program_set_uniform_1f(program, uniform_location, value); +} + + +// Changes the value of an integer uniform for the given linked +// @program. +// : A #CoglHandle for a linked program +// : the uniform location retrieved from cogl_program_get_uniform_location(). +// : the new value of the uniform. +static void program_set_uniform_1i(Handle program, int uniform_location, int value) { + cogl_program_set_uniform_1i(program, uniform_location, value); +} + + +// Changes the value of a float vector uniform, or uniform array for +// the given linked @program. +// : A #CoglHandle for a linked program +// : the uniform location retrieved from cogl_program_get_uniform_location(). +// : The number of components for the uniform. For example with glsl you'd use 3 for a vec3 or 4 for a vec4. +// : For uniform arrays this is the array length otherwise just pass 1 +// : the new value of the uniform[s]. +static void program_set_uniform_float(Handle program, int uniform_location, int n_components, int count, float* value) { + cogl_program_set_uniform_float(program, uniform_location, n_components, count, value); +} + + +// Changes the value of a int vector uniform, or uniform array for +// the given linked @program. +// : A #CoglHandle for a linked program +// : the uniform location retrieved from cogl_program_get_uniform_location(). +// : The number of components for the uniform. For example with glsl you'd use 3 for a vec3 or 4 for a vec4. +// : For uniform arrays this is the array length otherwise just pass 1 +// : the new value of the uniform[s]. +static void program_set_uniform_int(Handle program, int uniform_location, int n_components, int count, int* value) { + cogl_program_set_uniform_int(program, uniform_location, n_components, count, value); +} + + +// Changes the value of a matrix uniform, or uniform array in the +// given linked @program. +// : A #CoglHandle for a linked program +// : the uniform location retrieved from cogl_program_get_uniform_location(). +// : The dimensions of the matrix. So for for example pass 2 for a 2x2 matrix or 3 for 3x3. +// : For uniform arrays this is the array length otherwise just pass 1 +// : Whether to transpose the matrix when setting the uniform. +// : the new value of the uniform. +static void program_set_uniform_matrix(Handle program, int uniform_location, int dimensions, int count, int transpose, float* value) { + cogl_program_set_uniform_matrix(program, uniform_location, dimensions, count, transpose, value); +} + + +// Changes the value of a floating point uniform in the currently +// used (see cogl_program_use()) shader program. +// : the uniform to set. +// : the new value of the uniform. +static void program_uniform_1f(int uniform_no, float value) { + cogl_program_uniform_1f(uniform_no, value); +} + + +// Changes the value of an integer uniform in the currently +// used (see cogl_program_use()) shader program. +// : the uniform to set. +// : the new value of the uniform. +static void program_uniform_1i(int uniform_no, int value) { + cogl_program_uniform_1i(uniform_no, value); +} + + +// Changes the value of a float vector uniform, or uniform array in the +// currently used (see cogl_program_use()) shader program. +// : the uniform to set. +// : Size of float vector. +// : Size of array of uniforms. +// : the new value of the uniform. +static void program_uniform_float(int uniform_no, int size, int count, float* value) { + cogl_program_uniform_float(uniform_no, size, count, value); +} + + +// Changes the value of a int vector uniform, or uniform array in the +// currently used (see cogl_program_use()) shader program. +// : the uniform to set. +// : Size of int vector. +// : Size of array of uniforms. +// : the new value of the uniform. +static void program_uniform_int(int uniform_no, int size, int count, int* value) { + cogl_program_uniform_int(uniform_no, size, count, value); +} + + +// Changes the value of a matrix uniform, or uniform array in the +// currently used (see cogl_program_use()) shader program. The @size +// parameter is used to determine the square size of the matrix. +// : the uniform to set. +// : Size of matrix. +// : Size of array of uniforms. +// : Whether to transpose the matrix when setting the uniform. +// : the new value of the uniform. +static void program_uniform_matrix(int uniform_no, int size, int count, int transpose, float* value) { + cogl_program_uniform_matrix(uniform_no, size, count, transpose, value); +} + + +// Removes a reference to a program. If it was the last reference the +// program object will be destroyed. +// : A #CoglHandle to a program. +static void program_unref(Handle handle) { + cogl_program_unref(handle); +} + + +// Activate a specific shader program replacing that part of the GL +// rendering pipeline, if passed in %COGL_INVALID_HANDLE the default +// behavior of GL is reinstated. +// : a #CoglHandle for a shader program or %COGL_INVALID_HANDLE. +static void program_use(Handle handle) { + cogl_program_use(handle); +} + +// Save cogl_set_draw_buffer() state. +static void push_draw_buffer() { + cogl_push_draw_buffer(); +} + + +// Redirects all subsequent drawing to the specified framebuffer. This can +// either be an offscreen buffer created with cogl_offscreen_new_to_texture () +// or in the future it may be an onscreen framebuffer too. +// +// You should understand that a framebuffer owns the following state: +// +// The projection matrix +// The modelview matrix stack +// The viewport +// The clip stack +// +// So these items will automatically be saved and restored when you +// push and pop between different framebuffers. +// +// Also remember a newly allocated framebuffer will have an identity matrix for +// the projection and modelview matrices which gives you a coordinate space +// like OpenGL with (-1, -1) corresponding to the top left of the viewport, +// (1, 1) corresponding to the bottom right and +z coming out towards the +// viewer. +// +// If you want to set up a coordinate space like Clutter does with (0, 0) +// corresponding to the top left and (framebuffer_width, framebuffer_height) +// corresponding to the bottom right you can do so like this: +// +// |[ +// static void +// setup_viewport (unsigned int width, +// unsigned int height, +// float fovy, +// float aspect, +// float z_near, +// float z_far) +// { +// float z_camera; +// CoglMatrix projection_matrix; +// CoglMatrix mv_matrix; +// +// cogl_set_viewport (0, 0, width, height); +// cogl_perspective (fovy, aspect, z_near, z_far); +// +// cogl_get_projection_matrix (&projection_matrix); +// z_camera = 0.5 * projection_matrix.xx; +// +// cogl_matrix_init_identity (&mv_matrix); +// cogl_matrix_translate (&mv_matrix, -0.5f, -0.5f, -z_camera); +// cogl_matrix_scale (&mv_matrix, 1.0f / width, -1.0f / height, 1.0f / width); +// cogl_matrix_translate (&mv_matrix, 0.0f, -1.0 * height, 0.0f); +// cogl_set_modelview_matrix (&mv_matrix); +// } +// +// static void +// my_init_framebuffer (ClutterStage *stage, +// CoglFramebuffer *framebuffer, +// unsigned int framebuffer_width, +// unsigned int framebuffer_height) +// { +// ClutterPerspective perspective; +// +// clutter_stage_get_perspective (stage, &perspective); +// +// cogl_push_framebuffer (framebuffer); +// setup_viewport (framebuffer_width, +// framebuffer_height, +// perspective.fovy, +// perspective.aspect, +// perspective.z_near, +// perspective.z_far); +// } +// ]| +// +// The previous framebuffer can be restored by calling cogl_pop_framebuffer() +// : A #CoglFramebuffer object, either onscreen or offscreen. +static void push_framebuffer(Framebuffer* buffer) { + cogl_push_framebuffer(buffer); +} + + +// Stores the current model-view matrix on the matrix stack. The matrix +// can later be restored with cogl_pop_matrix(). +static void push_matrix() { + cogl_push_matrix(); +} + + +// Pushes the given @material to the top of the source stack. The +// material at the top of this stack defines the GPU state used to +// process later primitives as defined by cogl_set_source(). +// : A #CoglMaterial +static void push_source(void* material) { + cogl_push_source(material); +} + + +// Compares that all the components of quaternions @a and @b are +// equal. +// +// An epsilon value is not used to compare the float components, but +// the == operator is at least used so that 0 and -0 are considered +// equal. +// RETURNS: %TRUE if the quaternions are equal else %FALSE. +// : A #CoglQuaternion +// : A #CoglQuaternion +static int quaternion_equal(const(void)* v1, const(void)* v2) { + return cogl_quaternion_equal(v1, v2); +} + + +// This reads a rectangle of pixels from the current framebuffer where +// position (0, 0) is the top left. The pixel at (x, y) is the first +// read, and the data is returned with a rowstride of (width * 4). +// +// Currently Cogl assumes that the framebuffer is in a premultiplied +// format so if @format is non-premultiplied it will convert it. To +// read the pixel values without any conversion you should either +// specify a format that doesn't use an alpha channel or use one of +// the formats ending in PRE. +// : The window x position to start reading from +// : The window y position to start reading from +// : The width of the rectangle you want to read +// : The height of the rectangle you want to read +// : Identifies which auxillary buffer you want to read (only COGL_READ_PIXELS_COLOR_BUFFER supported currently) +// : The pixel format you want the result in (only COGL_PIXEL_FORMAT_RGBA_8888 supported currently) +// : The location to write the pixel data. +static void read_pixels(int x, int y, int width, int height, ReadPixelsFlags source, PixelFormat format, ubyte* pixels) { + cogl_read_pixels(x, y, width, height, source, format, pixels); +} + + +// Fills a rectangle at the given coordinates with the current source material +// : X coordinate of the top-left corner +// : Y coordinate of the top-left corner +// : X coordinate of the bottom-right corner +// : Y coordinate of the bottom-right corner +static void rectangle(float x_1, float y_1, float x_2, float y_2) { + cogl_rectangle(x_1, y_1, x_2, y_2); +} + + +// This function draws a rectangle using the current source material to +// texture or fill with. As a material may contain multiple texture layers +// this interface lets you supply texture coordinates for each layer of the +// material. +// +// The first pair of coordinates are for the first layer (with the smallest +// layer index) and if you supply less texture coordinates than there are +// layers in the current source material then default texture coordinates +// (0.0, 0.0, 1.0, 1.0) are generated. +// : x coordinate upper left on screen. +// : y coordinate upper left on screen. +// : x coordinate lower right on screen. +// : y coordinate lower right on screen. +// : 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. +// : The length of the tex_coords array. (e.g. for one layer and one group of texture coordinates, this would be 4) +static void rectangle_with_multitexture_coords(float x1, float y1, float x2, float y2, float* tex_coords, int tex_coords_len) { + cogl_rectangle_with_multitexture_coords(x1, y1, x2, y2, tex_coords, tex_coords_len); +} + + +// Draw a rectangle using the current material and supply texture coordinates +// to be used for the first texture layer of the material. To draw the entire +// texture pass in @tx1=0.0 @ty1=0.0 @tx2=1.0 @ty2=1.0. +// : x coordinate upper left on screen. +// : y coordinate upper left on screen. +// : x coordinate lower right on screen. +// : y coordinate lower right on screen. +// : x part of texture coordinate to use for upper left pixel +// : y part of texture coordinate to use for upper left pixel +// : x part of texture coordinate to use for lower right pixel +// : y part of texture coordinate to use for left pixel +static void rectangle_with_texture_coords(float x1, float y1, float x2, float y2, float tx1, float ty1, float tx2, float ty2) { + cogl_rectangle_with_texture_coords(x1, y1, x2, y2, tx1, ty1, tx2, ty2); +} + + +// Draws a series of rectangles in the same way that +// cogl_rectangle() does. In some situations it can give a +// significant performance boost to use this function rather than +// calling cogl_rectangle() separately for each rectangle. +// +// @verts should point to an array of #floats with +// @n_rects * 4 elements. Each group of 4 values corresponds to the +// parameters x1, y1, x2, and y2, and have the same +// meaning as in cogl_rectangle(). +// : an array of vertices +// : number of rectangles to draw +static void rectangles(float* verts, uint n_rects) { + cogl_rectangles(verts, n_rects); +} + + +// Draws a series of rectangles in the same way that +// cogl_rectangle_with_texture_coords() does. In some situations it can give a +// significant performance boost to use this function rather than +// calling cogl_rectangle_with_texture_coords() separately for each rectangle. +// +// @verts should point to an array of #floats with +// @n_rects * 8 elements. Each group of 8 values corresponds to the +// parameters x1, y1, x2, y2, tx1, ty1, tx2 and ty2 and have the same +// meaning as in cogl_rectangle_with_texture_coords(). +// : an array of vertices +// : number of rectangles to draw +static void rectangles_with_texture_coords(float* verts, uint n_rects) { + cogl_rectangles_with_texture_coords(verts, n_rects); +} + + +// Multiplies the current model-view matrix by one that rotates the +// model around the vertex specified by @x, @y and @z. The rotation +// follows the right-hand thumb rule so for example rotating by 10 +// degrees about the vertex (0, 0, 1) causes a small counter-clockwise +// rotation. +// : Angle in degrees to rotate. +// : X-component of vertex to rotate around. +// : Y-component of vertex to rotate around. +// : Z-component of vertex to rotate around. +static void rotate(float angle, float x, float y, float z) { + cogl_rotate(angle, x, y, z); +} + + +// Multiplies the current model-view matrix by one that scales the x, +// y and z axes by the given values. +// : Amount to scale along the x-axis +// : Amount to scale along the y-axis +// : Amount to scale along the z-axis +static void scale(float x, float y, float z) { + cogl_scale(x, y, z); +} + + +// Sets whether textures positioned so that their backface is showing +// should be hidden. This can be used to efficiently draw two-sided +// textures or fully closed cubes without enabling depth testing. This +// only affects calls to the cogl_rectangle* family of functions and +// cogl_vertex_buffer_draw*. Backface culling is disabled by default. +// : %TRUE to enable backface culling or %FALSE to disable. +static void set_backface_culling_enabled(int setting) { + cogl_set_backface_culling_enabled(setting); +} + + +// Sets whether depth testing is enabled. If it is disabled then the +// order that actors are layered on the screen depends solely on the +// order specified using clutter_actor_raise() and +// clutter_actor_lower(), otherwise it will also take into account the +// actor's depth. Depth testing is disabled by default. +// +// instead. +// : %TRUE to enable depth testing or %FALSE to disable. +static void set_depth_test_enabled(int setting) { + cogl_set_depth_test_enabled(setting); +} + + +// Redirects all subsequent drawing to the specified framebuffer. This +// can either be an offscreen buffer created with +// cogl_offscreen_new_to_texture () or you can revert to your original +// on screen window buffer. +// +// the type of CoglHandle given instead. +// : A #CoglBufferTarget that specifies what kind of framebuffer you are setting as the render target. +// : If you are setting a framebuffer of type COGL_OFFSCREEN_BUFFER then this is a CoglHandle for the offscreen buffer. +static void set_draw_buffer(BufferTarget target, Handle offscreen) { + cogl_set_draw_buffer(target, offscreen); +} + + +// Enables fogging. Fogging causes vertices that are further away from the eye +// to be rendered with a different color. The color is determined according to +// the chosen fog mode; at it's simplest the color is linearly interpolated so +// that vertices at @z_near are drawn fully with their original color and +// vertices at @z_far are drawn fully with @fog_color. Fogging will remain +// enabled until you call cogl_disable_fog(). +// +// The fogging functions only work correctly when primitives use +// unmultiplied alpha colors. By default Cogl will premultiply textures +// and cogl_set_source_color() will premultiply colors, so unless you +// explicitly load your textures requesting an unmultiplied internal format +// and use cogl_material_set_color() you can only use fogging with fully +// opaque primitives. This might improve in the future when we can depend +// on fragment shaders. +// : The color of the fog +// : A #CoglFogMode that determines the equation used to calculate the fogging blend factor. +// : Used by %COGL_FOG_MODE_EXPONENTIAL and by %COGL_FOG_MODE_EXPONENTIAL_SQUARED equations. +// : Position along Z axis where no fogging should be applied +// : Position along Z axis where full fogging should be applied +static void set_fog(Color* fog_color, FogMode mode, float density, float z_near, float z_far) { + cogl_set_fog(fog_color, mode, density, z_near, z_far); +} + + +// This redirects all subsequent drawing to the specified framebuffer. This can +// either be an offscreen buffer created with cogl_offscreen_new_to_texture () +// or in the future it may be an onscreen framebuffers too. +// : A #CoglFramebuffer object, either onscreen or offscreen. +static void set_framebuffer(Framebuffer* buffer) { + cogl_set_framebuffer(buffer); +} + + +// Loads @matrix as the new model-view matrix. +// : the new model-view matrix +static void set_modelview_matrix(Matrix* matrix) { + cogl_set_modelview_matrix(matrix); +} + + +// Unintrospectable function: set_path() / cogl_set_path() +// Replaces the current path with @path. A reference is taken on the +// object so if you no longer need the path you should unref with +// cogl_object_unref(). +// : A #CoglPath object +static void set_path(Path* path) { + cogl_set_path(path); +} + + +// Loads matrix as the new projection matrix. +// : the new projection matrix +static void set_projection_matrix(Matrix* matrix) { + cogl_set_projection_matrix(matrix); +} + + +// This function changes the material at the top of the source stack. +// The material at the top of this stack defines the GPU state used to +// process subsequent primitives, such as rectangles drawn with +// cogl_rectangle() or vertices drawn using cogl_vertex_buffer_draw(). +// : A #CoglMaterial +static void set_source(void* material) { + cogl_set_source(material); +} + + +// This is a convenience function for creating a solid fill source material +// from the given color. This color will be used for any subsequent drawing +// operation. +// +// The color will be premultiplied by Cogl, so the color should be +// non-premultiplied. For example: use (1.0, 0.0, 0.0, 0.5) for +// semi-transparent red. +// +// See also cogl_set_source_color4ub() and cogl_set_source_color4f() +// if you already have the color components. +// : a #CoglColor +static void set_source_color(Color* color) { + cogl_set_source_color(color); +} + + +// This is a convenience function for creating a solid fill source material +// from the given color using normalized values for each component. This color +// will be used for any subsequent drawing operation. +// +// The value for each component is a fixed point number in the range +// between 0 and %1.0. If the values passed in are outside that +// range, they will be clamped. +// : value of the red channel, between 0 and %1.0 +// : value of the green channel, between 0 and %1.0 +// : value of the blue channel, between 0 and %1.0 +// : value of the alpha channel, between 0 and %1.0 +static void set_source_color4f(float red, float green, float blue, float alpha) { + cogl_set_source_color4f(red, green, blue, alpha); +} + + +// This is a convenience function for creating a solid fill source material +// from the given color using unsigned bytes for each component. This +// color will be used for any subsequent drawing operation. +// +// The value for each component is an unsigned byte in the range +// between 0 and 255. +// : value of the red channel, between 0 and 255 +// : value of the green channel, between 0 and 255 +// : value of the blue channel, between 0 and 255 +// : value of the alpha channel, between 0 and 255 +static void set_source_color4ub(ubyte red, ubyte green, ubyte blue, ubyte alpha) { + cogl_set_source_color4ub(red, green, blue, alpha); +} + + +// This is a convenience function for creating a material with the first +// layer set to #texture_handle and setting that material as the source with +// cogl_set_source. +// +// Note: There is no interaction between calls to cogl_set_source_color +// and cogl_set_source_texture. If you need to blend a texture with a color then +// you can create a simple material like this: +// +// material = cogl_material_new (); +// cogl_material_set_color4ub (material, 0xff, 0x00, 0x00, 0x80); +// cogl_material_set_layer (material, 0, tex_handle); +// cogl_set_source (material); +// +// : The Cogl texture you want as your source +static void set_source_texture(Handle texture_handle) { + cogl_set_source_texture(texture_handle); +} + + +// Replaces the current viewport with the given values. +// : X offset of the viewport +// : Y offset of the viewport +// : Width of the viewport +// : Height of the viewport +static void set_viewport(int x, int y, int width, int height) { + cogl_set_viewport(x, y, width, height); +} + + +// Compiles the shader, no return value, but the shader is now ready for +// linking into a program. +// : #CoglHandle for a shader. +static void shader_compile(Handle handle) { + cogl_shader_compile(handle); +} + + +// Retrieves the information log for a coglobject, can be used in conjunction +// with cogl_shader_get_parameteriv() to retrieve the compiler warnings/error +// messages that caused a shader to not compile correctly, mainly useful for +// debugging purposes. +// +// g_free() to free it +// RETURNS: a newly allocated string containing the info log. Use +// : #CoglHandle for a shader. +static char* /*new*/ shader_get_info_log(Handle handle) { + return cogl_shader_get_info_log(handle); +} + + +// Retrieves the type of a shader #CoglHandle +// +// or %COGL_SHADER_TYPE_FRAGMENT if the shader is a frament processor +// RETURNS: %COGL_SHADER_TYPE_VERTEX if the shader is a vertex processor +// : #CoglHandle for a shader. +static ShaderType shader_get_type(Handle handle) { + return cogl_shader_get_type(handle); +} + + +// Retrieves whether a shader #CoglHandle has been compiled +// RETURNS: %TRUE if the shader object has sucessfully be compiled +// : #CoglHandle for a shader. +static int shader_is_compiled(Handle handle) { + return cogl_shader_is_compiled(handle); +} + + +// Unintrospectable function: shader_ref() / cogl_shader_ref() +// Add an extra reference to a shader. +// RETURNS: @handle +// : A #CoglHandle to a shader. +static Handle shader_ref(Handle handle) { + return cogl_shader_ref(handle); +} + + +// Replaces the current GLSL source associated with a shader with a new +// one. +// : #CoglHandle for a shader. +// : GLSL shader source. +static void shader_source(Handle shader, char* source) { + cogl_shader_source(shader, source); +} + + +// Removes a reference to a shader. If it was the last reference the +// shader object will be destroyed. +// : A #CoglHandle to a shader. +static void shader_unref(Handle handle) { + cogl_shader_unref(handle); +} + + +// Very fast fixed point implementation of square root for integers. +// +// This function is at least 6x faster than clib sqrt() on x86, and (this is +// not a typo!) about 500x faster on ARM without FPU. It's error is less than +// 5% for arguments smaller than %COGL_SQRTI_ARG_5_PERCENT and less than 10% +// for narguments smaller than %COGL_SQRTI_ARG_10_PERCENT. The maximum +// argument that can be passed to this function is %COGL_SQRTI_ARG_MAX. +// RETURNS: integer square root. +// : integer value +static int sqrti(int x) { + return cogl_sqrti(x); +} + +// Unintrospectable function: texture_2d_new_from_data_EXP() / cogl_texture_2d_new_from_data_EXP() +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) { + return cogl_texture_2d_new_from_data_EXP(ctx, width, height, format, internal_format, rowstride, data, error); +} + +// Unintrospectable function: texture_2d_new_from_foreign_EXP() / cogl_texture_2d_new_from_foreign_EXP() +static Texture2D* texture_2d_new_from_foreign_EXP(CoglContext* ctx, uint gl_handle, int width, int height, PixelFormat format, GLib2.Error** error=null) { + return cogl_texture_2d_new_from_foreign_EXP(ctx, gl_handle, width, height, format, error); +} + +// Unintrospectable function: texture_2d_new_with_size_EXP() / cogl_texture_2d_new_with_size_EXP() +static Texture2D* texture_2d_new_with_size_EXP(CoglContext* ctx, int width, int height, PixelFormat internal_format, GLib2.Error** error=null) { + return cogl_texture_2d_new_with_size_EXP(ctx, width, height, internal_format, error); +} + +// Unintrospectable function: texture_3d_new_from_data_EXP() / cogl_texture_3d_new_from_data_EXP() +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) { + return cogl_texture_3d_new_from_data_EXP(width, height, depth, flags, format, internal_format, rowstride, image_stride, data, error); +} + +// Unintrospectable function: texture_3d_new_with_size_EXP() / cogl_texture_3d_new_with_size_EXP() +static Handle texture_3d_new_with_size_EXP(uint width, uint height, uint depth, TextureFlags flags, PixelFormat internal_format, GLib2.Error** error=null) { + return cogl_texture_3d_new_with_size_EXP(width, height, depth, flags, internal_format, error); +} + +static GLib2.Quark texture_error_quark() { + return cogl_texture_error_quark(); +} + + +// Copies the pixel data from a cogl texture to system memory. +// +// is not valid +// RETURNS: the size of the texture data in bytes, or 0 if the texture +// : a #CoglHandle for a texture. +// : the #CoglPixelFormat to store the texture as. +// : the rowstride of @data or retrieved from texture if none is specified. +// : memory location to write contents of buffer, or %NULL if we're only querying the data size through the return value. +static int texture_get_data(Handle handle, PixelFormat format, uint rowstride, ubyte* data) { + return cogl_texture_get_data(handle, format, rowstride, data); +} + + +// Queries the #CoglPixelFormat of a cogl texture. +// RETURNS: the #CoglPixelFormat of the GPU side texture +// : a #CoglHandle for a texture. +static PixelFormat texture_get_format(Handle handle) { + return cogl_texture_get_format(handle); +} + + +// Queries the GL handles for a GPU side texture through its #CoglHandle. +// +// If the texture is spliced the data for the first sub texture will be +// queried. +// +// if the handle was invalid +// RETURNS: %TRUE if the handle was successfully retrieved, %FALSE +// : a #CoglHandle for a texture. +// : pointer to return location for the textures GL handle, or %NULL. +// : pointer to return location for the GL target type, or %NULL. +static int texture_get_gl_texture(Handle handle, /*out*/ GL.uint* out_gl_handle=null, /*out*/ GL.enum* out_gl_target=null) { + return cogl_texture_get_gl_texture(handle, out_gl_handle, out_gl_target); +} + + +// Queries the height of a cogl texture. +// RETURNS: the height of the GPU side texture in pixels +// : a #CoglHandle for a texture. +static uint texture_get_height(Handle handle) { + return cogl_texture_get_height(handle); +} + + +// Queries the maximum wasted (unused) pixels in one dimension of a GPU side +// texture. +// RETURNS: the maximum waste +// : a #CoglHandle for a texture. +static int texture_get_max_waste(Handle handle) { + return cogl_texture_get_max_waste(handle); +} + + +// Queries the rowstride of a cogl texture. +// RETURNS: the offset in bytes between each consequetive row of pixels +// : a #CoglHandle for a texture. +static uint texture_get_rowstride(Handle handle) { + return cogl_texture_get_rowstride(handle); +} + + +// Queries the width of a cogl texture. +// RETURNS: the width of the GPU side texture in pixels +// : a #CoglHandle for a texture. +static uint texture_get_width(Handle handle) { + return cogl_texture_get_width(handle); +} + + +// Queries if a texture is sliced (stored as multiple GPU side tecture +// objects). +// +// is stored as a single GPU texture +// RETURNS: %TRUE if the texture is sliced, %FALSE if the texture +// : a #CoglHandle for a texture. +static int texture_is_sliced(Handle handle) { + return cogl_texture_is_sliced(handle); +} + + +// Unintrospectable function: texture_new_from_bitmap() / cogl_texture_new_from_bitmap() +// Creates a COGL texture from a CoglBitmap. +// +// %COGL_INVALID_HANDLE on failure +// RETURNS: a #CoglHandle to the newly created texture or +// : A CoglBitmap handle +// : Optional flags for the texture, or %COGL_TEXTURE_NONE +// : the #CoglPixelFormat to use for the GPU storage of the texture +static Handle texture_new_from_bitmap(Handle bmp_handle, TextureFlags flags, PixelFormat internal_format) { + return cogl_texture_new_from_bitmap(bmp_handle, flags, internal_format); +} + + +// Unintrospectable function: texture_new_from_data() / cogl_texture_new_from_data() +// Creates a new COGL texture based on data residing in memory. +// +// %COGL_INVALID_HANDLE on failure +// RETURNS: a #CoglHandle to the newly created texture or +// : width of texture in pixels +// : height of texture in pixels +// : Optional flags for the texture, or %COGL_TEXTURE_NONE +// : the #CoglPixelFormat the buffer is stored in in RAM +// : 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. +// : the memory offset in bytes between the starts of scanlines in @data +// : pointer the memory region where the source buffer resides +static Handle texture_new_from_data(uint width, uint height, TextureFlags flags, PixelFormat format, PixelFormat internal_format, uint rowstride, ubyte* data) { + return cogl_texture_new_from_data(width, height, flags, format, internal_format, rowstride, data); +} + + +// Unintrospectable function: texture_new_from_file() / cogl_texture_new_from_file() +// Creates a COGL texture from an image file. +// +// %COGL_INVALID_HANDLE on failure +// RETURNS: a #CoglHandle to the newly created texture or +// : the file to load +// : Optional flags for the texture, or %COGL_TEXTURE_NONE +// : 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. +static Handle texture_new_from_file(char* filename, TextureFlags flags, PixelFormat internal_format, GLib2.Error** error=null) { + return cogl_texture_new_from_file(filename, flags, internal_format, error); +} + + +// Unintrospectable function: texture_new_from_foreign() / cogl_texture_new_from_foreign() +// Creates a COGL texture based on an existing OpenGL texture; the +// width, height and format are passed along since it is not always +// possible to query these from OpenGL. +// +// The waste arguments allow you to create a Cogl texture that maps to +// a region smaller than the real OpenGL texture. For instance if your +// hardware only supports power-of-two textures you may load a +// non-power-of-two image into a larger power-of-two texture and use +// the waste arguments to tell Cogl which region should be mapped to +// the texture coordinate range [0:1]. +// +// %COGL_INVALID_HANDLE on failure +// RETURNS: a #CoglHandle to the newly created texture or +// : opengl handle of foreign texture. +// : opengl target type of foreign texture +// : width of foreign texture +// : height of foreign texture. +// : horizontal waste on the right hand edge of the texture. +// : vertical waste on the bottom edge of the texture. +// : format of the foreign texture. +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) { + return cogl_texture_new_from_foreign(gl_handle, gl_target, width, height, x_pot_waste, y_pot_waste, format); +} + + +// Unintrospectable function: texture_new_from_sub_texture() / cogl_texture_new_from_sub_texture() +// Creates a new texture which represents a subregion of another +// texture. The GL resources will be shared so that no new texture +// data is actually allocated. +// +// Sub textures have undefined behaviour texture coordinates outside +// of the range [0,1] are used. They also do not work with +// CoglVertexBuffers. +// +// The sub texture will keep a reference to the full texture so you do +// not need to keep one separately if you only want to use the sub +// texture. +// RETURNS: a #CoglHandle to the new texture. +// : a #CoglHandle to an existing texture +// : X coordinate of the top-left of the subregion +// : Y coordinate of the top-left of the subregion +// : Width in pixels of the subregion +// : Height in pixels of the subregion +static Handle texture_new_from_sub_texture(Handle full_texture, int sub_x, int sub_y, int sub_width, int sub_height) { + return cogl_texture_new_from_sub_texture(full_texture, sub_x, sub_y, sub_width, sub_height); +} + + +// Unintrospectable function: texture_new_with_size() / cogl_texture_new_with_size() +// Creates a new COGL texture with the specified dimensions and pixel format. +// +// %COGL_INVALID_HANDLE on failure +// RETURNS: a #CoglHandle to the newly created texture or +// : width of texture in pixels. +// : height of texture in pixels. +// : Optional flags for the texture, or %COGL_TEXTURE_NONE +// : the #CoglPixelFormat to use for the GPU storage of the texture. +static Handle texture_new_with_size(uint width, uint height, TextureFlags flags, PixelFormat internal_format) { + return cogl_texture_new_with_size(width, height, flags, internal_format); +} + + +// Unintrospectable function: texture_ref() / cogl_texture_ref() +// Increment the reference count for a cogl texture. +// RETURNS: the @handle. +// : a @CoglHandle. +static Handle texture_ref(Handle handle) { + return cogl_texture_ref(handle); +} + + +// Sets the pixels in a rectangular subregion of @handle from an in-memory +// buffer containing pixel data. +// +// %FALSE otherwise +// RETURNS: %TRUE if the subregion upload was successful, and +// : a #CoglHandle. +// : upper left coordinate to use from source data. +// : upper left coordinate to use from source data. +// : upper left destination horizontal coordinate. +// : upper left destination vertical coordinate. +// : width of destination region to write. +// : height of destination region to write. +// : width of source data buffer. +// : height of source data buffer. +// : the #CoglPixelFormat used in the source buffer. +// : rowstride of source buffer (computed from width if none specified) +// : the actual pixel data. +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) { + return cogl_texture_set_region(handle, src_x, src_y, dst_x, dst_y, dst_width, dst_height, width, height, format, rowstride, data); +} + + +// Decrement the reference count for a cogl texture. +// : a @CoglHandle. +static void texture_unref(Handle handle) { + cogl_texture_unref(handle); +} + + +// Multiplies the current model-view matrix by the given matrix. +// : the matrix to multiply with the current model-view +static void transform(Matrix* matrix) { + cogl_transform(matrix); +} + + +// Multiplies the current model-view matrix by one that translates the +// model along all three axes according to the given values. +// : Distance to translate along the x-axis +// : Distance to translate along the y-axis +// : Distance to translate along the z-axis +static void translate(float x, float y, float z) { + cogl_translate(x, y, z); +} + +// Unintrospectable function: vdraw_attributes() / cogl_vdraw_attributes() +alias cogl_vdraw_attributes vdraw_attributes; // Variadic + +// Unintrospectable function: vdraw_indexed_attributes() / cogl_vdraw_indexed_attributes() +alias cogl_vdraw_indexed_attributes vdraw_indexed_attributes; // Variadic + +static int vector3_equal_EXP(const(void)* v1, const(void)* v2) { + return cogl_vector3_equal_EXP(v1, v2); +} + + +// Adds an attribute to a buffer, or replaces a previously added +// attribute with the same name. +// +// You either can use one of the built-in names such as "gl_Vertex", or +// "gl_MultiTexCoord0" to add standard attributes, like positions, colors +// and normals, or you can add custom attributes for use in shaders. +// +// The number of vertices declared when calling cogl_vertex_buffer_new() +// determines how many attribute values will be read from the supplied +// @pointer. +// +// The data for your attribute isn't copied anywhere until you call +// cogl_vertex_buffer_submit(), or issue a draw call which automatically +// submits pending attribute changes. so the supplied pointer must remain +// valid until then. If you are updating an existing attribute (done by +// re-adding it) then you still need to re-call cogl_vertex_buffer_submit() +// to commit the changes to the GPU. Be carefull to minimize the number +// of calls to cogl_vertex_buffer_submit(), though. +// +// If you are interleving attributes it is assumed that each interleaved +// attribute starts no farther than +- stride bytes from the other attributes +// it is interleved with. I.e. this is ok: +// +// |-0-0-0-0-0-0-0-0-0-0| +// +// This is not ok: +// +// |- - - - -0-0-0-0-0-0 0 0 0 0| +// +// (Though you can have multiple groups of interleved attributes) +// : A vertex buffer handle +// : 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) "gl_Color" "gl_Normal" "gl_MultiTexCoord0, gl_MultiTexCoord1, ..." "gl_Vertex" 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" +// : The number of components per attribute and must be 1, 2, 3 or 4 +// : a #CoglAttributeType specifying the data type of each component. +// : 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. +// : 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. +// : 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. +static void vertex_buffer_add(Handle handle, char* attribute_name, ubyte n_components, AttributeType type, int normalized, ushort stride, void* pointer) { + cogl_vertex_buffer_add(handle, attribute_name, n_components, type, normalized, stride, pointer); +} + + +// Deletes an attribute from a buffer. You will need to call +// cogl_vertex_buffer_submit() or issue a draw call to commit this +// change to the GPU. +// : A vertex buffer handle +// : The name of a previously added attribute +static void vertex_buffer_delete(Handle handle, char* attribute_name) { + cogl_vertex_buffer_delete(handle, attribute_name); +} + + +// Disables a previosuly added attribute. +// +// Since it can be costly to add and remove new attributes to buffers; to make +// individual buffers more reuseable it is possible to enable and disable +// attributes before using a buffer for drawing. +// +// You don't need to call cogl_vertex_buffer_submit() after using this +// function. +// : A vertex buffer handle +// : The name of the attribute you want to disable +static void vertex_buffer_disable(Handle handle, char* attribute_name) { + cogl_vertex_buffer_disable(handle, attribute_name); +} + + +// Allows you to draw geometry using all or a subset of the +// vertices in a vertex buffer. +// +// Any un-submitted attribute changes are automatically submitted before +// drawing. +// : A vertex buffer handle +// : A #CoglVerticesMode specifying how the vertices should be interpreted. +// : Specifies the index of the first vertex you want to draw with +// : Specifies the number of vertices you want to draw. +static void vertex_buffer_draw(Handle handle, VerticesMode mode, int first, int count) { + cogl_vertex_buffer_draw(handle, mode, first, count); +} + + +// This function lets you use an array of indices to specify the vertices +// within your vertex buffer that you want to draw. The indices themselves +// are created by calling cogl_vertex_buffer_indices_new () +// +// Any un-submitted attribute changes are automatically submitted before +// drawing. +// : A vertex buffer handle +// : A #CoglVerticesMode specifying how the vertices should be interpreted. +// : A CoglHandle for a set of indices allocated via cogl_vertex_buffer_indices_new () +// : Specifies the minimum vertex index contained in indices +// : Specifies the maximum vertex index contained in indices +// : An offset into named indices. The offset marks the first index to use for drawing. +// : Specifies the number of vertices you want to draw. +static void vertex_buffer_draw_elements(Handle handle, VerticesMode mode, Handle indices, int min_index, int max_index, int indices_offset, int count) { + cogl_vertex_buffer_draw_elements(handle, mode, indices, min_index, max_index, indices_offset, count); +} + + +// Enables a previosuly disabled attribute. +// +// Since it can be costly to add and remove new attributes to buffers; to make +// individual buffers more reuseable it is possible to enable and disable +// attributes before using a buffer for drawing. +// +// You don't need to call cogl_vertex_buffer_submit() after using this function +// : A vertex buffer handle +// : The name of the attribute you want to enable +static void vertex_buffer_enable(Handle handle, char* attribute_name) { + cogl_vertex_buffer_enable(handle, attribute_name); +} + + +// Retrieves the number of vertices that @handle represents +// RETURNS: the number of vertices +// : A vertex buffer handle +static uint vertex_buffer_get_n_vertices(Handle handle) { + return cogl_vertex_buffer_get_n_vertices(handle); +} + + +// Unintrospectable function: vertex_buffer_indices_get_for_quads() / cogl_vertex_buffer_indices_get_for_quads() +// Creates a vertex buffer containing the indices needed to draw pairs +// of triangles from a list of vertices grouped as quads. There will +// be at least @n_indices entries in the buffer (but there may be +// more). +// +// The indices will follow this pattern: +// +// 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7 ... etc +// +// For example, if you submit vertices for a quad like like that shown +// in then you can request 6 +// indices to render two triangles like those shown in . +// +//
+// Example of vertices submitted to form a quad +// +//
+// +//
+// Illustration of the triangle indices that will be generated +// +//
+// +// owned by Cogl and should not be modified or unref'd. +// RETURNS: A %CoglHandle containing the indices. The handled is +// : the number of indices in the vertex buffer. +static Handle vertex_buffer_indices_get_for_quads(uint n_indices) { + return cogl_vertex_buffer_indices_get_for_quads(n_indices); +} + + +// Queries back the data type used for the given indices +// RETURNS: The CoglIndicesType used +// : An indices handle +static IndicesType vertex_buffer_indices_get_type(Handle indices) { + return cogl_vertex_buffer_indices_get_type(indices); +} + + +// Unintrospectable function: vertex_buffer_indices_new() / cogl_vertex_buffer_indices_new() +// Depending on how much geometry you are submitting it can be worthwhile +// optimizing the number of redundant vertices you submit. Using an index +// array allows you to reference vertices multiple times, for example +// during triangle strips. +// +// cogl_vertex_buffer_draw_elements(). +// RETURNS: A CoglHandle for the indices which you can pass to +// : a #CoglIndicesType specifying the data type used for the indices. +// : Specifies the address of your array of indices +// : The number of indices in indices_array +static Handle vertex_buffer_indices_new(IndicesType indices_type, void* indices_array, int indices_len) { + return cogl_vertex_buffer_indices_new(indices_type, indices_array, indices_len); +} + + +// Unintrospectable function: vertex_buffer_new() / cogl_vertex_buffer_new() +// Creates a new vertex buffer that you can use to add attributes. +// RETURNS: a new #CoglHandle +// : The number of vertices that your attributes will correspond to. +static Handle vertex_buffer_new(uint n_vertices) { + return cogl_vertex_buffer_new(n_vertices); +} + + +// Unintrospectable function: vertex_buffer_ref() / cogl_vertex_buffer_ref() +// Increment the reference count for a vertex buffer +// RETURNS: the @handle. +// : a @CoglHandle. +static Handle vertex_buffer_ref(Handle handle) { + return cogl_vertex_buffer_ref(handle); +} + + +// Submits all the user added attributes to the GPU; once submitted, the +// attributes can be used for drawing. +// +// You should aim to minimize calls to this function since it implies +// validating your data; it potentially incurs a transport cost (especially if +// you are using GLX indirect rendering) and potentially a format conversion +// cost if the GPU doesn't natively support any of the given attribute formats. +// : A vertex buffer handle +static void vertex_buffer_submit(Handle handle) { + cogl_vertex_buffer_submit(handle); +} + + +// Decrement the reference count for a vertex buffer +// : a @CoglHandle. +static void vertex_buffer_unref(Handle handle) { + cogl_vertex_buffer_unref(handle); +} + + +// Replace the current viewport with the given values. +// : Width of the viewport +// : Height of the viewport +static void viewport(uint width, uint height) { + cogl_viewport(width, height); +} + +// Unintrospectable function: xlib_renderer_add_filter_EXP() / cogl_xlib_renderer_add_filter_EXP() +static void xlib_renderer_add_filter_EXP(CoglRenderer* renderer, XlibFilterFunc func, void* data) { + cogl_xlib_renderer_add_filter_EXP(renderer, func, data); +} + +// Unintrospectable function: xlib_renderer_get_display_EXP() / cogl_xlib_renderer_get_display_EXP() +static /*CTYPE*/ Display* xlib_renderer_get_display_EXP(CoglRenderer* renderer) { + return cogl_xlib_renderer_get_display_EXP(renderer); +} + +// Unintrospectable function: xlib_renderer_get_foreign_display_EXP() / cogl_xlib_renderer_get_foreign_display_EXP() +static /*CTYPE*/ Display* xlib_renderer_get_foreign_display_EXP(CoglRenderer* renderer) { + return cogl_xlib_renderer_get_foreign_display_EXP(renderer); +} + +// Unintrospectable function: xlib_renderer_handle_event_EXP() / cogl_xlib_renderer_handle_event_EXP() +static FilterReturn xlib_renderer_handle_event_EXP(CoglRenderer* renderer, XEvent* event) { + return cogl_xlib_renderer_handle_event_EXP(renderer, event); +} + +// Unintrospectable function: xlib_renderer_remove_filter_EXP() / cogl_xlib_renderer_remove_filter_EXP() +static void xlib_renderer_remove_filter_EXP(CoglRenderer* renderer, XlibFilterFunc func, void* data) { + cogl_xlib_renderer_remove_filter_EXP(renderer, func, data); +} + +// Unintrospectable function: xlib_renderer_set_foreign_display_EXP() / cogl_xlib_renderer_set_foreign_display_EXP() +static void xlib_renderer_set_foreign_display_EXP(CoglRenderer* renderer, Display* display) { + cogl_xlib_renderer_set_foreign_display_EXP(renderer, display); +} + + +// C prototypes: + +extern (C) { +Attribute* cogl_attribute_new(AttributeBuffer* attribute_buffer, char* name, size_t stride, size_t offset, int components, AttributeType type); +AttributeBuffer* cogl_attribute_buffer_new(size_t bytes, void* data); +int cogl_bitmap_get_size_from_file(char* filename, /*out*/ int* width, /*out*/ int* height); +Bitmap* cogl_bitmap_new_from_file(char* filename, GLib2.Error** error); +uint cogl_buffer_get_size_EXP(Buffer* this_); +BufferUpdateHint cogl_buffer_get_update_hint_EXP(Buffer* this_); +void* cogl_buffer_map_EXP(Buffer* this_, BufferAccess access, BufferMapHint hints); +int cogl_buffer_set_data_EXP(Buffer* this_, size_t offset, void* data, size_t size); +void cogl_buffer_set_update_hint_EXP(Buffer* this_, BufferUpdateHint hint); +void cogl_buffer_unmap_EXP(Buffer* this_); +Color* cogl_color_copy(Color* this_); +void cogl_color_free(Color* this_); +float cogl_color_get_alpha(Color* this_); +ubyte cogl_color_get_alpha_byte(Color* this_); +float cogl_color_get_alpha_float(Color* this_); +float cogl_color_get_blue(Color* this_); +ubyte cogl_color_get_blue_byte(Color* this_); +float cogl_color_get_blue_float(Color* this_); +float cogl_color_get_green(Color* this_); +ubyte cogl_color_get_green_byte(Color* this_); +float cogl_color_get_green_float(Color* this_); +float cogl_color_get_red(Color* this_); +ubyte cogl_color_get_red_byte(Color* this_); +float cogl_color_get_red_float(Color* this_); +void cogl_color_init_from_4f(Color* this_, float red, float green, float blue, float alpha); +void cogl_color_init_from_4fv(Color* this_, float* color_array); +void cogl_color_init_from_4ub(Color* this_, ubyte red, ubyte green, ubyte blue, ubyte alpha); +void cogl_color_premultiply(Color* this_); +void cogl_color_set_alpha(Color* this_, float alpha); +void cogl_color_set_alpha_byte(Color* this_, ubyte alpha); +void cogl_color_set_alpha_float(Color* this_, float alpha); +void cogl_color_set_blue(Color* this_, float blue); +void cogl_color_set_blue_byte(Color* this_, ubyte blue); +void cogl_color_set_blue_float(Color* this_, float blue); +void cogl_color_set_from_4f(Color* this_, float red, float green, float blue, float alpha); +void cogl_color_set_from_4ub(Color* this_, ubyte red, ubyte green, ubyte blue, ubyte alpha); +void cogl_color_set_green(Color* this_, float green); +void cogl_color_set_green_byte(Color* this_, ubyte green); +void cogl_color_set_green_float(Color* this_, float green); +void cogl_color_set_red(Color* this_, float red); +void cogl_color_set_red_byte(Color* this_, ubyte red); +void cogl_color_set_red_float(Color* this_, float red); +void cogl_color_unpremultiply(Color* this_); +int cogl_color_equal(const(void)* v1, const(void)* v2); +Color* cogl_color_new(); +void cogl_depth_state_get_range(DepthState* this_, float* near_val, float* far_val); +int cogl_depth_state_get_test_enabled(DepthState* this_); +DepthTestFunction cogl_depth_state_get_test_function(DepthState* this_); +int cogl_depth_state_get_write_enabled(DepthState* this_); +void cogl_depth_state_init(DepthState* this_); +void cogl_depth_state_set_range(DepthState* this_, float near_val, float far_val); +void cogl_depth_state_set_test_enabled(DepthState* this_, int enable); +void cogl_depth_state_set_test_function(DepthState* this_, DepthTestFunction function_); +void cogl_depth_state_set_write_enabled(DepthState* this_, int enable); +Euler* cogl_euler_copy(Euler* this_); +void cogl_euler_free(Euler* this_); +void cogl_euler_init(Euler* this_, float heading, float pitch, float roll); +void cogl_euler_init_from_matrix(Euler* this_, Matrix* matrix); +void cogl_euler_init_from_quaternion(Euler* this_, Quaternion* quaternion); +int cogl_euler_equal(const(void)* v1, const(void)* v2); +Fixed cogl_fixed_log2(uint x); +uint cogl_fixed_pow(uint x, Fixed y); +Fixed cogl_fixed_atan(Fixed* this_); +Fixed cogl_fixed_atan2(Fixed* this_, Fixed b); +Fixed cogl_fixed_cos(Fixed* this_); +Fixed cogl_fixed_div(Fixed* this_, Fixed b); +Fixed cogl_fixed_mul(Fixed* this_, Fixed b); +Fixed cogl_fixed_mul_div(Fixed* this_, Fixed b, Fixed c); +uint cogl_fixed_pow2(Fixed* this_); +Fixed cogl_fixed_sin(Fixed* this_); +Fixed cogl_fixed_sqrt(Fixed* this_); +Fixed cogl_fixed_tan(Fixed* this_); +IndexBuffer* cogl_index_buffer_new(size_t bytes); +IndexBuffer* cogl_indices_get_buffer(Indices* this_); +size_t cogl_indices_get_offset(Indices* this_); +void cogl_indices_set_offset(Indices* this_, size_t offset); +Indices* cogl_indices_new(IndicesType type, void* indices_data, int n_indices); +Indices* cogl_indices_new_for_buffer(IndicesType type, IndexBuffer* buffer, size_t offset); +Material* cogl_material_copy(Material* this_); +void cogl_material_get_ambient(Material* this_, Color* ambient); +void cogl_material_get_color(Material* this_, /*out*/ Color* color); +void cogl_material_get_diffuse(Material* this_, Color* diffuse); +void cogl_material_get_emission(Material* this_, Color* emission); +int cogl_material_get_layer_point_sprite_coords_enabled(Material* this_, int layer_index); +MaterialWrapMode cogl_material_get_layer_wrap_mode_p(Material* this_, int layer_index); +MaterialWrapMode cogl_material_get_layer_wrap_mode_s(Material* this_, int layer_index); +MaterialWrapMode cogl_material_get_layer_wrap_mode_t(Material* this_, int layer_index); +GLib2.List* cogl_material_get_layers(Material* this_); +int cogl_material_get_n_layers(Material* this_); +float cogl_material_get_point_size(Material* this_); +float cogl_material_get_shininess(Material* this_); +void cogl_material_get_specular(Material* this_, Color* specular); +Handle cogl_material_get_user_program(Material* this_); +void cogl_material_remove_layer(Material* this_, int layer_index); +void cogl_material_set_alpha_test_function(Material* this_, MaterialAlphaFunc alpha_func, float alpha_reference); +void cogl_material_set_ambient(Material* this_, Color* ambient); +void cogl_material_set_ambient_and_diffuse(Material* this_, Color* color); +int cogl_material_set_blend(Material* this_, char* blend_string, GLib2.Error** error); +void cogl_material_set_blend_constant(Material* this_, Color* constant_color); +void cogl_material_set_color(Material* this_, Color* color); +void cogl_material_set_color4f(Material* this_, float red, float green, float blue, float alpha); +void cogl_material_set_color4ub(Material* this_, ubyte red, ubyte green, ubyte blue, ubyte alpha); +void cogl_material_set_diffuse(Material* this_, Color* diffuse); +void cogl_material_set_emission(Material* this_, Color* emission); +void cogl_material_set_layer(Material* this_, int layer_index, Handle texture); +int cogl_material_set_layer_combine(Material* this_, int layer_index, char* blend_string, GLib2.Error** error); +void cogl_material_set_layer_combine_constant(Material* this_, int layer_index, Color* constant); +void cogl_material_set_layer_filters(Material* this_, int layer_index, MaterialFilter min_filter, MaterialFilter mag_filter); +void cogl_material_set_layer_matrix(Material* this_, int layer_index, Matrix* matrix); +int cogl_material_set_layer_point_sprite_coords_enabled(Material* this_, int layer_index, int enable, GLib2.Error** error); +void cogl_material_set_layer_wrap_mode(Material* this_, int layer_index, MaterialWrapMode mode); +void cogl_material_set_layer_wrap_mode_p(Material* this_, int layer_index, MaterialWrapMode mode); +void cogl_material_set_layer_wrap_mode_s(Material* this_, int layer_index, MaterialWrapMode mode); +void cogl_material_set_layer_wrap_mode_t(Material* this_, int layer_index, MaterialWrapMode mode); +void cogl_material_set_point_size(Material* this_, float point_size); +void cogl_material_set_shininess(Material* this_, float shininess); +void cogl_material_set_specular(Material* this_, Color* specular); +void cogl_material_set_user_program(Material* this_, Handle program); +Material* cogl_material_new(); +Handle cogl_material_ref(Handle material); +void cogl_material_unref(Handle material); +MaterialFilter cogl_material_layer_get_mag_filter(MaterialLayer* this_); +MaterialFilter cogl_material_layer_get_min_filter(MaterialLayer* this_); +Handle cogl_material_layer_get_texture(MaterialLayer* this_); +MaterialWrapMode cogl_material_layer_get_wrap_mode_p(MaterialLayer* this_); +MaterialWrapMode cogl_material_layer_get_wrap_mode_s(MaterialLayer* this_); +MaterialWrapMode cogl_material_layer_get_wrap_mode_t(MaterialLayer* this_); +Matrix* cogl_matrix_copy(Matrix* this_); +void cogl_matrix_free(Matrix* this_); +void cogl_matrix_frustum(Matrix* this_, float left, float right, float bottom, float top, float z_near, float z_far); +float* cogl_matrix_get_array(Matrix* this_); +int cogl_matrix_get_inverse(Matrix* this_, /*out*/ Matrix* inverse); +void cogl_matrix_init_from_array(Matrix* this_, float* array); +void cogl_matrix_init_identity(Matrix* this_); +int cogl_matrix_is_identity(Matrix* this_); +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); +void cogl_matrix_multiply(Matrix* this_, Matrix* a, Matrix* b); +void cogl_matrix_ortho(Matrix* this_, float left, float right, float bottom, float top, float z_near, float z_far); +void cogl_matrix_perspective(Matrix* this_, float fov_y, float aspect, float z_near, float z_far); +void cogl_matrix_rotate(Matrix* this_, float angle, float x, float y, float z); +void cogl_matrix_scale(Matrix* this_, float sx, float sy, float sz); +void cogl_matrix_transform_point(Matrix* this_, /*inout*/ float* x, /*inout*/ float* y, /*inout*/ float* z, /*inout*/ float* w); +void cogl_matrix_translate(Matrix* this_, float x, float y, float z); +int cogl_matrix_equal(const(void)* v1, const(void)* v2); +void* cogl_object_get_user_data(Object* this_, UserDataKey* key); +void cogl_object_set_user_data(Object* this_, UserDataKey* key, void* user_data, UserDataDestroyCallback destroy); +void* cogl_object_ref(void* object); +void cogl_object_unref(void* object); +Path* /*new*/ cogl_path_copy(Path* this_); +void cogl_path_arc(float center_x, float center_y, float radius_x, float radius_y, float angle_1, float angle_2); +void cogl_path_close(); +void cogl_path_curve_to(float x_1, float y_1, float x_2, float y_2, float x_3, float y_3); +void cogl_path_ellipse(float center_x, float center_y, float radius_x, float radius_y); +void cogl_path_fill(); +void cogl_path_fill_preserve(); +PathFillRule cogl_path_get_fill_rule(); +void cogl_path_line(float x_1, float y_1, float x_2, float y_2); +void cogl_path_line_to(float x, float y); +void cogl_path_move_to(float x, float y); +void cogl_path_new(); +void cogl_path_polygon(float* coords, int num_points); +void cogl_path_polyline(float* coords, int num_points); +void cogl_path_rectangle(float x_1, float y_1, float x_2, float y_2); +void cogl_path_rel_curve_to(float x_1, float y_1, float x_2, float y_2, float x_3, float y_3); +void cogl_path_rel_line_to(float x, float y); +void cogl_path_rel_move_to(float x, float y); +void cogl_path_round_rectangle(float x_1, float y_1, float x_2, float y_2, float radius, float arc_step); +void cogl_path_set_fill_rule(PathFillRule fill_rule); +void cogl_path_stroke(); +void cogl_path_stroke_preserve(); +PixelBuffer* cogl_pixel_buffer_new_with_size_EXP(uint width, uint height, PixelFormat format, uint* stride); +void cogl_primitive_draw(Primitive* this_); +int cogl_primitive_get_first_vertex(Primitive* this_); +VerticesMode cogl_primitive_get_mode(Primitive* this_); +int cogl_primitive_get_n_vertices(Primitive* this_); +void cogl_primitive_set_attributes(Primitive* this_, Attribute** attributes, int n_attributes); +void cogl_primitive_set_first_vertex(Primitive* this_, int first_vertex); +void cogl_primitive_set_indices(Primitive* this_, Indices* indices); +void cogl_primitive_set_mode(Primitive* this_, VerticesMode mode); +void cogl_primitive_set_n_vertices(Primitive* this_, int n_vertices); +Primitive* cogl_primitive_new(VerticesMode mode, int n_vertices, ...); +Primitive* cogl_primitive_new_p2(VerticesMode mode, int n_vertices, VertexP2* data); +Primitive* cogl_primitive_new_p2c4(VerticesMode mode, int n_vertices, VertexP2C4* data); +Primitive* cogl_primitive_new_p2t2(VerticesMode mode, int n_vertices, VertexP2T2* data); +Primitive* cogl_primitive_new_p2t2c4(VerticesMode mode, int n_vertices, VertexP2T2C4* data); +Primitive* cogl_primitive_new_p3(VerticesMode mode, int n_vertices, VertexP3* data); +Primitive* cogl_primitive_new_p3c4(VerticesMode mode, int n_vertices, VertexP3C4* data); +Primitive* cogl_primitive_new_p3t2(VerticesMode mode, int n_vertices, VertexP3T2* data); +Primitive* cogl_primitive_new_p3t2c4(VerticesMode mode, int n_vertices, VertexP3T2C4* data); +Primitive* cogl_primitive_new_with_attributes(VerticesMode mode, int n_vertices, Attribute** attributes, int n_attributes); +Quaternion* cogl_quaternion_copy(Quaternion* this_); +float cogl_quaternion_dot_product(Quaternion* this_, Quaternion* b); +void cogl_quaternion_free(Quaternion* this_); +float cogl_quaternion_get_rotation_angle(Quaternion* this_); +void cogl_quaternion_get_rotation_axis(Quaternion* this_, Vector3* vector); +void cogl_quaternion_init(Quaternion* this_, float angle, float x, float y, float z); +void cogl_quaternion_init_from_angle_vector(Quaternion* this_, float angle, Vector3* axis); +void cogl_quaternion_init_from_array(Quaternion* this_, float* array); +void cogl_quaternion_init_from_euler(Quaternion* this_, Euler* euler); +void cogl_quaternion_init_from_x_rotation(Quaternion* this_, float angle); +void cogl_quaternion_init_from_y_rotation(Quaternion* this_, float angle); +void cogl_quaternion_init_from_z_rotation(Quaternion* this_, float angle); +void cogl_quaternion_init_identity(Quaternion* this_); +void cogl_quaternion_invert(Quaternion* this_); +void cogl_quaternion_multiply(Quaternion* this_, Quaternion* left, Quaternion* right); +void cogl_quaternion_nlerp(Quaternion* this_, Quaternion* a, Quaternion* b, float t); +void cogl_quaternion_normalize(Quaternion* this_); +void cogl_quaternion_pow(Quaternion* this_, float exponent); +void cogl_quaternion_slerp(Quaternion* this_, Quaternion* a, Quaternion* b, float t); +void cogl_quaternion_squad(Quaternion* this_, Quaternion* prev, Quaternion* a, Quaternion* b, Quaternion* next, float t); +int cogl_quaternion_equal(const(void)* v1, const(void)* v2); +void cogl_vector3_add_EXP(Vector3* this_, Vector3* a, Vector3* b); +Vector3* cogl_vector3_copy_EXP(Vector3* this_); +void cogl_vector3_cross_product_EXP(Vector3* this_, Vector3* u, Vector3* v); +float cogl_vector3_distance_EXP(Vector3* this_, Vector3* b); +void cogl_vector3_divide_scalar_EXP(Vector3* this_, float scalar); +float cogl_vector3_dot_product_EXP(Vector3* this_, Vector3* b); +int cogl_vector3_equal_with_epsilon_EXP(Vector3* this_, Vector3* vector1, float epsilon); +void cogl_vector3_free_EXP(Vector3* this_); +void cogl_vector3_init_EXP(Vector3* this_, float x, float y, float z); +void cogl_vector3_init_zero_EXP(Vector3* this_); +void cogl_vector3_invert_EXP(Vector3* this_); +float cogl_vector3_magnitude_EXP(Vector3* this_); +void cogl_vector3_multiply_scalar_EXP(Vector3* this_, float scalar); +void cogl_vector3_normalize_EXP(Vector3* this_); +void cogl_vector3_subtract_EXP(Vector3* this_, Vector3* a, Vector3* b); +int cogl_vector3_equal_EXP(const(void)* v1, const(void)* v2); +Fixed cogl_angle_cos(Angle angle); +Fixed cogl_angle_sin(Angle angle); +Fixed cogl_angle_tan(Angle angle); +void cogl_begin_gl(); +GLib2.Quark cogl_bitmap_error_quark(); +GLib2.Quark cogl_blend_string_error_quark(); +int cogl_check_extension(char* name, char* ext); +void cogl_clear(Color* color, c_ulong buffers); +void cogl_clip_ensure(); +void cogl_clip_pop(); +void cogl_clip_push(float x_offset, float y_offset, float width, float height); +void cogl_clip_push_from_path(); +void cogl_clip_push_from_path_preserve(); +void cogl_clip_push_rectangle(float x0, float y0, float x1, float y1); +void cogl_clip_push_window_rect(float x_offset, float y_offset, float width, float height); +void cogl_clip_push_window_rectangle(int x_offset, int y_offset, int width, int height); +void cogl_clip_stack_restore(); +void cogl_clip_stack_save(); +int cogl_clutter_check_extension_CLUTTER(char* name, char* ext); +int cogl_clutter_winsys_has_feature_CLUTTER(WinsysFeature feature); +/*CTYPE*/ XVisualInfo* cogl_clutter_winsys_xlib_get_visual_info_CLUTTER(); +Handle cogl_create_program(); +Handle cogl_create_shader(ShaderType shader_type); +void cogl_disable_fog(); +Fixed cogl_double_to_fixed(double value); +int cogl_double_to_int(double value); +uint cogl_double_to_uint(double value); +void cogl_draw_attributes(VerticesMode mode, int first_vertex, int n_vertices, Attribute** attributes, int n_attributes); +void cogl_draw_indexed_attributes(VerticesMode mode, int first_vertex, int n_vertices, Indices* indices, Attribute** attributes, int n_attributes); +void cogl_end_gl(); +int cogl_features_available(FeatureFlags features); +void cogl_flush(); +void cogl_frustum(float left, float right, float bottom, float top, float z_near, float z_far); +int cogl_get_backface_culling_enabled(); +void cogl_get_bitmasks(/*out*/ int* red, /*out*/ int* green, /*out*/ int* blue, /*out*/ int* alpha); +int cogl_get_depth_test_enabled(); +FeatureFlags cogl_get_features(); +void cogl_get_modelview_matrix(/*out*/ Matrix* matrix); +GLib2.OptionGroup* cogl_get_option_group(); +Path* cogl_get_path(); +FuncPtr cogl_get_proc_address(char* name); +void cogl_get_projection_matrix(/*out*/ Matrix* matrix); +Indices* cogl_get_rectangle_indices(int n_rectangles); +void* cogl_get_source(); +Quaternion* cogl_get_static_identity_quaternion(); +Quaternion* cogl_get_static_zero_quaternion(); +void cogl_get_viewport(/*out*/ float v); +Type cogl_handle_get_type(); +Handle cogl_handle_ref(Handle handle); +void cogl_handle_unref(Handle handle); +IndicesType cogl_indices_get_type(Indices* indices); +int cogl_is_attribute(void* object); +int cogl_is_attribute_buffer(void* object); +int cogl_is_bitmap(Handle handle); +int cogl_is_buffer_EXP(void* object); +int cogl_is_index_buffer(void* object); +int cogl_is_material(Handle handle); +int cogl_is_offscreen(Handle handle); +int cogl_is_path(Handle handle); +int cogl_is_pixel_buffer_EXP(void* object); +int cogl_is_primitive(void* object); +int cogl_is_program(Handle handle); +int cogl_is_shader(Handle handle); +int cogl_is_texture(Handle handle); +int cogl_is_texture_2d_EXP(void* object); +int cogl_is_texture_3d_EXP(Handle handle); +int cogl_is_vertex_buffer(Handle handle); +int cogl_is_vertex_buffer_indices(Handle handle); +MaterialLayerType cogl_material_layer_get_type(MaterialLayer* layer); +Handle /*new*/ cogl_offscreen_new_to_texture(Handle handle); +Handle cogl_offscreen_ref(Handle handle); +void cogl_offscreen_unref(Handle handle); +void cogl_onscreen_clutter_backend_set_size_CLUTTER(int width, int height); +void cogl_ortho(float left, float right, float bottom, float top, float near, float far); +void cogl_perspective(float fovy, float aspect, float z_near, float z_far); +void cogl_polygon(TextureVertex* vertices, uint n_vertices, int use_color); +void cogl_pop_draw_buffer(); +void cogl_pop_framebuffer(); +void cogl_pop_matrix(); +void cogl_pop_source(); +void cogl_program_attach_shader(Handle program_handle, Handle shader_handle); +int cogl_program_get_uniform_location(Handle handle, char* uniform_name); +void cogl_program_link(Handle handle); +Handle cogl_program_ref(Handle handle); +void cogl_program_set_uniform_1f(Handle program, int uniform_location, float value); +void cogl_program_set_uniform_1i(Handle program, int uniform_location, int value); +void cogl_program_set_uniform_float(Handle program, int uniform_location, int n_components, int count, float* value); +void cogl_program_set_uniform_int(Handle program, int uniform_location, int n_components, int count, int* value); +void cogl_program_set_uniform_matrix(Handle program, int uniform_location, int dimensions, int count, int transpose, float* value); +void cogl_program_uniform_1f(int uniform_no, float value); +void cogl_program_uniform_1i(int uniform_no, int value); +void cogl_program_uniform_float(int uniform_no, int size, int count, float* value); +void cogl_program_uniform_int(int uniform_no, int size, int count, int* value); +void cogl_program_uniform_matrix(int uniform_no, int size, int count, int transpose, float* value); +void cogl_program_unref(Handle handle); +void cogl_program_use(Handle handle); +void cogl_push_draw_buffer(); +void cogl_push_framebuffer(Framebuffer* buffer); +void cogl_push_matrix(); +void cogl_push_source(void* material); +void cogl_read_pixels(int x, int y, int width, int height, ReadPixelsFlags source, PixelFormat format, ubyte* pixels); +void cogl_rectangle(float x_1, float y_1, float x_2, float y_2); +void cogl_rectangle_with_multitexture_coords(float x1, float y1, float x2, float y2, float* tex_coords, int tex_coords_len); +void cogl_rectangle_with_texture_coords(float x1, float y1, float x2, float y2, float tx1, float ty1, float tx2, float ty2); +void cogl_rectangles(float* verts, uint n_rects); +void cogl_rectangles_with_texture_coords(float* verts, uint n_rects); +void cogl_rotate(float angle, float x, float y, float z); +void cogl_scale(float x, float y, float z); +void cogl_set_backface_culling_enabled(int setting); +void cogl_set_depth_test_enabled(int setting); +void cogl_set_draw_buffer(BufferTarget target, Handle offscreen); +void cogl_set_fog(Color* fog_color, FogMode mode, float density, float z_near, float z_far); +void cogl_set_framebuffer(Framebuffer* buffer); +void cogl_set_modelview_matrix(Matrix* matrix); +void cogl_set_path(Path* path); +void cogl_set_projection_matrix(Matrix* matrix); +void cogl_set_source(void* material); +void cogl_set_source_color(Color* color); +void cogl_set_source_color4f(float red, float green, float blue, float alpha); +void cogl_set_source_color4ub(ubyte red, ubyte green, ubyte blue, ubyte alpha); +void cogl_set_source_texture(Handle texture_handle); +void cogl_set_viewport(int x, int y, int width, int height); +void cogl_shader_compile(Handle handle); +char* /*new*/ cogl_shader_get_info_log(Handle handle); +ShaderType cogl_shader_get_type(Handle handle); +int cogl_shader_is_compiled(Handle handle); +Handle cogl_shader_ref(Handle handle); +void cogl_shader_source(Handle shader, char* source); +void cogl_shader_unref(Handle handle); +int cogl_sqrti(int x); +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); +Texture2D* cogl_texture_2d_new_from_foreign_EXP(CoglContext* ctx, uint gl_handle, int width, int height, PixelFormat format, GLib2.Error** error); +Texture2D* cogl_texture_2d_new_with_size_EXP(CoglContext* ctx, int width, int height, PixelFormat internal_format, GLib2.Error** error); +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); +Handle cogl_texture_3d_new_with_size_EXP(uint width, uint height, uint depth, TextureFlags flags, PixelFormat internal_format, GLib2.Error** error); +GLib2.Quark cogl_texture_error_quark(); +int cogl_texture_get_data(Handle handle, PixelFormat format, uint rowstride, ubyte* data); +PixelFormat cogl_texture_get_format(Handle handle); +int cogl_texture_get_gl_texture(Handle handle, /*out*/ GL.uint* out_gl_handle=null, /*out*/ GL.enum* out_gl_target=null); +uint cogl_texture_get_height(Handle handle); +int cogl_texture_get_max_waste(Handle handle); +uint cogl_texture_get_rowstride(Handle handle); +uint cogl_texture_get_width(Handle handle); +int cogl_texture_is_sliced(Handle handle); +Handle cogl_texture_new_from_bitmap(Handle bmp_handle, TextureFlags flags, PixelFormat internal_format); +Handle cogl_texture_new_from_data(uint width, uint height, TextureFlags flags, PixelFormat format, PixelFormat internal_format, uint rowstride, ubyte* data); +Handle cogl_texture_new_from_file(char* filename, TextureFlags flags, PixelFormat internal_format, GLib2.Error** error); +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); +Handle cogl_texture_new_from_sub_texture(Handle full_texture, int sub_x, int sub_y, int sub_width, int sub_height); +Handle cogl_texture_new_with_size(uint width, uint height, TextureFlags flags, PixelFormat internal_format); +Handle cogl_texture_ref(Handle handle); +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); +void cogl_texture_unref(Handle handle); +void cogl_transform(Matrix* matrix); +void cogl_translate(float x, float y, float z); +void cogl_vdraw_attributes(VerticesMode mode, int first_vertex, int n_vertices, ...); +void cogl_vdraw_indexed_attributes(VerticesMode mode, int first_vertex, int n_vertices, Indices* indices, ...); +void cogl_vertex_buffer_add(Handle handle, char* attribute_name, ubyte n_components, AttributeType type, int normalized, ushort stride, void* pointer); +void cogl_vertex_buffer_delete(Handle handle, char* attribute_name); +void cogl_vertex_buffer_disable(Handle handle, char* attribute_name); +void cogl_vertex_buffer_draw(Handle handle, VerticesMode mode, int first, int count); +void cogl_vertex_buffer_draw_elements(Handle handle, VerticesMode mode, Handle indices, int min_index, int max_index, int indices_offset, int count); +void cogl_vertex_buffer_enable(Handle handle, char* attribute_name); +uint cogl_vertex_buffer_get_n_vertices(Handle handle); +Handle cogl_vertex_buffer_indices_get_for_quads(uint n_indices); +IndicesType cogl_vertex_buffer_indices_get_type(Handle indices); +Handle cogl_vertex_buffer_indices_new(IndicesType indices_type, void* indices_array, int indices_len); +Handle cogl_vertex_buffer_new(uint n_vertices); +Handle cogl_vertex_buffer_ref(Handle handle); +void cogl_vertex_buffer_submit(Handle handle); +void cogl_vertex_buffer_unref(Handle handle); +void cogl_viewport(uint width, uint height); +void cogl_xlib_renderer_add_filter_EXP(CoglRenderer* renderer, XlibFilterFunc func, void* data); +/*CTYPE*/ Display* cogl_xlib_renderer_get_display_EXP(CoglRenderer* renderer); +/*CTYPE*/ Display* cogl_xlib_renderer_get_foreign_display_EXP(CoglRenderer* renderer); +FilterReturn cogl_xlib_renderer_handle_event_EXP(CoglRenderer* renderer, XEvent* event); +void cogl_xlib_renderer_remove_filter_EXP(CoglRenderer* renderer, XlibFilterFunc func, void* data); +void cogl_xlib_renderer_set_foreign_display_EXP(CoglRenderer* renderer, Display* display); +} diff --git a/gtk2/coglpango.d b/gtk2/coglpango.d new file mode 100644 index 0000000..a7b25f7 --- /dev/null +++ b/gtk2/coglpango.d @@ -0,0 +1,152 @@ +// *** DO NOT EDIT *** +// Automatically generated from "/usr/share/gir-1.0/CoglPango-1.0.gir" + +module CoglPango; +public import gtk2.cogl; +alias gtk2.cogl Cogl; +public import gtk2.gl; +alias gtk2.gl GL; +public import gtk2.glib2; +alias gtk2.glib2 GLib2; +public import gtk2.gobject2; +alias gtk2.gobject2 GObject2; +public import gtk2.pango; +alias gtk2.pango Pango; +public import gtk2.pangocairo; +alias gtk2.pangocairo PangoCairo; +public import gtk2.pangoft2; +alias gtk2.pangoft2 PangoFT2; +public import gtk2.cairo; +alias gtk2.cairo cairo; +public import gtk2.fontconfig2; +alias gtk2.fontconfig2 fontconfig2; +public import gtk2.freetype22; +alias gtk2.freetype22 freetype22; + +// package: "cogl-pango-1.0"; +// C header: "cogl-pango/cogl-pango.h"; + +// c:symbol-prefixes: ["cogl_pango"] +// c:identifier-prefixes: ["CoglPango"] + +// module CoglPango; + +alias PangoCairo.FontMap FontMap; +struct Renderer /* : Pango.Renderer */ { + alias method_parent this; + alias method_parent super_; + alias method_parent renderer; + Pango.Renderer method_parent; +} + +struct RendererClass { +} + +static void ensure_glyph_cache_for_layout(Pango.Layout* layout) { + cogl_pango_ensure_glyph_cache_for_layout(layout); +} + + +// Clears the glyph cache for @fm. +// : a #CoglPangoFontMap +static void font_map_clear_glyph_cache(FontMap* fm) { + cogl_pango_font_map_clear_glyph_cache(fm); +} + + +// Creates a new #PangoContext from the passed font map. +// RETURNS: the newly created #PangoContext +// : a #CoglPangoFontMap +static Pango.Context* /*new*/ font_map_create_context(FontMap* fm) { + return cogl_pango_font_map_create_context(fm); +} + + +// Retrieves the #CoglPangoRenderer for the passed font map. +// RETURNS: a #PangoRenderer +// : a #CoglPangoFontMap +static Pango.Renderer* font_map_get_renderer(FontMap* fm) { + return cogl_pango_font_map_get_renderer(fm); +} + + +// Retrieves whether the #CoglPangoRenderer used by @fm will +// use mipmapping when rendering the glyphs. +// RETURNS: %TRUE if mipmapping is used, %FALSE otherwise. +// : a #CoglPangoFontMap +static int font_map_get_use_mipmapping(FontMap* fm) { + return cogl_pango_font_map_get_use_mipmapping(fm); +} + + +// Creates a new font map. +// RETURNS: the newly created #PangoFontMap +static Pango.FontMap* /*new*/ font_map_new() { + return cogl_pango_font_map_new(); +} + + +// Sets the resolution to be used by @font_map at @dpi. +// : a #CoglPangoFontMap +// : DPI to set +static void font_map_set_resolution(FontMap* font_map, double dpi) { + cogl_pango_font_map_set_resolution(font_map, dpi); +} + + +// Sets whether the renderer for the passed font map should use +// mipmapping when rendering a #PangoLayout. +// : a #CoglPangoFontMap +// : %TRUE to enable the use of mipmapping +static void font_map_set_use_mipmapping(FontMap* fm, int value) { + cogl_pango_font_map_set_use_mipmapping(fm, value); +} + + +// Renders @layout. +// : a #PangoLayout +// : X coordinate to render the layout at +// : Y coordinate to render the layout at +// : color to use when rendering the layout +// : flags to pass to the renderer +static void render_layout(Pango.Layout* layout, int x, int y, Cogl.Color* color, int flags) { + cogl_pango_render_layout(layout, x, y, color, flags); +} + + +// Renders @line at the given coordinates using the given color. +// : a #PangoLayoutLine +// : X coordinate to render the line at +// : Y coordinate to render the line at +// : color to use when rendering the line +static void render_layout_line(Pango.LayoutLine* line, int x, int y, Cogl.Color* color) { + cogl_pango_render_layout_line(line, x, y, color); +} + + +// FIXME +// : a #PangoLayout +// : FIXME +// : FIXME +// : color to use when rendering the layout +// : flags to pass to the renderer +static void render_layout_subpixel(Pango.Layout* layout, int x, int y, Cogl.Color* color, int flags) { + cogl_pango_render_layout_subpixel(layout, x, y, color, flags); +} + + +// C prototypes: + +extern (C) { +void cogl_pango_ensure_glyph_cache_for_layout(Pango.Layout* layout); +void cogl_pango_font_map_clear_glyph_cache(FontMap* fm); +Pango.Context* /*new*/ cogl_pango_font_map_create_context(FontMap* fm); +Pango.Renderer* cogl_pango_font_map_get_renderer(FontMap* fm); +int cogl_pango_font_map_get_use_mipmapping(FontMap* fm); +Pango.FontMap* /*new*/ cogl_pango_font_map_new(); +void cogl_pango_font_map_set_resolution(FontMap* font_map, double dpi); +void cogl_pango_font_map_set_use_mipmapping(FontMap* fm, int value); +void cogl_pango_render_layout(Pango.Layout* layout, int x, int y, Cogl.Color* color, int flags); +void cogl_pango_render_layout_line(Pango.LayoutLine* line, int x, int y, Cogl.Color* color); +void cogl_pango_render_layout_subpixel(Pango.Layout* layout, int x, int y, Cogl.Color* color, int flags); +} -- 2.11.4.GIT