Next: , Previous: ClutterStage, Up: Top


35 ClutterTexture

An actor for displaying and manipulating images.

35.1 Overview

<clutter-texture> is a base class for displaying and manipulating pixel buffer type data.

The clutter-texture-set-from-rgb-data and clutter-texture-set-from-file functions are used to copy image data into texture memory and subsequently realize the texture.

If texture reads are supported by underlying GL implementation, unrealizing frees image data from texture memory moving to main system memory. Re-realizing then performs the opposite operation. This process allows basic management of commonly limited available texture memory.

Note: a ClutterTexture will scale its contents to fit the bounding box requested using clutter-actor-set-size. To display an area of a texture without scaling, you should set the clip area using clutter-actor-set-clip.

35.2 Usage

— Class: <clutter-texture>

Derives from <clutter-actor>.

This class defines the following slots:

disable-slicing
Force the underlying texture to be singlularand not made of of smaller space saving inidivual textures.
tile-waste
Max wastage dimension of a texture when using sliced textures or -1 to disable slicing. Bigger values use less textures, smaller values less texture memory.
pixel-format
CoglPixelFormat to use.
sync-size
Auto sync size of actor to underlying pixbuf dimensions
repeat-y
Repeat underlying pixbuf rather than scale in y direction.
repeat-x
Repeat underlying pixbuf rather than scale in x direction.
filter-quality
Rendering quality used when drawing the texture.
cogl-texture
The underlying COGL texture handle used to draw this actor
filename
The full path of the file containing the texture
keep-aspect-ratio
Keep the aspect ratio of the texture when requesting the preferred width or height
— Signal on <clutter-texture>: size-change (arg0 <gint>) (arg1 <gint>)

The ::size-change signal is emitted each time the size of the pixbuf used by texture changes. The new size is given as argument to the callback.

— Signal on <clutter-texture>: pixbuf-change

The ::pixbuf-change signal is emitted each time the pixbuf used by texture changes.

— Function: clutter-texture-new   (ret <clutter-actor>)

Creates a new empty <clutter-texture> object.

ret
A newly created <clutter-texture> object.
— Function: clutter-texture-new-from-file (filename mchars)   (ret <clutter-actor>)

Creates a new ClutterTexture actor to display the image contained a file. If the image failed to load then NULL is returned and error is set.

filename
The name of an image file to load.
error
Return locatoin for an error.
ret
A newly created <clutter-texture> object or NULL on error.

Since 0.8

— Function: clutter-texture-new-from-actor (actor <clutter-actor>)   (ret <clutter-actor>)

Creates a new <clutter-texture> object with its source a prexisting actor (and associated children). The textures content will contain 'live' redirected output of the actors scene.

Note this function is intented as a utility call for uniformly applying shaders to groups and other potential visual effects. It requires that the ‘CLUTTER_FEATURE_OFFSCREEN’ feature is supported by the current backend and the target system.

Some tips on usage:

The source actor must be made visible (i.e by calling <clutter-actor-show>). The source actor does not however have to have a parent.

Avoid reparenting the source with the created texture.

A group can be padded with a transparent rectangle as to provide a border to contents for shader output (blurring text for example).

The texture will automatically resize to contain a further transformed source. However, this involves overhead and can be avoided by placing the source actor in a bounding group sized large enough to contain any child tranformations.

Uploading pixel data to the texture (e.g by using clutter-actor-set-from-file) will destroy the offscreen texture data and end redirection.

cogl-texture-get-data with the handle returned by clutter-texture-get-cogl-texture can be used to read the offscreen texture pixels into a pixbuf.

actor
A source <clutter-actor>
ret
A newly created <clutter-texture> object, or ‘#f’ on failure.

Since 0.6

— Function: clutter-texture-set-from-file (self <clutter-texture>) (filename mchars)   (ret bool)
— Method: set-from-file

Sets the <clutter-texture> image data from an image file. In case of failure, ‘#f’ is returned and error is set.

texture
A <clutter-texture>
filename
The filename of the image in GLib file name encoding
error
Return location for a <g-error>, or ‘#f
ret
#t’ if the image was successfully loaded and set

Since 0.8

— Function: clutter-texture-get-base-size (self <clutter-texture>)   (width int) (height int)
— Method: get-base-size

Gets the size in pixels of the untransformed underlying texture pixbuf data.

texture
A <clutter-texture>
width
Pointer to gint to be populated with width value if non NULL.
height
Pointer to gint to be populated with height value if non NULL.
— Function: clutter-texture-set-filter-quality (self <clutter-texture>) (filter_quality <clutter-texture-quality>)
— Method: set-filter-quality

Sets the filter quality when scaling a texture. The quality is an enumeration currently the following values are supported: ‘CLUTTER_TEXTURE_QUALITY_LOW’ which is fast but only uses nearest neighbour interpolation. ‘CLUTTER_TEXTURE_QUALITY_MEDIUM’ which is computationally a bit more expensive (bilinear interpolation), and ‘CLUTTER_TEXTURE_QUALITY_HIGH’ which uses extra texture memory resources to improve scaled down rendering as well (by using mipmaps). The default value is ‘CLUTTER_TEXTURE_QUALITY_MEDIUM’.

texture
a <clutter-texture>
filter-quality
new filter quality value

Since 0.8

— Function: clutter-texture-get-max-tile-waste (self <clutter-texture>)   (ret int)
— Method: get-max-tile-waste

Gets the maximum waste that will be used when creating a texture or -1 if slicing is disabled.

texture
A <clutter-texture>
ret
The maximum waste or -1 if the texture waste is unlimited.

Since 0.8

— Function: clutter-texture-set-max-tile-waste (self <clutter-texture>) (max_tile_waste int)
— Method: set-max-tile-waste

Sets the maximum number of pixels in either axis that can be wasted for an individual texture slice. If -1 is specified then the texture is forced not to be sliced and the texture creation will fail if the hardware can't create a texture large enough.

The value is only used when first creating a texture so changing it after the texture data has been set has no effect.

texture
A <clutter-texture>
max-tile-waste
Maximum amount of waste in pixels or -1

Since 0.8