Clutter::Cogl(3) Abstraction over programmable GPUs


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.


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)


Restore the current model-view matrix from the matrix stack


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


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'


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.