source: libcaca/trunk/caca/caca_internals.h @ 543

Last change on this file since 543 was 543, checked in by Sam Hocevar, 14 years ago
  • Fixed DOS driver.
  • Added a build-dos script to cross-compile the DOS version using djgpp.
  • Property svn:keywords set to Id
File size: 4.7 KB
Line 
1/*
2 *  libcaca       ASCII-Art library
3 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  This library is free software; you can redistribute it and/or
7 *  modify it under the terms of the Do What The Fuck You Want To
8 *  Public License, Version 2, as published by Sam Hocevar. See
9 *  http://sam.zoy.org/wtfpl/COPYING for more details.
10 */
11
12/** \file caca_internals.h
13 *  \version \$Id: caca_internals.h 543 2006-03-07 12:39:34Z sam $
14 *  \author Sam Hocevar <sam@zoy.org>
15 *  \brief The \e libcaca private header.
16 *
17 *  This header contains the private types and functions used by \e libcaca.
18 */
19
20#ifndef __CACA_INTERNALS_H__
21#define __CACA_INTERNALS_H__
22
23#if defined(HAVE_INTTYPES_H) || defined(_DOXYGEN_SKIP_ME)
24#   include <inttypes.h>
25#elif !defined(CUSTOM_INTTYPES)
26#   define CUSTOM_INTTYPES
27typedef unsigned char uint8_t;
28typedef unsigned short uint16_t;
29typedef unsigned int uint32_t;
30#endif
31
32#if defined(USE_CONIO)
33#   include <conio.h>
34#endif
35#if defined(USE_GL)
36#   include <GL/glut.h>
37#endif
38#if defined(USE_NCURSES)
39#   if defined(HAVE_NCURSES_H)
40#       include <ncurses.h>
41#   else
42#       include <curses.h>
43#   endif
44#endif
45#if defined(USE_WIN32)
46#   include <windows.h>
47#endif
48#if defined(USE_X11)
49#   include <X11/Xlib.h>
50#endif
51
52#if !defined(_DOXYGEN_SKIP_ME)
53#   define EVENTBUF_LEN 10
54#endif
55
56/* Graphics driver */
57enum caca_driver
58{
59#if defined(USE_CONIO)
60    CACA_DRIVER_CONIO = 1,
61#endif
62#if defined(USE_NCURSES)
63    CACA_DRIVER_NCURSES = 2,
64#endif
65#if defined(USE_SLANG)
66    CACA_DRIVER_SLANG = 3,
67#endif
68#if defined(USE_X11)
69    CACA_DRIVER_X11 = 4,
70#endif
71#if defined(USE_WIN32)
72    CACA_DRIVER_WIN32 = 5,
73#endif
74#if defined(USE_GL)
75    CACA_DRIVER_GL = 6,
76#endif
77    CACA_DRIVER_NONE = 0
78};
79
80/* Available drivers */
81#if defined(USE_CONIO)
82void conio_init_driver(caca_t *);
83#endif
84#if defined(USE_GL)
85void gl_init_driver(caca_t *);
86#endif
87#if defined(USE_NCURSES)
88void ncurses_init_driver(caca_t *);
89#endif
90#if defined(USE_SLANG)
91void slang_init_driver(caca_t *);
92#endif
93#if defined(USE_WIN32)
94void win32_init_driver(caca_t *);
95#endif
96#if defined(USE_X11)
97void x11_init_driver(caca_t *);
98#endif
99
100/* Timer structure */
101struct caca_timer
102{
103    int last_sec, last_usec;
104};
105
106/* Internal caca context */
107struct caca_context
108{
109    cucul_t *qq;
110
111    struct driver
112    {
113        enum caca_driver driver;
114
115        int (* init_graphics) (caca_t *);
116        int (* end_graphics) (caca_t *);
117        int (* set_window_title) (caca_t *, char const *);
118        unsigned int (* get_window_width) (caca_t *);
119        unsigned int (* get_window_height) (caca_t *);
120        void (* display) (caca_t *);
121        void (* handle_resize) (caca_t *, unsigned int *, unsigned int *);
122    } driver;
123
124    //unsigned int width, height;
125    unsigned int mouse_x, mouse_y;
126
127    int resize;
128    int resize_event;
129
130    unsigned int delay, rendertime;
131    struct caca_timer timer;
132    int lastticks;
133
134    struct events
135    {
136#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO)
137        unsigned int buf[EVENTBUF_LEN];
138        int queue;
139#endif
140#if defined(USE_SLANG) || defined(USE_NCURSES)
141        struct caca_timer key_timer;
142        unsigned int last_key_ticks;
143        unsigned int autorepeat_ticks;
144        unsigned int last_key;
145#endif
146    } events;
147
148    /* FIXME: maybe this should go away */
149#if defined(USE_X11) && !defined(_DOXYGEN_SKIP_ME)
150    struct x11
151    {
152        Display *dpy;
153        Window window;
154        Pixmap pixmap;
155        GC gc;
156        long int event_mask;
157        int font_width, font_height;
158        unsigned int new_width, new_height;
159        int colors[16];
160        Font font;
161        XFontStruct *font_struct;
162        int font_offset;
163#if defined(HAVE_X11_XKBLIB_H)
164        Bool autorepeat;
165#endif
166    } x11;
167#endif
168#if defined(USE_NCURSES)
169    struct ncurses
170    {
171        int attr[16*16];
172        mmask_t oldmask;
173    } ncurses;
174#endif
175#if defined(USE_CONIO)
176    struct conio
177    {
178        struct text_info ti;
179        char *screen;
180    } conio;
181#endif
182#if defined(USE_WIN32)
183    struct win32
184    {
185        HANDLE hin, hout;
186        HANDLE front, back;
187        CHAR_INFO *buffer;
188        CONSOLE_CURSOR_INFO cci;
189    } win32;
190#endif
191#if defined(USE_GL)
192    struct gl
193    {
194        int window;
195        unsigned int width, height;
196        float font_width, font_height;
197        float incx, incy;
198        int id[94];
199        unsigned char resized, bit;
200        unsigned char mouse_changed, mouse_clicked;
201        unsigned int mouse_x, mouse_y;
202        unsigned int mouse_button, mouse_state;
203
204        unsigned char key;
205        int special_key;
206        int new_width;
207        int new_height;
208
209        float sw, sh;
210    } gl;
211#endif
212};
213
214/* Timer functions */
215extern void _caca_sleep(unsigned int);
216extern unsigned int _caca_getticks(struct caca_timer *);
217
218#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.