Ignore:
Timestamp:
Mar 5, 2006, 7:43:13 PM (15 years ago)
Author:
Sam Hocevar
Message:

A new low-level text management library (canvas for ultrafast compositing

of unicode letters) is now separated from the higher level rendering and I/O
(that is, libcaca). This commit totally breaks the API, but once everything
is polished I will think about source-level backward compatibility. Most
drivers are broken, but X11 still sorta works.

The new design is much more object-oriented and allows having several

active renderers at the same time, changing renderers on the fly, and more
important, having no renderer at all (useful for converters, or when you
want to do your own renderer).

And in case you are still wondering, the libcucul acronym has "Unicode"

because I want to support at least a subset of Unicode. There are awesome
glyphs in it, including the ones inherited from Codepage 437 such as
"gray 25%" that are used in DOS and Win32 ANSI art.

Location:
libcaca/trunk/examples
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/examples

    • Property svn:ignore
      •  

        old new  
        33.libs
        44.deps
        5 cacademo
        6 cacademo.exe
        75caca-spritedit
        86caca-spritedit.exe
  • libcaca/trunk/examples/cacaball.c

    r522 r524  
    2323#endif
    2424
     25#include "cucul.h"
    2526#include "caca.h"
    2627
     
    4344int main(int argc, char **argv)
    4445{
     46    cucul_t *qq; caca_t *kk;
    4547    unsigned int r[256], g[256], b[256], a[256];
    4648    float d[METABALLS], di[METABALLS], dj[METABALLS], dk[METABALLS];
    4749    unsigned int x[METABALLS], y[METABALLS];
    48     struct caca_bitmap *caca_bitmap;
     50    struct cucul_bitmap *cucul_bitmap;
    4951    float i = 10.0, j = 17.0, k = 11.0;
    5052    int p, frame = 0, pause = 0;
    5153
    52     if(caca_init())
     54    qq = cucul_init();
     55    if(!qq)
    5356        return 1;
    54 
    55     caca_set_delay(20000);
     57    kk = caca_attach(qq);
     58    if(!kk)
     59        return 1;
     60
     61    caca_set_delay(kk, 20000);
    5662
    5763    /* Make the palette eatable by libcaca */
     
    6066    r[255] = g[255] = b[255] = 0xfff;
    6167
    62     /* Create a libcaca bitmap smaller than our pixel buffer, so that we
     68    /* Create a libcucul bitmap smaller than our pixel buffer, so that we
    6369     * display only the interesting part of it */
    64     caca_bitmap = caca_create_bitmap(8, XSIZ - METASIZE, YSIZ - METASIZE,
    65                                      XSIZ, 0, 0, 0, 0);
     70    cucul_bitmap = cucul_create_bitmap(qq, 8, XSIZ - METASIZE, YSIZ - METASIZE,
     71                                       XSIZ, 0, 0, 0, 0);
    6672
    6773    /* Generate ball sprite */
     
    7076    for(p = 0; p < METABALLS; p++)
    7177    {
    72         d[p] = caca_rand(0, 100);
    73         di[p] = (float)caca_rand(500, 4000) / 6000.0;
    74         dj[p] = (float)caca_rand(500, 4000) / 6000.0;
    75         dk[p] = (float)caca_rand(500, 4000) / 6000.0;
     78        d[p] = cucul_rand(0, 100);
     79        di[p] = (float)cucul_rand(500, 4000) / 6000.0;
     80        dj[p] = (float)cucul_rand(500, 4000) / 6000.0;
     81        dk[p] = (float)cucul_rand(500, 4000) / 6000.0;
    7682    }
    7783
     
    7985    for(;;)
    8086    {
    81         switch(caca_get_event(CACA_EVENT_KEY_PRESS))
     87        switch(caca_get_event(kk, CACA_EVENT_KEY_PRESS))
    8288        {
    8389            case CACA_EVENT_KEY_PRESS | CACA_KEY_ESCAPE: goto end;
     
    110116
    111117        /* Set the palette */
    112         caca_set_bitmap_palette(caca_bitmap, r, g, b, a);
     118        cucul_set_bitmap_palette(qq, cucul_bitmap, r, g, b, a);
    113119
    114120        /* Silly paths for our balls */
     
    135141
    136142paused:
    137         /* Draw our virtual buffer to screen, letting libcaca resize it */
    138         caca_draw_bitmap(0, 0, caca_get_width() - 1, caca_get_height() - 1,
    139                          caca_bitmap, pixels + (METASIZE / 2) * (1 + XSIZ));
    140         caca_refresh();
     143        /* Draw our virtual buffer to screen, letting libcucul resize it */
     144        cucul_draw_bitmap(qq, 0, 0,
     145                          cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
     146                          cucul_bitmap, pixels + (METASIZE / 2) * (1 + XSIZ));
     147        caca_refresh(kk);
    141148    }
    142149
    143150    /* End, bye folks */
    144151end:
    145     caca_free_bitmap(caca_bitmap);
    146     caca_end();
     152    cucul_free_bitmap(qq, cucul_bitmap);
     153    caca_detach(kk);
     154    cucul_end(qq);
    147155
    148156    return 0;
Note: See TracChangeset for help on using the changeset viewer.