libcaca  0.99.beta19
About: libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals (something like an advanced AAlib library).
  Fossies Dox: libcaca-0.99.beta19.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

A libcaca tutorial

First, a very simple working program, to check for basic libcaca functionalities.

What does it do?

  • Create a display. Physically, the display is either a window or a context in a terminal (ncurses, slang) or even the whole screen (VGA).
  • Get the display's associated canvas. A canvas is the surface where everything happens: writing characters, sprites, strings, images... It is unavoidable. Here the size of the canvas is set by the display.
  • Set the display's window name (only available in windowed displays, does nothing otherwise).
  • Set the current canvas colours to black background and white foreground.
  • Write the string "This is a message" onto the canvas, using the current colour pair.
  • Refresh the display, causing the text to be effectively displayed.
  • Wait for an event of type CACA_EVENT_KEY_PRESS.
  • Free the display (release memory). Since it was created together with the display, the canvas will be automatically freed as well.

You can then compile this code on an UNIX-like system using the following commans (requiring pkg-config and gcc):

gcc `pkg-config --libs --cflags caca` example.c -o example
caca
Definition: __init__.py:1
caca_create_display
caca_display_t * caca_create_display(caca_canvas_t *cv)
Attach a caca graphical context to a caca canvas.
Definition: caca.c:68
caca_event
Handling of user events.
Definition: caca.h:129
caca_display
Definition: caca_internals.h:167
CACA_WHITE
Definition: caca.h:86
caca_put_str
int caca_put_str(caca_canvas_t *, int, int, char const *)
Print a string.
Definition: string.c:254
caca_get_canvas
caca_canvas_t * caca_get_canvas(caca_display_t *dp)
Get the canvas attached to a caca graphical context.
Definition: caca.c:259
cv
caca_canvas_t * cv
Definition: cacaview.c:45
caca_refresh_display
int caca_refresh_display(caca_display_t *)
Flush pending changes and redraw the screen.
Definition: graphics.c:146
caca_free_display
int caca_free_display(caca_display_t *dp)
Detach a caca graphical context from a caca backend context.
Definition: caca.c:238
CACA_BLACK
Definition: caca.h:71
caca_set_display_title
int caca_set_display_title(caca_display_t *, char const *)
Set the display title.
Definition: graphics.c:40
caca_set_color_ansi
int caca_set_color_ansi(caca_canvas_t *cv, uint8_t fg, uint8_t bg)
Set the default colour pair for text (ANSI version).
Definition: attr.c:234
caca.h
The libcaca public header.
caca_get_event
#define caca_get_event(x)
Definition: caca0.h:136
CACA_EVENT_KEY_PRESS
Definition: caca.h:111
dp
caca_display_t * dp
Definition: cacaview.c:45
caca_canvas
Definition: caca_internals.h:47
main
int main(int argc, char *argv[])
Definition: cxxtest.cpp:39