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

Last change on this file since 539 was 539, checked in by Sam Hocevar, 15 years ago
  • Split caca/graphics.c into driver-specific files. Resize is currently broken, and event handling is not yet in the driver-specific files, but I will of course fix that later.
  • 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 539 2006-03-06 23:01:59Z 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
[539]23#if defined(USE_GL)
24#   include <GL/glut.h>
25#endif
26#if defined(USE_NCURSES)
27#   if defined(HAVE_NCURSES_H)
28#       include <ncurses.h>
29#   else
30#       include <curses.h>
31#   endif
32#endif
33#if defined(USE_WIN32)
34#   include <windows.h>
35#endif
[524]36#if defined(USE_X11)
[539]37#   include <X11/Xlib.h>
[524]38#endif
39
[265]40/* Graphics driver */
41enum caca_driver
42{
43#if defined(USE_CONIO)
44    CACA_DRIVER_CONIO = 1,
45#endif
46#if defined(USE_NCURSES)
47    CACA_DRIVER_NCURSES = 2,
48#endif
49#if defined(USE_SLANG)
50    CACA_DRIVER_SLANG = 3,
51#endif
52#if defined(USE_X11)
53    CACA_DRIVER_X11 = 4,
54#endif
[335]55#if defined(USE_WIN32)
56    CACA_DRIVER_WIN32 = 5,
57#endif
[483]58#if defined(USE_GL)
59    CACA_DRIVER_GL = 6,
60#endif
[265]61    CACA_DRIVER_NONE = 0
62};
63
[539]64/* Available drivers */
65#if defined(USE_CONIO)
66void conio_init_driver(caca_t *);
67#endif
68#if defined(USE_GL)
69void gl_init_driver(caca_t *);
70#endif
71#if defined(USE_NCURSES)
72void ncurses_init_driver(caca_t *);
73#endif
74#if defined(USE_SLANG)
75void slang_init_driver(caca_t *);
76#endif
77#if defined(USE_WIN32)
78void win32_init_driver(caca_t *);
79#endif
80#if defined(USE_X11)
81void x11_init_driver(caca_t *);
82#endif
83
[331]84/* Timer structure */
85struct caca_timer
86{
87    int last_sec, last_usec;
88};
89
[524]90/* Internal caca context */
91struct caca_context
92{
93    cucul_t *qq;
[265]94
[539]95    struct driver
96    {
97        enum caca_driver driver;
98
99        int (* init_graphics) (caca_t *);
100        int (* end_graphics) (caca_t *);
101        int (* set_window_title) (caca_t *, char const *);
102        unsigned int (* get_window_width) (caca_t *);
103        unsigned int (* get_window_height) (caca_t *);
104        void (* display) (caca_t *);
105        void (* handle_resize) (caca_t *);
106    } driver;
107
[524]108    unsigned int width, height;
109
110    int resize;
111    int resize_event;
112
113    unsigned int delay, rendertime;
[527]114    struct caca_timer timer;
115    int lastticks;
[524]116
[527]117    struct events
118    {
119#if defined(USE_SLANG) || defined(USE_NCURSES)
120        struct caca_timer key_timer;
121        unsigned int last_key_ticks;
122        unsigned int autorepeat_ticks;
123        unsigned int last_key;
124#endif
125    } events;
126
[524]127#if defined(USE_X11) && !defined(_DOXYGEN_SKIP_ME)
128    struct x11
129    {
130        Display *dpy;
131        Window window;
132        Pixmap pixmap;
133        GC gc;
134        long int event_mask;
135        int font_width, font_height;
136        unsigned int new_width, new_height;
137        int colors[16];
138        Font font;
139        XFontStruct *font_struct;
140        int font_offset;
141#if defined(HAVE_X11_XKBLIB_H)
[527]142        Bool autorepeat;
[524]143#endif
144    } x11;
145#endif
[527]146#if defined(USE_NCURSES)
147    struct ncurses
148    {
149        int attr[16*16];
[539]150        mmask_t oldmask;
[527]151    } ncurses;
152#endif
153#if defined(USE_CONIO)
154    struct conio
155    {
156        struct text_info ti;
157        char *screen;
158    } conio;
159#endif
160#if defined(USE_WIN32)
161    struct win32
162    {
163        HANDLE hin, hout;
164        HANDLE front, back;
165        CHAR_INFO *buffer;
166    } win32;
167#endif
168#if defined(USE_GL)
169    struct gl
170    {
171        int window;
172        unsigned int width, height;
173        float font_width, font_height;
174        float incx, incy;
175        int id[94];
176        unsigned char resized, bit;
177        unsigned char mouse_changed, mouse_clicked;
178        unsigned int mouse_x, mouse_y;
179        unsigned int mouse_button, mouse_state;
180
181        unsigned char key;
182        int special_key;
183        int new_width;
184        int new_height;
185
186        float sw, sh;
187    } gl;
188#endif
[524]189};
190
[265]191/* Initialisation functions */
[524]192extern int _caca_init_graphics(caca_t *kk);
193extern int _caca_end_graphics(caca_t *kk);
[227]194
[331]195/* Timer functions */
[335]196extern void _caca_sleep(unsigned int);
[331]197extern unsigned int _caca_getticks(struct caca_timer *);
198
[249]199/* Cached screen size */
[246]200extern unsigned int _caca_width;
201extern unsigned int _caca_height;
[349]202extern int _caca_resize;
203extern int _caca_resize_event;
[246]204
[193]205#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.