source: libcaca/trunk/caca/caca0.h @ 3604

Last change on this file since 3604 was 3604, checked in by Sam Hocevar, 10 years ago

Since caca.h now exports variables, we need declspec(dllimport), otherwise
they won't be seen by the linker when linking dynamically. Fix caca0.h
accordingly.

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