---
name: "Clutter::Cogl"
section: "3pm"
platform: "linux"
package: "libclutter-perl"
version: "1.002-1"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/Clutter::Cogl"
---

# Clutter::Cogl(3pm)

Abstraction over programmable GPUs Clutter::Cogl is an abstraction API over GL and GLES, and it is used internally by Clutter to allow portability between platforms. The Clutter::Cogl API is low-level and it is meant to be used only when creating new Clutter::Actor classes. Clutter::Cogl tries to provide an API that is nicer and more understandable than the raw OpenGL API (as exposed, for instance, by the Perl OpenGL wrapper module).

## NAME

Clutter::Cogl - Abstraction over programmable GPUs

**Clutter::Cogl** is an abstraction API over GL and GLES, and it is used internally by Clutter to allow portability between platforms.

The Clutter::Cogl API is low-level and it is meant to be used only when creating new Clutter::Actor classes.

Clutter::Cogl tries to provide an API that is nicer and more understandable than the raw OpenGL API (as exposed, for instance, by the Perl OpenGL wrapper module).

## METHODS

### boolean = Clutter::Cogl-\>get\_backface\_culling\_enabled

### Clutter::Cogl-\>set\_backface\_culling\_enabled ($enabled)

- •

  `$enabled` (boolean)

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 Clutter::Cogl::rectangle\* family of functions and Clutter::Cogl::VertexBuffer::draw\*.

Backface culling is disabled by default.

### boolean = Clutter::Cogl-\>check\_extension ($name, $ext)

- •

  `$name` (string)

- •

  `$ext` (string)

Checks whether *name* occurs in the list of extensions inside *ext*

### Clutter::Cogl-\>clear ($color, $buffers)

- •

  `$color` (array of R, G, B, A values)

- •

  `$buffers` (Clutter::Cogl::BufferBit)

Clears all the auxiliary buffers identified in the *buffers mask*, and if that includes the color buffer then the specified *color* is used.

### boolean = Clutter::Cogl-\>get\_depth\_test\_enabled

### Clutter::Cogl-\>set\_depth\_test\_enabled ($enabled)

- •

  `$enabled` (boolean)

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.

### Clutter::Cogl-\>disable\_fog

### boolean = Clutter::Cogl-\>features\_available ($features)

- •

  `$features` (Clutter::Cogl::FeatureFlags)

Checks whether the given *features* are available.

### featureflags = Clutter::Cogl-\>get\_features

Retrieves all the features supported by Cogl on the current platform

### Clutter::Cogl-\>set\_fog ($fog\_color, $mode, $density, $z\_near, $z\_far)

- •

  `$fog_color` (array of R, G, B, A values)

- •

  `$mode` (Clutter::Cogl::FogMode)

- •

  `$density` (double)

- •

  `$z_near` (double)

- •

  `$z_far` (double)

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 its 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 *Clutter::Cogl::disable\_fog()*.

**Note**: The fogging functions only work correctly when primitives use unmultiplied alpha colors. By default Cogl will premultiply textures and *Clutter::Cogl::set\_source\_color()* will premultiply colors, so unless you explicitly load your textures requesting an unmultiplied internal format and use *Clutter::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.

### Clutter::Cogl-\>frustum ($left, $right, $bottom, $top, $z\_near, $z\_far)

- •

  `$left` (double)

- •

  `$right` (double)

- •

  `$bottom` (double)

- •

  `$top` (double)

- •

  `$z_near` (double)

- •

  `$z_far` (double)

Replaces the current projection matrix with a perspective matrix for the given viewing frustum

### Clutter::Cogl-\>ortho ($left, $right, $bottom, $top, $z\_near, $z\_far)

- •

  `$left` (double)

- •

  `$right` (double)

- •

  `$bottom` (double)

- •

  `$top` (double)

- •

  `$z_near` (double)

- •

  `$z_far` (double)

Replaces the current projection matrix with a parallel projection matrix

### Clutter::Cogl-\>perspective ($fovy, $aspect, $z\_near, $z\_far)

- •

  `$fovy` (double)

- •

  `$aspect` (double)

- •

  `$z_near` (double)

- •

  `$z_far` (double)

Replaces the current projection matrix with a perspective matrix based on the provided values

### Clutter::Cogl-\>polygon ($vertices, $use\_color)

- •

  `$vertices` (scalar)

- •

  `$use_color` (boolean)

### Clutter::Cogl-\>pop\_matrix

Restore the current model-view matrix from the matrix stack

### Clutter::Cogl-\>push\_matrix

Stores the current model-view matrix on the matrix stack. The matrix can later be restored with Clutter::Cogl-\>*pop\_matrix()*

### Clutter::Cogl-\>rectangle ($x1, $y1, $x2, $y2)

- •

  `$x1` (double)

- •

  `$y1` (double)

- •

  `$x2` (double)

- •

  `$y2` (double)

Fills a rectangle at the given coordinates with the current drawing material in a highly optimizied fashion

### Clutter::Cogl-\>rectangle\_with\_texture\_coords ($x1, $y1, $x2, $y2, $tx1, $ty1, $tx2, $ty2)

- •

  `$x1` (double)

- •

  `$y1` (double)

- •

  `$x2` (double)

- •

  `$y2` (double)

- •

  `$tx1` (double)

- •

  `$ty1` (double)

- •

  `$tx2` (double)

- •

  `$ty2` (double)

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 and *ty2*=1.0.

### Clutter::Cogl-\>rectangles ($vertices)

- •

  `$vertices` (scalar)

Draws a series of rectangles in the same way that *Clutter::Cogl::rectangle()* does. In some situations it can give a significant performance boost to use this function rather than calling *Clutter::Cogl::rectangle()* separately for each rectangle.

The *vertices* array reference should point to an array of floating point values. Each group of 4 values corresponds to the parameters x1, y1, x2, and y2, and have the same meaning as in *Clutter::Cogl::rectangle()*.

### Clutter::Cogl-\>rectangles\_with\_texture\_coords ($vertices)

- •

  `$vertices` (scalar)

### Clutter::Cogl-\>rotate ($angle, $x, $y, $z)

- •

  `$angle` (double)

- •

  `$x` (double)

- •

  `$y` (double)

- •

  `$z` (double)

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

### Clutter::Cogl-\>scale ($x, $y, $z)

- •

  `$x` (double)

- •

  `$y` (double)

- •

  `$z` (double)

Multiplies the current model-view matrix by one that scales the *x*, *y* and *z* axes by the given values

### Clutter::Cogl-\>set\_source\_color ($color)

- •

  `$color` (array of R, G, B, A values)

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.

### Clutter::Cogl-\>set\_source ($material)

- •

  `$material` (handle)

This function sets the source material that will be used to fill subsequent geometry emitted via the cogl API.

**Note**: in the future we may add the ability to set a front facing material, and a back facing material, in which case this function will set both to the same.

### Clutter::Cogl-\>set\_source\_texture ($texture)

- •

  `$texture` (handle)

This is a convenience function for creating a material with the first layer set to *texture* and setting that material as the source with *Clutter::Cogl::set\_source()*

**Note**: There is no interaction between calls to Clutter::Cogl::set\_source\_color and *Clutter::Cogl::set\_source\_texture()*. If you need to blend a texture with a color then you can create a simple material like this:

```
    $material = Clutter::Cogl::Material->new ();
    $material->set_color (material, (0xff, 0x00, 0x00, 0x80));
    $material->set_layer (material, 0, texture);
    Clutter::Cogl->set_source ($material);
```

### Clutter::Cogl-\>translate ($x, $y, $z)

- •

  `$x` (double)

- •

  `$y` (double)

- •

  `$z` (double)

Multiplies the current model-view matrix by one that translates the model along all three axes according to the given values

### Clutter::Cogl-\>viewport ($width, $height)

- •

  `$width` (integer)

- •

  `$height` (integer)

Replace the current viewport with the given values.

### (x, y, width, height) = Clutter::Cogl-\>get\_viewport

Retrieves the size of the current viewport

## ENUMS AND FLAGS

### flags Clutter::Cogl::BufferBit

- •

  'color' / 'COGL\_BUFFER\_BIT\_COLOR'

- •

  'depth' / 'COGL\_BUFFER\_BIT\_DEPTH'

- •

  'stencil' / 'COGL\_BUFFER\_BIT\_STENCIL'

### flags Clutter::Cogl::FeatureFlags

- •

  'texture-rectangle' / 'COGL\_FEATURE\_TEXTURE\_RECTANGLE'

- •

  'texture-npot' / 'COGL\_FEATURE\_TEXTURE\_NPOT'

- •

  'texture-yuv' / 'COGL\_FEATURE\_TEXTURE\_YUV'

- •

  'texture-read-pixels' / 'COGL\_FEATURE\_TEXTURE\_READ\_PIXELS'

- •

  'shaders-glsl' / 'COGL\_FEATURE\_SHADERS\_GLSL'

- •

  'offscreen' / 'COGL\_FEATURE\_OFFSCREEN'

- •

  'offscreen-multisample' / 'COGL\_FEATURE\_OFFSCREEN\_MULTISAMPLE'

- •

  'offscreen-blit' / 'COGL\_FEATURE\_OFFSCREEN\_BLIT'

- •

  'four-clip-planes' / 'COGL\_FEATURE\_FOUR\_CLIP\_PLANES'

- •

  'stencil-buffer' / 'COGL\_FEATURE\_STENCIL\_BUFFER'

- •

  'vbos' / 'COGL\_FEATURE\_VBOS'

### enum Clutter::Cogl::FogMode

- •

  'linear' / 'COGL\_FOG\_MODE\_LINEAR'

- •

  'exponential' / 'COGL\_FOG\_MODE\_EXPONENTIAL'

- •

  'exponential-squared' / 'COGL\_FOG\_MODE\_EXPONENTIAL\_SQUARED'

## SEE ALSO

Clutter

## COPYRIGHT

Copyright (C) 2006, 2007, 2008  OpenedHand Ltd

Copyright (C) 2009  Intel Corporation

This module is free software; you can redistribute it and/or modify it under the terms of either:

- •

  the GNU Lesser General Public Library version 2.1; or

- •

  the Artistic License, version 2.0.

See Clutter for the full copyright notice.
