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)  

caca0.h
Go to the documentation of this file.
1 /*
2  * libcaca Colour ASCII-Art library
3  * Copyright (c) 2002-2012 Sam Hocevar <sam@hocevar.net>
4  * All Rights Reserved
5  *
6  * This library is free software. It comes without any warranty, to
7  * the extent permitted by applicable law. You can redistribute it
8  * and/or modify it under the terms of the Do What the Fuck You Want
9  * to Public License, Version 2, as published by Sam Hocevar. See
10  * http://www.wtfpl.net/ for more details.
11  */
12 
13 /*
14  * This header contains glue code for applications using the pre-1.0
15  * libcaca API.
16  */
17 
18 #ifndef __CACA0_H__
19 #define __CACA0_H__
20 
21 #include <caca.h>
22 
23 #undef __extern
24 #if defined _DOXYGEN_SKIP_ME
25 #elif defined _WIN32 && defined __LIBCACA__ && defined DLL_EXPORT
26 # define __extern extern __declspec(dllexport)
27 #elif defined _WIN32 && !defined __LIBCACA__
28 # define __extern extern __declspec(dllimport)
29 #else
30 # define __extern extern
31 #endif
32 
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37 
38 /* Function emulation */
39 __extern int __caca0_init(void);
40 __extern void __caca0_end(void);
41 __extern unsigned int __caca0_get_event(unsigned int, int);
42 __extern unsigned int __caca0_sqrt(unsigned int);
45 __extern char const *__caca0_get_feature_name(int);
47 __extern caca_dither_t *__caca0_create_bitmap(unsigned int, unsigned int,
48  unsigned int, unsigned int, unsigned long int, unsigned long int,
49  unsigned long int, unsigned long int);
51 __extern char const *__caca0_get_color_name(unsigned char);
52 
53 /* These variables are needed to emulate old non-thread safe behaviour */
56 __extern unsigned char __caca0_fg;
57 __extern unsigned char __caca0_bg;
58 
59 /* This enum still exists in libcaca 1.x, thus cannot be redefined */
60 #define CACA_COLOR_BLACK CACA_BLACK
61 #define CACA_COLOR_BLUE CACA_BLUE
62 #define CACA_COLOR_GREEN CACA_GREEN
63 #define CACA_COLOR_CYAN CACA_CYAN
64 #define CACA_COLOR_RED CACA_RED
65 #define CACA_COLOR_MAGENTA CACA_MAGENTA
66 #define CACA_COLOR_BROWN CACA_BROWN
67 #define CACA_COLOR_LIGHTGRAY CACA_LIGHTGRAY
68 #define CACA_COLOR_DARKGRAY CACA_DARKGRAY
69 #define CACA_COLOR_LIGHTBLUE CACA_LIGHTBLUE
70 #define CACA_COLOR_LIGHTGREEN CACA_LIGHTGREEN
71 #define CACA_COLOR_LIGHTCYAN CACA_LIGHTCYAN
72 #define CACA_COLOR_LIGHTRED CACA_LIGHTRED
73 #define CACA_COLOR_LIGHTMAGENTA CACA_LIGHTMAGENTA
74 #define CACA_COLOR_YELLOW CACA_YELLOW
75 #define CACA_COLOR_WHITE CACA_WHITE
76 
77 /* These enums and macros changed names or values */
79 {
83 #define CACA_BACKGROUND_MIN 0x11
84 #define CACA_BACKGROUND_MAX 0x12
88 #define CACA_ANTIALIASING_MIN 0x21
89 #define CACA_ANTIALIASING_MAX 0x22
96 #define CACA_DITHERING_MIN 0x31
97 #define CACA_DITHERING_MAX 0x35
99 };
100 
101 #if ! defined __LIBCACA__
102 
103 /* This enum still exists in libcaca 1.x, thus cannot be redefined */
104 #define CACA_EVENT_NONE 0x00000000
105 #define CACA_EVENT_KEY_PRESS 0x01000000
106 #define CACA_EVENT_KEY_RELEASE 0x02000000
107 #define CACA_EVENT_MOUSE_PRESS 0x04000000
108 #define CACA_EVENT_MOUSE_RELEASE 0x08000000
109 #define CACA_EVENT_MOUSE_MOTION 0x10000000
110 #define CACA_EVENT_RESIZE 0x20000000
111 #define CACA_EVENT_ANY 0xff000000
112 
113 /* Backwards compatibility macros for even older shit */
114 #define caca_dithering caca_feature
115 #define caca_set_dithering caca_set_feature
116 #define caca_get_dithering_name caca_get_feature_name
117 #define CACA_DITHER_NONE CACA_DITHERING_NONE
118 #define CACA_DITHER_ORDERED CACA_DITHERING_ORDERED8
119 #define CACA_DITHER_RANDOM CACA_DITHERING_RANDOM
120 
121 /* Macros to redefine all the shit */
122 #define caca_init __caca0_init
123 #define caca_set_delay(x) caca_set_display_time(__caca0_dp, x)
124 #define caca_get_feature __caca0_get_feature
125 #define caca_set_feature __caca0_set_feature
126 #define caca_get_feature_name __caca0_get_feature_name
127 #define caca_get_rendertime() caca_get_display_time(__caca0_dp)
128 #define caca_get_width() caca_get_canvas_width(__caca0_cv)
129 #define caca_get_height() caca_get_canvas_height(__caca0_cv)
130 #define caca_set_window_title(s) caca_set_display_title(__caca0_dp, s)
131 #define caca_get_window_width() caca_get_display_width(__caca0_dp)
132 #define caca_get_window_height() caca_get_display_height(__caca0_dp)
133 #define caca_refresh() caca_refresh_display(__caca0_dp)
134 #define caca_end __caca0_end
135 
136 #define caca_get_event(x) __caca0_get_event(x, 0)
137 #define caca_wait_event(x) __caca0_get_event(x, -1)
138 #define caca_get_mouse_x() caca_get_mouse_x(__caca0_dp)
139 #define caca_get_mouse_y() caca_get_mouse_y(__caca0_dp)
140 
141 #define caca_set_color(x, y) \
142  (__caca0_fg = (x), __caca0_bg = (y), caca_set_color_ansi(__caca0_cv, x, y))
143 #define caca_get_fg_color() __caca0_fg
144 #define caca_get_bg_color() __caca0_bg
145 #define caca_get_color_name __caca0_get_color_name
146 #define caca_putchar(x, y, c) caca_put_char(__caca0_cv, x, y, c)
147 #define caca_putstr(x, y, s) caca_put_str(__caca0_cv, x, y, s)
148 #define caca_printf(x, y, f, z...) caca_printf(__caca0_cv, x, y, f, ##z)
149 #define caca_clear() caca_clear_canvas(__caca0_cv)
150 
151 #define caca_draw_line(x, y, z, t, c) \
152  caca_draw_line(__caca0_cv, x, y, z, t, c)
153 #define caca_draw_polyline(x, y, z, c) \
154  caca_draw_polyline(__caca0_cv, x, y, z, c)
155 #define caca_draw_thin_line(x, y, z, t) \
156  caca_draw_thin_line(__caca0_cv, x, y, z, t)
157 #define caca_draw_thin_polyline(x, y, z) \
158  caca_draw_thin_polyline(__caca0_cv, x, y, z)
159 #define caca_draw_circle(x, y, z, c) \
160  caca_draw_circle(__caca0_cv, x, y, z, c)
161 #define caca_draw_ellipse(x, y, z, t, c) \
162  caca_draw_ellipse(__caca0_cv, x, y, z, t, c)
163 #define caca_draw_thin_ellipse(x, y, z, t) \
164  caca_draw_thin_ellipse(__caca0_cv, x, y, z, t)
165 #define caca_fill_ellipse(x, y, z, t, c) \
166  caca_fill_ellipse(__caca0_cv, x, y, z, t, c)
167 #define caca_draw_box(x, y, z, t, c) \
168  caca_draw_box(__caca0_cv, x, y, z, t, c)
169 #define caca_draw_thin_box(x, y, z, t) \
170  caca_draw_thin_box(__caca0_cv, x, y, z, t)
171 #define caca_fill_box(x, y, z, t, c) \
172  caca_fill_box(__caca0_cv, x, y, z, t, c)
173 #define caca_draw_triangle(x, y, z, t, u, v, c) \
174  caca_draw_triangle(__caca0_cv, x, y, z, t, u, v, c)
175 #define caca_draw_thin_triangle(x, y, z, t, u, v) \
176  caca_draw_thin_triangle(__caca0_cv, x, y, z, t, u, v)
177 #define caca_fill_triangle(x, y, z, t, u, v, c) \
178  caca_fill_triangle(__caca0_cv, x, y, z, t, u, v, c)
179 
180 #define caca_rand(a, b) caca_rand(a, (b)+1)
181 #define caca_sqrt __caca0_sqrt
182 
183 #define caca_sprite caca_canvas
184 #define caca_load_sprite __caca0_load_sprite
185 #define caca_get_sprite_frames(c) 1
186 #define caca_get_sprite_width(c, f) caca_get_canvas_width(c)
187 #define caca_get_sprite_height(c, f) caca_get_canvas_height(c)
188 #define caca_get_sprite_dx(c, f) 0
189 #define caca_get_sprite_dx(c, f) 0
190 #define caca_draw_sprite(x, y, c, f) caca_blit(__caca0_cv, x, y, c, NULL)
191 #define caca_free_sprite caca_free_canvas
192 
193 #define caca_bitmap caca_dither
194 #define caca_create_bitmap __caca0_create_bitmap
195 #define caca_set_bitmap_palette caca_set_dither_palette
196 #define caca_draw_bitmap(x, y, z, t, b, p) \
197  caca_dither_bitmap(__caca0_cv, x, y, z, t, b, p)
198 #define caca_free_bitmap __caca0_free_bitmap
199 
200 #endif /* ! defined __LIBCACA__ */
201 
202 #ifdef __cplusplus
203 }
204 #endif
205 
206 #undef __extern
207 
208 #endif /* __CACA0_H__ */
CACA_DITHERING
Definition: caca0.h:90
CACA_DITHERING_ORDERED4
Definition: caca0.h:93
caca_dither
Definition: dither.c:116
CACA_ANTIALIASING_PREFILTER
Definition: caca0.h:87
CACA_DITHERING_NONE
Definition: caca0.h:91
CACA_FEATURE_UNKNOWN
Definition: caca0.h:98
__caca0_create_bitmap
caca_dither_t * __caca0_create_bitmap(unsigned int, unsigned int, unsigned int, unsigned int, unsigned long int, unsigned long int, unsigned long int, unsigned long int)
Definition: caca0.c:225
__caca0_fg
unsigned char __caca0_fg
Definition: caca0.c:29
caca_display
Definition: caca_internals.h:167
__caca0_get_feature_name
const char * __caca0_get_feature_name(int)
Definition: caca0.c:191
CACA_DITHERING_RANDOM
Definition: caca0.h:95
__caca0_load_sprite
caca_canvas_t * __caca0_load_sprite(char const *)
Definition: caca0.c:211
CACA_ANTIALIASING_NONE
Definition: caca0.h:86
caca_feature
caca_feature
Definition: caca0.h:78
CACA_DITHERING_ORDERED8
Definition: caca0.h:94
__extern
#define __extern
Definition: caca0.h:30
__caca0_get_feature
int __caca0_get_feature(int)
Definition: caca0.c:151
__caca0_free_bitmap
void __caca0_free_bitmap(caca_dither_t *)
Definition: caca0.c:248
CACA_BACKGROUND_BLACK
Definition: caca0.h:81
__caca0_bg
unsigned char __caca0_bg
Definition: caca0.c:30
__caca0_end
void __caca0_end(void)
Definition: caca0.c:66
CACA_BACKGROUND_SOLID
Definition: caca0.h:82
__caca0_init
int __caca0_init(void)
Definition: caca0.c:49
caca.h
The libcaca public header.
__caca0_dp
caca_display_t * __caca0_dp
Definition: caca0.c:28
__caca0_get_color_name
const char * __caca0_get_color_name(unsigned char)
Definition: caca0.c:266
CACA_DITHERING_ORDERED2
Definition: caca0.h:92
CACA_BACKGROUND
Definition: caca0.h:80
CACA_ANTIALIASING
Definition: caca0.h:85
__caca0_set_feature
void __caca0_set_feature(int)
Definition: caca0.c:162
__caca0_get_event
unsigned int __caca0_get_event(unsigned int, int)
Definition: caca0.c:74
caca_canvas
Definition: caca_internals.h:47
__caca0_sqrt
unsigned int __caca0_sqrt(unsigned int)
Definition: caca0.c:105
__caca0_cv
caca_canvas_t * __caca0_cv
Definition: caca0.c:27