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

Last change on this file since 550 was 550, checked in by Sam Hocevar, 14 years ago
  • Finished moving everything driver-specific to the apropriate driver_*.c files. Phew. Now they just need a few comments.
  • Property svn:keywords set to Id
File size: 3.1 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 550 2006-03-08 10:33:01Z 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(_DOXYGEN_SKIP_ME)
33#   define EVENTBUF_LEN 10
34#endif
35
36/* Graphics driver */
37enum caca_driver
38{
39#if defined(USE_CONIO)
40    CACA_DRIVER_CONIO = 1,
41#endif
42#if defined(USE_NCURSES)
43    CACA_DRIVER_NCURSES = 2,
44#endif
45#if defined(USE_SLANG)
46    CACA_DRIVER_SLANG = 3,
47#endif
48#if defined(USE_X11)
49    CACA_DRIVER_X11 = 4,
50#endif
51#if defined(USE_WIN32)
52    CACA_DRIVER_WIN32 = 5,
53#endif
54#if defined(USE_GL)
55    CACA_DRIVER_GL = 6,
56#endif
57    CACA_DRIVER_NONE = 0
58};
59
60/* Available drivers */
61#if defined(USE_CONIO)
62void conio_init_driver(caca_t *);
63#endif
64#if defined(USE_GL)
65void gl_init_driver(caca_t *);
66#endif
67#if defined(USE_NCURSES)
68void ncurses_init_driver(caca_t *);
69#endif
70#if defined(USE_SLANG)
71void slang_init_driver(caca_t *);
72#endif
73#if defined(USE_WIN32)
74void win32_init_driver(caca_t *);
75#endif
76#if defined(USE_X11)
77void x11_init_driver(caca_t *);
78#endif
79
80/* Timer structure */
81struct caca_timer
82{
83    int last_sec, last_usec;
84};
85
86/* Internal caca context */
87struct caca_context
88{
89    cucul_t *qq;
90
91    struct drv
92    {
93        enum caca_driver driver;
94        struct driver_private *p;
95
96        int (* init_graphics) (caca_t *);
97        int (* end_graphics) (caca_t *);
98        int (* set_window_title) (caca_t *, char const *);
99        unsigned int (* get_window_width) (caca_t *);
100        unsigned int (* get_window_height) (caca_t *);
101        void (* display) (caca_t *);
102        void (* handle_resize) (caca_t *, unsigned int *, unsigned int *);
103        unsigned int (* get_event) (caca_t *);
104    } drv;
105
106    //unsigned int width, height;
107    unsigned int mouse_x, mouse_y;
108
109    int resize;
110    int resize_event;
111
112    unsigned int delay, rendertime;
113    struct caca_timer timer;
114    int lastticks;
115
116    struct events
117    {
118#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO)
119        unsigned int buf[EVENTBUF_LEN];
120        int queue;
121#endif
122#if defined(USE_SLANG) || defined(USE_NCURSES)
123        struct caca_timer key_timer;
124        unsigned int last_key_ticks;
125        unsigned int autorepeat_ticks;
126        unsigned int last_key;
127#endif
128    } events;
129};
130
131/* Timer functions */
132extern void _caca_sleep(unsigned int);
133extern unsigned int _caca_getticks(struct caca_timer *);
134
135#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.