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

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