source: libcaca/trunk/src/caca_internals.h @ 527

Last change on this file since 527 was 527, checked in by Sam Hocevar, 14 years ago
  • All output plugins should now work again.
  • Renamed caca_refresh() into caca_display() which makes more sense.
  • Optimised gl_bgpal by directly storing floats instead of doing the conversion at runtime.
  • Handle resizing in cucul_set_size() and try to keep as much information as possible from the previous canvas.
  • Moved most global variables into cucul_t or caca_t contexts.
  • Moved time.c into libcaca.
  • Property svn:keywords set to Id
File size: 3.5 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 527 2006-03-06 08:32:40Z 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(USE_X11)
24#include <X11/Xlib.h>
25#endif
26
27/* Graphics driver */
28enum caca_driver
29{
30#if defined(USE_CONIO)
31    CACA_DRIVER_CONIO = 1,
32#endif
33#if defined(USE_NCURSES)
34    CACA_DRIVER_NCURSES = 2,
35#endif
36#if defined(USE_SLANG)
37    CACA_DRIVER_SLANG = 3,
38#endif
39#if defined(USE_X11)
40    CACA_DRIVER_X11 = 4,
41#endif
42#if defined(USE_WIN32)
43    CACA_DRIVER_WIN32 = 5,
44#endif
45#if defined(USE_GL)
46    CACA_DRIVER_GL = 6,
47#endif
48    CACA_DRIVER_NONE = 0
49};
50
51/* Timer structure */
52struct caca_timer
53{
54    int last_sec, last_usec;
55};
56
57/* Internal caca context */
58struct caca_context
59{
60    cucul_t *qq;
61
62    enum caca_driver driver;
63    unsigned int width, height;
64
65    int resize;
66    int resize_event;
67
68    unsigned int delay, rendertime;
69    struct caca_timer timer;
70    int lastticks;
71
72    struct events
73    {
74#if defined(USE_SLANG) || defined(USE_NCURSES)
75        struct caca_timer key_timer;
76        unsigned int last_key_ticks;
77        unsigned int autorepeat_ticks;
78        unsigned int last_key;
79#endif
80    } events;
81
82#if defined(USE_X11) && !defined(_DOXYGEN_SKIP_ME)
83    struct x11
84    {
85        Display *dpy;
86        Window window;
87        Pixmap pixmap;
88        GC gc;
89        long int event_mask;
90        int font_width, font_height;
91        unsigned int new_width, new_height;
92        int colors[16];
93        Font font;
94        XFontStruct *font_struct;
95        int font_offset;
96#if defined(HAVE_X11_XKBLIB_H)
97        Bool autorepeat;
98#endif
99    } x11;
100#endif
101#if defined(USE_NCURSES)
102    struct ncurses
103    {
104        int attr[16*16];
105    } ncurses;
106#endif
107#if defined(USE_CONIO)
108    struct conio
109    {
110        struct text_info ti;
111        char *screen;
112    } conio;
113#endif
114#if defined(USE_WIN32)
115    struct win32
116    {
117        HANDLE hin, hout;
118        HANDLE front, back;
119        CHAR_INFO *buffer;
120    } win32;
121#endif
122#if defined(USE_GL)
123    struct gl
124    {
125        int window;
126        unsigned int width, height;
127        float font_width, font_height;
128        float incx, incy;
129        int id[94];
130        unsigned char resized, bit;
131        unsigned char mouse_changed, mouse_clicked;
132        unsigned int mouse_x, mouse_y;
133        unsigned int mouse_button, mouse_state;
134
135        unsigned char key;
136        int special_key;
137        int new_width;
138        int new_height;
139
140        float sw, sh;
141    } gl;
142#endif
143};
144
145/* Initialisation functions */
146extern int _caca_init_graphics(caca_t *kk);
147extern int _caca_end_graphics(caca_t *kk);
148
149/* Timer functions */
150extern void _caca_sleep(unsigned int);
151extern unsigned int _caca_getticks(struct caca_timer *);
152
153/* Cached screen size */
154extern unsigned int _caca_width;
155extern unsigned int _caca_height;
156extern int _caca_resize;
157extern int _caca_resize_event;
158
159#if defined(USE_WIN32)
160#include <windows.h>
161extern HANDLE win32_hin, win32_hout;
162#endif
163
164#if defined(USE_GL)
165#include <GL/glut.h>
166extern unsigned int gl_width, gl_height;
167#endif
168
169
170#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.