LwCairoTexture

LwCairoTexture — connection between OpenGL textures and the cairo graphics library

Functions

Types and Values

Object Hierarchy

    GObject
    ╰── LwTexture
        ╰── LwCairoTexture

Description

The LwCairoTexture object allows you to draw directly onto your OpenGL texture by using the cairo graphics library.

Example 7. Using a LwCairoTexture

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
GError *error = NULL;
LwCairoTexture *tex = lw_cairo_texture_new(WIDTH, HEIGHT, error);
cairo_t *cr;

if(error != NULL)
{
    g_warning("Could not create cairo texture: %s", error->message);
    g_error_free(error);
    return;
}

cr = lw_cairo_texture_cairo_create(tex);
// use cairo to draw onto your texture
...
cairo_destroy(cr);

// update the texture everytime you draw on it
lw_cairo_texture_update(tex);

lw_texture_enable( LW_TEXTURE(tex) );
...

Functions

lw_cairo_texture_new ()

LwCairoTexture *
lw_cairo_texture_new (guint width,
                      guint height);

Creates a new cairo texture with a specified size.

Parameters

width

The width of the new texture

 

height

The height of the new texture

 

Returns

A new LwCairoTexture or NULL in case of an error. Use g_object_unref() to free the LwCairoTexture.


lw_cairo_texture_cairo_create ()

cairo_t *
lw_cairo_texture_cairo_create (LwCairoTexture *self);

Creates a cairo context for drawing to the texture. Call lw_cairo_texture_update() to update the texture when you are done with drawing.

Parameters

self

A LwCairoTexture

 

Returns

A newly created cairo context. Free it with cairo_destroy() when you are done with drawing.


lw_cairo_texture_update ()

void
lw_cairo_texture_update (LwCairoTexture *self);

Updates the texture.

Parameters

self

A LwCairoTexture

 

Types and Values

struct LwCairoTexture

struct LwCairoTexture;

Paint on this OpenGL texture with cairo.


struct LwCairoTextureClass

struct LwCairoTextureClass {
};