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

Last change on this file since 553 was 553, checked in by Sam Hocevar, 14 years ago
  • Fixed async issues between the driver and libcaca when resizing windows, and simplified the handle_resize() API. Still can be polished.
  • Property svn:keywords set to Id
File size: 3.4 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 553 2006-03-08 19:41:53Z 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    /* A link to our cucul canvas */
90    cucul_t *qq;
91
92    /* Device-specific functions */
93    struct drv
94    {
95        enum caca_driver driver;
96        struct driver_private *p;
97
98        int (* init_graphics) (caca_t *);
99        int (* end_graphics) (caca_t *);
100        int (* set_window_title) (caca_t *, char const *);
101        unsigned int (* get_window_width) (caca_t *);
102        unsigned int (* get_window_height) (caca_t *);
103        void (* display) (caca_t *);
104        void (* handle_resize) (caca_t *);
105        unsigned int (* get_event) (caca_t *);
106    } drv;
107
108    /* Mouse position */
109    struct mouse
110    {
111        unsigned int x, y;
112    } mouse;
113
114    /* Window resize handling */
115    struct resize
116    {
117        int resized;   /* A resize event was requested */
118        //int acked;     /* The event has been acknowledged by the user */
119        unsigned w, h; /* Requested width and height */
120    } resize;
121
122    /* Framerate handling */
123    unsigned int delay, rendertime;
124    struct caca_timer timer;
125    int lastticks;
126
127    struct events
128    {
129#if defined(USE_SLANG) || defined(USE_NCURSES) || defined(USE_CONIO)
130        unsigned int buf[EVENTBUF_LEN];
131        int queue;
132#endif
133#if defined(USE_SLANG) || defined(USE_NCURSES)
134        struct caca_timer key_timer;
135        unsigned int last_key_ticks;
136        unsigned int autorepeat_ticks;
137        unsigned int last_key;
138#endif
139    } events;
140};
141
142/* Timer functions */
143extern void _caca_sleep(unsigned int);
144extern unsigned int _caca_getticks(struct caca_timer *);
145
146#endif /* __CACA_INTERNALS_H__ */
Note: See TracBrowser for help on using the repository browser.