Common Types

## Common Types Common Types — Types used throughout the library |

## Synopsis

                        CoglVertexP2;
                        CoglVertexP3;
                        CoglVertexP2C4;
                        CoglVertexP3C4;
                        CoglVertexP2T2;
                        CoglVertexP3T2;
                        CoglVertexP2T2C4;
                        CoglVertexP3T2C4;
    enum                CoglVerticesMode;

    void                (*CoglFuncPtr)                      (void);
    enum                CoglPixelFormat;
    enum                CoglBufferTarget;
    enum                CoglBufferBit;
    enum                CoglAttributeType;
    enum                CoglColorMask;

    enum                CoglTextureFlags;

    typedef             CoglBool;

## Description

General types used by various Cogl functions.

## Details

### CoglVertexP2

    typedef struct {
       float x, y;
    } CoglVertexP2;

A convenience vertex definition that can be used with `cogl_primitive_new_p2()`.

float `x`; | The x component of a position attribute
float `y`; | The y component of a position attribute

Since 1.6

Stability Level: Unstable

### CoglVertexP3

    typedef struct {
       float x, y, z;
    } CoglVertexP3;

A convenience vertex definition that can be used with `cogl_primitive_new_p3()`.

float `x`; | The x component of a position attribute
float `y`; | The y component of a position attribute
float `z`; | The z component of a position attribute

Since 1.6

Stability Level: Unstable

### CoglVertexP2C4

    typedef struct {
       float x, y;
       uint8_t r, g, b, a;
    } CoglVertexP2C4;

A convenience vertex definition that can be used with `cogl_primitive_new_p2c4()`.

float `x`; | The x component of a position attribute
float `y`; | The y component of a position attribute
uint8_t `r`; | The red component of a color attribute
uint8_t `g`; | The blue component of a color attribute
uint8_t `b`; | The green component of a color attribute
uint8_t `a`; | The alpha component of a color attribute

Since 1.6

Stability Level: Unstable

### CoglVertexP3C4

    typedef struct {
       float x, y, z;
       uint8_t r, g, b, a;
    } CoglVertexP3C4;

A convenience vertex definition that can be used with `cogl_primitive_new_p3c4()`.

float `x`; | The x component of a position attribute
float `y`; | The y component of a position attribute
float `z`; | The z component of a position attribute
uint8_t `r`; | The red component of a color attribute
uint8_t `g`; | The blue component of a color attribute
uint8_t `b`; | The green component of a color attribute
uint8_t `a`; | The alpha component of a color attribute

Since 1.6

Stability Level: Unstable

### CoglVertexP2T2

    typedef struct {
       float x, y;
       float s, t;
    } CoglVertexP2T2;

A convenience vertex definition that can be used with `cogl_primitive_new_p2t2()`.

float `x`; | The x component of a position attribute
float `y`; | The y component of a position attribute
float `s`; | The s component of a texture coordinate attribute
float `t`; | The t component of a texture coordinate attribute

Since 1.6

Stability Level: Unstable

### CoglVertexP3T2

    typedef struct {
       float x, y, z;
       float s, t;
    } CoglVertexP3T2;

A convenience vertex definition that can be used with `cogl_primitive_new_p3t2()`.

float `x`; | The x component of a position attribute
float `y`; | The y component of a position attribute
float `z`; | The z component of a position attribute
float `s`; | The s component of a texture coordinate attribute
float `t`; | The t component of a texture coordinate attribute

Since 1.6

Stability Level: Unstable

### CoglVertexP2T2C4

    typedef struct {
       float x, y;
       float s, t;
       uint8_t r, g, b, a;
    } CoglVertexP2T2C4;

A convenience vertex definition that can be used with `cogl_primitive_new_p3t2c4()`.

float `x`; | The x component of a position attribute
float `y`; | The y component of a position attribute
float `s`; | The s component of a texture coordinate attribute
float `t`; | The t component of a texture coordinate attribute
uint8_t `r`; | The red component of a color attribute
uint8_t `g`; | The blue component of a color attribute
uint8_t `b`; | The green component of a color attribute
uint8_t `a`; | The alpha component of a color attribute

Since 1.6

Stability Level: Unstable

### CoglVertexP3T2C4

    typedef struct {
       float x, y, z;
       float s, t;
       uint8_t r, g, b, a;
    } CoglVertexP3T2C4;

A convenience vertex definition that can be used with `cogl_primitive_new_p3t2c4()`.

float `x`; | The x component of a position attribute
float `y`; | The y component of a position attribute
float `z`; | The z component of a position attribute
float `s`; | The s component of a texture coordinate attribute
float `t`; | The t component of a texture coordinate attribute
uint8_t `r`; | The red component of a color attribute
uint8_t `g`; | The blue component of a color attribute
uint8_t `b`; | The green component of a color attribute
uint8_t `a`; | The alpha component of a color attribute

Since 1.6

Stability Level: Unstable

### enum CoglVerticesMode

    typedef enum {
      COGL_VERTICES_MODE_POINTS = 0x0000,
      COGL_VERTICES_MODE_LINES = 0x0001,
      COGL_VERTICES_MODE_LINE_LOOP = 0x0002,
      COGL_VERTICES_MODE_LINE_STRIP = 0x0003,
      COGL_VERTICES_MODE_TRIANGLES = 0x0004,
      COGL_VERTICES_MODE_TRIANGLE_STRIP = 0x0005,
      COGL_VERTICES_MODE_TRIANGLE_FAN = 0x0006
    } CoglVerticesMode;

Different ways of interpreting vertices when drawing.

`COGL_VERTICES_MODE_POINTS` | FIXME, equivalent to `GL_POINTS`
`COGL_VERTICES_MODE_LINES` | FIXME, equivalent to `GL_LINES`
`COGL_VERTICES_MODE_LINE_LOOP` | FIXME, equivalent to `GL_LINE_LOOP`
`COGL_VERTICES_MODE_LINE_STRIP` | FIXME, equivalent to `GL_LINE_STRIP`
`COGL_VERTICES_MODE_TRIANGLES` | FIXME, equivalent to `GL_TRIANGLES`
`COGL_VERTICES_MODE_TRIANGLE_STRIP` | FIXME, equivalent to `GL_TRIANGLE_STRIP`
`COGL_VERTICES_MODE_TRIANGLE_FAN` | FIXME, equivalent to `GL_TRIANGLE_FAN`

Since 1.0

### CoglFuncPtr ()

    void                (*CoglFuncPtr)                      (void);

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.

### enum CoglPixelFormat

    typedef enum {
     /*< prefix=COGL_PIXEL_FORMAT >*/
      COGL_PIXEL_FORMAT_ANY           = 0,
      COGL_PIXEL_FORMAT_A_8           = 1 | COGL_A_BIT,

      COGL_PIXEL_FORMAT_RGB_565       = 4,
      COGL_PIXEL_FORMAT_RGBA_4444     = 5 | COGL_A_BIT,
      COGL_PIXEL_FORMAT_RGBA_5551     = 6 | COGL_A_BIT,
      COGL_PIXEL_FORMAT_YUV           = 7,
      COGL_PIXEL_FORMAT_G_8           = 8,

      COGL_PIXEL_FORMAT_RGB_888       = 2,
      COGL_PIXEL_FORMAT_BGR_888       = (2 | COGL_BGR_BIT),

      COGL_PIXEL_FORMAT_RGBA_8888     = (3 | COGL_A_BIT),
      COGL_PIXEL_FORMAT_BGRA_8888     = (3 | COGL_A_BIT | COGL_BGR_BIT),
      COGL_PIXEL_FORMAT_ARGB_8888     = (3 | COGL_A_BIT | COGL_AFIRST_BIT),
      COGL_PIXEL_FORMAT_ABGR_8888     = (3 | COGL_A_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),

      COGL_PIXEL_FORMAT_RGBA_1010102  = (13 | COGL_A_BIT),
      COGL_PIXEL_FORMAT_BGRA_1010102  = (13 | COGL_A_BIT | COGL_BGR_BIT),
      COGL_PIXEL_FORMAT_ARGB_2101010  = (13 | COGL_A_BIT | COGL_AFIRST_BIT),
      COGL_PIXEL_FORMAT_ABGR_2101010  = (13 | COGL_A_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),

      COGL_PIXEL_FORMAT_RGBA_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT),
      COGL_PIXEL_FORMAT_BGRA_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT),
      COGL_PIXEL_FORMAT_ARGB_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_AFIRST_BIT),
      COGL_PIXEL_FORMAT_ABGR_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
      COGL_PIXEL_FORMAT_RGBA_4444_PRE = (COGL_PIXEL_FORMAT_RGBA_4444 | COGL_A_BIT | COGL_PREMULT_BIT),
      COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 | COGL_A_BIT | COGL_PREMULT_BIT),

      COGL_PIXEL_FORMAT_RGBA_1010102_PRE = (COGL_PIXEL_FORMAT_RGBA_1010102 | COGL_PREMULT_BIT),
      COGL_PIXEL_FORMAT_BGRA_1010102_PRE = (COGL_PIXEL_FORMAT_BGRA_1010102 | COGL_PREMULT_BIT),
      COGL_PIXEL_FORMAT_ARGB_2101010_PRE = (COGL_PIXEL_FORMAT_ARGB_2101010 | COGL_PREMULT_BIT),
      COGL_PIXEL_FORMAT_ABGR_2101010_PRE = (COGL_PIXEL_FORMAT_ABGR_2101010 | COGL_PREMULT_BIT),

      COGL_PIXEL_FORMAT_DEPTH_16  = (9 | COGL_DEPTH_BIT),
      COGL_PIXEL_FORMAT_DEPTH_32  = (3 | COGL_DEPTH_BIT),

      COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8 = (3 | COGL_DEPTH_BIT | COGL_STENCIL_BIT)
    } CoglPixelFormat;

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 endianness of the system.

For the formats with non byte aligned components the component order specifies the order within a 16-bit or 32-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.

`COGL_PIXEL_FORMAT_ANY` | Any format
`COGL_PIXEL_FORMAT_A_8` | 8 bits alpha mask
`COGL_PIXEL_FORMAT_RGB_565` | RGB, 16 bits
`COGL_PIXEL_FORMAT_RGBA_4444` | RGBA, 16 bits
`COGL_PIXEL_FORMAT_RGBA_5551` | RGBA, 16 bits
`COGL_PIXEL_FORMAT_YUV` | Not currently supported
`COGL_PIXEL_FORMAT_G_8` | Single luminance component
`COGL_PIXEL_FORMAT_RGB_888` | RGB, 24 bits
`COGL_PIXEL_FORMAT_BGR_888` | BGR, 24 bits
`COGL_PIXEL_FORMAT_RGBA_8888` | RGBA, 32 bits
`COGL_PIXEL_FORMAT_BGRA_8888` | BGRA, 32 bits
`COGL_PIXEL_FORMAT_ARGB_8888` | ARGB, 32 bits
`COGL_PIXEL_FORMAT_ABGR_8888` | ABGR, 32 bits
`COGL_PIXEL_FORMAT_RGBA_1010102` | RGBA, 32 bits, 10 bpc
`COGL_PIXEL_FORMAT_BGRA_1010102` | BGRA, 32 bits, 10 bpc
`COGL_PIXEL_FORMAT_ARGB_2101010` | ARGB, 32 bits, 10 bpc
`COGL_PIXEL_FORMAT_ABGR_2101010` | ABGR, 32 bits, 10 bpc
`COGL_PIXEL_FORMAT_RGBA_8888_PRE` | Premultiplied RGBA, 32 bits
`COGL_PIXEL_FORMAT_BGRA_8888_PRE` | Premultiplied BGRA, 32 bits
`COGL_PIXEL_FORMAT_ARGB_8888_PRE` | Premultiplied ARGB, 32 bits
`COGL_PIXEL_FORMAT_ABGR_8888_PRE` | Premultiplied ABGR, 32 bits
`COGL_PIXEL_FORMAT_RGBA_4444_PRE` | Premultiplied RGBA, 16 bits
`COGL_PIXEL_FORMAT_RGBA_5551_PRE` | Premultiplied RGBA, 16 bits
`COGL_PIXEL_FORMAT_RGBA_1010102_PRE` | Premultiplied RGBA, 32 bits, 10 bpc
`COGL_PIXEL_FORMAT_BGRA_1010102_PRE` | Premultiplied BGRA, 32 bits, 10 bpc
`COGL_PIXEL_FORMAT_ARGB_2101010_PRE` | Premultiplied ARGB, 32 bits, 10 bpc
`COGL_PIXEL_FORMAT_ABGR_2101010_PRE` | Premultiplied ABGR, 32 bits, 10 bpc
`COGL_PIXEL_FORMAT_DEPTH_16` |
`COGL_PIXEL_FORMAT_DEPTH_32` |
`COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8` |

Since 0.8

### enum CoglBufferTarget

    typedef enum {
      COGL_WINDOW_BUFFER      = (1 << 1),
      COGL_OFFSCREEN_BUFFER   = (1 << 2)
    } CoglBufferTarget;

Target flags for FBOs.

`COGL_WINDOW_BUFFER` | FIXME
`COGL_OFFSCREEN_BUFFER` | FIXME

Since 0.8

### enum CoglBufferBit

    typedef enum {
      COGL_BUFFER_BIT_COLOR   = 1L<<0,
      COGL_BUFFER_BIT_DEPTH   = 1L<<1,
      COGL_BUFFER_BIT_STENCIL = 1L<<2
    } CoglBufferBit;

Types of auxiliary buffers

`COGL_BUFFER_BIT_COLOR` | Selects the primary color buffer
`COGL_BUFFER_BIT_DEPTH` | Selects the depth buffer
`COGL_BUFFER_BIT_STENCIL` | Selects the stencil buffer

Since 1.0

### enum CoglAttributeType

    typedef enum {
      COGL_ATTRIBUTE_TYPE_BYTE           = 0x1400,
      COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE  = 0x1401,
      COGL_ATTRIBUTE_TYPE_SHORT          = 0x1402,
      COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT = 0x1403,
      COGL_ATTRIBUTE_TYPE_FLOAT          = 0x1406
    } CoglAttributeType;

Data types for the components of a vertex attribute.

`COGL_ATTRIBUTE_TYPE_BYTE` | Data is the same size of a byte
`COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE` | Data is the same size of an unsigned byte
`COGL_ATTRIBUTE_TYPE_SHORT` | Data is the same size of a short integer
`COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT` | Data is the same size of an unsigned short integer
`COGL_ATTRIBUTE_TYPE_FLOAT` | Data is the same size of a float

Since 1.0

### enum CoglColorMask

    typedef enum {
      COGL_COLOR_MASK_NONE = 0,
      COGL_COLOR_MASK_RED = 1L<<0,
      COGL_COLOR_MASK_GREEN = 1L<<1,
      COGL_COLOR_MASK_BLUE = 1L<<2,
      COGL_COLOR_MASK_ALPHA = 1L<<3,
      /* XXX: glib-mkenums is a perl script that can't cope if we split
       * this onto multiple lines! *sigh* */
      COGL_COLOR_MASK_ALL = (COGL_COLOR_MASK_RED | COGL_COLOR_MASK_GREEN | COGL_COLOR_MASK_BLUE | COGL_COLOR_MASK_ALPHA)
    } CoglColorMask;

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.

`COGL_COLOR_MASK_NONE` | None of the color channels are masked
`COGL_COLOR_MASK_RED` | Masks the red color channel
`COGL_COLOR_MASK_GREEN` | Masks the green color channel
`COGL_COLOR_MASK_BLUE` | Masks the blue color channel
`COGL_COLOR_MASK_ALPHA` | Masks the alpha color channel
`COGL_COLOR_MASK_ALL` | All of the color channels are masked

### enum CoglTextureFlags

    typedef enum {
      COGL_TEXTURE_NONE           = 0,
      COGL_TEXTURE_NO_AUTO_MIPMAP = 1 << 0,
      COGL_TEXTURE_NO_SLICING     = 1 << 1,
      COGL_TEXTURE_NO_ATLAS       = 1 << 2
    } CoglTextureFlags;

Flags to pass to the cogl_texture_new_* family of functions.

`COGL_TEXTURE_NONE` | No flags specified
`COGL_TEXTURE_NO_AUTO_MIPMAP` | Disables the automatic generation of the mipmap pyramid from the base level image whenever it is updated. The mipmaps are only generated when the texture is rendered with a mipmap filter so it should be free to leave out this flag when using other filtering modes
`COGL_TEXTURE_NO_SLICING` | Disables the slicing of the texture
`COGL_TEXTURE_NO_ATLAS` | Disables the insertion of the texture inside the texture atlas used by Cogl

Since 1.0

### CoglBool

    typedef int CoglBool;

A boolean data type used throughout the Cogl C api. This should be used in conjunction with the `TRUE` and `FALSE` macro defines for setting and testing boolean values.

Since 2.0

Stability Level: Stable