Ignore:
Timestamp:
Dec 12, 2003, 3:49:41 PM (19 years ago)
Author:
Sam Hocevar
Message:
  • src/bitmap.c: + Added antialiasing support. + Dithering, antialiasing and background mode can now be selected at

runtime.

  • src/caca.c src/caca.h: + Renamed caca_dithering into caca_feature and extended the type to

express background colour and antialiasing mode.

  • examples/demo.c: + Fixed a bug that disabled the sprite demo. + Draw solid flares.
  • examples/view.c: + Select antialiasing and background mode at runtime.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/src/caca.c

    r247 r249  
    4949#include "caca_internals.h"
    5050
     51static void caca_init_features(void);
    5152static void caca_init_terminal(void);
    5253
     
    6162#endif
    6263
     64    caca_init_features();
    6365    caca_init_terminal();
    6466
     
    157159}
    158160
    159 const char *caca_get_dithering_name(enum caca_dithering dithering)
    160 {
    161     static const char *dithering_names[] =
    162     {
    163         "no",
    164         "2x2 ordered",
    165         "4x4 ordered",
    166         "8x8 ordered",
    167         "random"
    168     };
    169 
    170     if(dithering < 0 || dithering > 4)
    171         return "unknown";
    172 
    173     return dithering_names[dithering];
     161enum caca_feature caca_get_feature(enum caca_feature feature)
     162{
     163    switch(feature)
     164    {
     165        case CACA_BACKGROUND:
     166            return _caca_background;
     167        case CACA_ANTIALIASING:
     168            return _caca_antialiasing;
     169        case CACA_DITHERING:
     170            return _caca_dithering;
     171
     172        default:
     173            return CACA_UNKNOWN_FEATURE;
     174    }
     175}
     176
     177void caca_set_feature(enum caca_feature feature)
     178{
     179    switch(feature)
     180    {
     181        case CACA_BACKGROUND:
     182            feature = CACA_BACKGROUND_SOLID;
     183        case CACA_BACKGROUND_BLACK:
     184        case CACA_BACKGROUND_SOLID:
     185            _caca_background = feature;
     186            break;
     187
     188        case CACA_ANTIALIASING:
     189            feature = CACA_ANTIALIASING_PREFILTER;
     190        case CACA_ANTIALIASING_NONE:
     191        case CACA_ANTIALIASING_PREFILTER:
     192            _caca_antialiasing = feature;
     193            break;
     194
     195        case CACA_DITHERING:
     196            feature = CACA_DITHERING_ORDERED4;
     197        case CACA_DITHERING_NONE:
     198        case CACA_DITHERING_ORDERED2:
     199        case CACA_DITHERING_ORDERED4:
     200        case CACA_DITHERING_ORDERED8:
     201        case CACA_DITHERING_RANDOM:
     202            _caca_dithering = feature;
     203            break;
     204
     205        case CACA_UNKNOWN_FEATURE:
     206            break;
     207    }
     208}
     209
     210const char *caca_get_feature_name(enum caca_feature feature)
     211{
     212    switch(feature)
     213    {
     214        case CACA_BACKGROUND_BLACK: return "black background";
     215        case CACA_BACKGROUND_SOLID: return "solid background";
     216
     217        case CACA_ANTIALIASING_NONE:      return "no antialiasing";
     218        case CACA_ANTIALIASING_PREFILTER: return "prefilter antialiasing";
     219
     220        case CACA_DITHERING_NONE:     return "no dithering";
     221        case CACA_DITHERING_ORDERED2: return "2x2 ordered dithering";
     222        case CACA_DITHERING_ORDERED4: return "4x4 ordered dithering";
     223        case CACA_DITHERING_ORDERED8: return "8x8 ordered dithering";
     224        case CACA_DITHERING_RANDOM:   return "random dithering";
     225
     226        default: return "unknown";
     227    }
    174228}
    175229
     
    195249}
    196250
     251static void caca_init_features(void)
     252{
     253    caca_set_feature(CACA_BACKGROUND);
     254    caca_set_feature(CACA_ANTIALIASING);
     255    caca_set_feature(CACA_DITHERING);
     256}
     257
    197258static void caca_init_terminal(void)
    198259{
Note: See TracChangeset for help on using the changeset viewer.