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.
 
 
 
 
 
 

206 lines
4.4 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(USE_GL)
  21. # include <GL/glut.h>
  22. #endif
  23. #if defined(USE_NCURSES)
  24. # if defined(HAVE_NCURSES_H)
  25. # include <ncurses.h>
  26. # else
  27. # include <curses.h>
  28. # endif
  29. #endif
  30. #if defined(USE_WIN32)
  31. # include <windows.h>
  32. #endif
  33. #if defined(USE_X11)
  34. # include <X11/Xlib.h>
  35. #endif
  36. /* Graphics driver */
  37. enum 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. /* Available drivers */
  60. #if defined(USE_CONIO)
  61. void conio_init_driver(caca_t *);
  62. #endif
  63. #if defined(USE_GL)
  64. void gl_init_driver(caca_t *);
  65. #endif
  66. #if defined(USE_NCURSES)
  67. void ncurses_init_driver(caca_t *);
  68. #endif
  69. #if defined(USE_SLANG)
  70. void slang_init_driver(caca_t *);
  71. #endif
  72. #if defined(USE_WIN32)
  73. void win32_init_driver(caca_t *);
  74. #endif
  75. #if defined(USE_X11)
  76. void x11_init_driver(caca_t *);
  77. #endif
  78. /* Timer structure */
  79. struct caca_timer
  80. {
  81. int last_sec, last_usec;
  82. };
  83. /* Internal caca context */
  84. struct caca_context
  85. {
  86. cucul_t *qq;
  87. struct driver
  88. {
  89. enum caca_driver driver;
  90. int (* init_graphics) (caca_t *);
  91. int (* end_graphics) (caca_t *);
  92. int (* set_window_title) (caca_t *, char const *);
  93. unsigned int (* get_window_width) (caca_t *);
  94. unsigned int (* get_window_height) (caca_t *);
  95. void (* display) (caca_t *);
  96. void (* handle_resize) (caca_t *);
  97. } driver;
  98. unsigned int width, height;
  99. int resize;
  100. int resize_event;
  101. unsigned int delay, rendertime;
  102. struct caca_timer timer;
  103. int lastticks;
  104. struct events
  105. {
  106. #if defined(USE_SLANG) || defined(USE_NCURSES)
  107. struct caca_timer key_timer;
  108. unsigned int last_key_ticks;
  109. unsigned int autorepeat_ticks;
  110. unsigned int last_key;
  111. #endif
  112. } events;
  113. #if defined(USE_X11) && !defined(_DOXYGEN_SKIP_ME)
  114. struct x11
  115. {
  116. Display *dpy;
  117. Window window;
  118. Pixmap pixmap;
  119. GC gc;
  120. long int event_mask;
  121. int font_width, font_height;
  122. unsigned int new_width, new_height;
  123. int colors[16];
  124. Font font;
  125. XFontStruct *font_struct;
  126. int font_offset;
  127. #if defined(HAVE_X11_XKBLIB_H)
  128. Bool autorepeat;
  129. #endif
  130. } x11;
  131. #endif
  132. #if defined(USE_NCURSES)
  133. struct ncurses
  134. {
  135. int attr[16*16];
  136. mmask_t oldmask;
  137. } ncurses;
  138. #endif
  139. #if defined(USE_CONIO)
  140. struct conio
  141. {
  142. struct text_info ti;
  143. char *screen;
  144. } conio;
  145. #endif
  146. #if defined(USE_WIN32)
  147. struct win32
  148. {
  149. HANDLE hin, hout;
  150. HANDLE front, back;
  151. CHAR_INFO *buffer;
  152. } win32;
  153. #endif
  154. #if defined(USE_GL)
  155. struct gl
  156. {
  157. int window;
  158. unsigned int width, height;
  159. float font_width, font_height;
  160. float incx, incy;
  161. int id[94];
  162. unsigned char resized, bit;
  163. unsigned char mouse_changed, mouse_clicked;
  164. unsigned int mouse_x, mouse_y;
  165. unsigned int mouse_button, mouse_state;
  166. unsigned char key;
  167. int special_key;
  168. int new_width;
  169. int new_height;
  170. float sw, sh;
  171. } gl;
  172. #endif
  173. };
  174. /* Initialisation functions */
  175. extern int _caca_init_graphics(caca_t *kk);
  176. extern int _caca_end_graphics(caca_t *kk);
  177. /* Timer functions */
  178. extern void _caca_sleep(unsigned int);
  179. extern unsigned int _caca_getticks(struct caca_timer *);
  180. /* Cached screen size */
  181. extern unsigned int _caca_width;
  182. extern unsigned int _caca_height;
  183. extern int _caca_resize;
  184. extern int _caca_resize_event;
  185. #endif /* __CACA_INTERNALS_H__ */