Ignore:
Timestamp:
Sep 27, 2008, 4:29:11 PM (12 years ago)
Author:
Sam Hocevar
Message:

Continuing the libcucul-libcaca merge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/doc/tutorial.dox

    r2189 r2824  
    11/* $Id$ */
    22
    3 /** \page libcaca-tutorial A libcucul and libcaca tutorial
    4 
    5  Before writing your first libcaca application, you need to know the difference between libcucul and libcaca :
    6 - libcucul is the text rendering library. It will do all the work you actually need. From imports (text, ANSI, caca internal format, all of this supporting n-bytes unicode), to exports (sames formats, adding SVG, PostScript, TGA, HTML (both 3 and 4), IRC), it'll cover all your needs.
    7 - libcaca handle everything that can be hardware related. It includes display (RAW, X11, OpenGL, Windows (native console), DOS (conio), ncurses, slang, text VGA (IMB-Compatible)), keyboard (same drivers but RAW), mouse (same drivers but RAW and VGA), time and resize events (on windowed drivers).
    8 
    9 So, you can write a libcucul only program, but you <b>can't</b> write a libcaca only program, it'll be nonsense. Period.
    10 
     3/** \page libcaca-tutorial A libcaca tutorial
    114
    125First, a working program, very simple, to check you can compile and run it:
     
    147\code
    158
    16 #include <cucul.h>
     9#include <caca.h>
    1710#include <caca.h>
    1811
     
    2013{
    2114    /* Initialise libcaca */
    22     cucul_canvas_t *cv; caca_display_t *dp; caca_event_t ev;
     15    caca_canvas_t *cv; caca_display_t *dp; caca_event_t ev;
    2316    dp = caca_create_display(NULL);
    2417    if(!dp) return 1;
     
    2720    caca_set_display_title(dp, "Hello!");
    2821    /* Choose drawing colours */
    29     cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE);
     22    caca_set_color_ansi(cv, CACA_BLACK, CACA_WHITE);
    3023    /* Draw a string at coordinates (0, 0) */
    31     cucul_put_str(cv, 0, 0, "This is a message");
     24    caca_put_str(cv, 0, 0, "This is a message");
    3225    /* Refresh display */
    3326    caca_refresh_display(dp);
     
    4437
    4538What does it do ? (we skip variable definitions, guessing you have a brain) :
    46 - Create a cucul canvas. A canvas is where everything happens. Writing characters, sprites, strings, images, everything. It is mandatory and is the reason of libcuculs' beeing. Size is there a width of 0 pixels, and a height of 0 pixels. It'll be resized according to contents you put in it.
     39- Create a caca canvas. A canvas is where everything happens. Writing characters, sprites, strings, images, everything. It is mandatory and is the reason of libcacas' beeing. Size is there a width of 0 pixels, and a height of 0 pixels. It'll be resized according to contents you put in it.
    4740
    4841- Create a caca display. This is basically the window. Physically it can be a window (most of the displays), a console (ncurses, slang) or a real display (VGA).
     
    5043- Set the window name of our display (only available in windowed displays, does nothing otherwise). (so this is libcaca related)
    5144 
    52 - Set current colors to black background, and white foreground of our canvas (so this is libcucul related)
     45- Set current colors to black background, and white foreground of our canvas (so this is libcaca related)
    5346
    54 - Put a string "This is a message" with current colors in our libcucul canvas.
     47- Put a string "This is a message" with current colors in our libcaca canvas.
    5548
    5649- Refresh our caca display, whish was firstly attached to our canvas
     
    6558You can then compile this code under UNIX-like systems with following command : (you'll need pkg-config and gcc)
    6659\code
    67 gcc `pkg-config --libs --cflags cucul caca` example.c -o example
     60gcc `pkg-config --libs --cflags caca` example.c -o example
    6861\endcode
    6962
Note: See TracChangeset for help on using the changeset viewer.