You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

215 lines
4.6 KiB

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