Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

caca_internals.h 4.4 KiB

20 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. /* Graphics driver */
  44. enum caca_driver
  45. {
  46. #if defined(USE_CONIO)
  47. CACA_DRIVER_CONIO = 1,
  48. #endif
  49. #if defined(USE_NCURSES)
  50. CACA_DRIVER_NCURSES = 2,
  51. #endif
  52. #if defined(USE_SLANG)
  53. CACA_DRIVER_SLANG = 3,
  54. #endif
  55. #if defined(USE_X11)
  56. CACA_DRIVER_X11 = 4,
  57. #endif
  58. #if defined(USE_WIN32)
  59. CACA_DRIVER_WIN32 = 5,
  60. #endif
  61. #if defined(USE_GL)
  62. CACA_DRIVER_GL = 6,
  63. #endif
  64. CACA_DRIVER_NONE = 0
  65. };
  66. /* Available drivers */
  67. #if defined(USE_CONIO)
  68. void conio_init_driver(caca_t *);
  69. #endif
  70. #if defined(USE_GL)
  71. void gl_init_driver(caca_t *);
  72. #endif
  73. #if defined(USE_NCURSES)
  74. void ncurses_init_driver(caca_t *);
  75. #endif
  76. #if defined(USE_SLANG)
  77. void slang_init_driver(caca_t *);
  78. #endif
  79. #if defined(USE_WIN32)
  80. void win32_init_driver(caca_t *);
  81. #endif
  82. #if defined(USE_X11)
  83. void x11_init_driver(caca_t *);
  84. #endif
  85. /* Timer structure */
  86. struct caca_timer
  87. {
  88. int last_sec, last_usec;
  89. };
  90. /* Internal caca context */
  91. struct caca_context
  92. {
  93. cucul_t *qq;
  94. struct driver
  95. {
  96. enum caca_driver driver;
  97. int (* init_graphics) (caca_t *);
  98. int (* end_graphics) (caca_t *);
  99. int (* set_window_title) (caca_t *, char const *);
  100. unsigned int (* get_window_width) (caca_t *);
  101. unsigned int (* get_window_height) (caca_t *);
  102. void (* display) (caca_t *);
  103. void (* handle_resize) (caca_t *, unsigned int *, unsigned int *);
  104. } driver;
  105. unsigned int width, height;
  106. int resize;
  107. int resize_event;
  108. unsigned int delay, rendertime;
  109. struct caca_timer timer;
  110. int lastticks;
  111. struct events
  112. {
  113. #if defined(USE_SLANG) || defined(USE_NCURSES)
  114. struct caca_timer key_timer;
  115. unsigned int last_key_ticks;
  116. unsigned int autorepeat_ticks;
  117. unsigned int last_key;
  118. #endif
  119. } events;
  120. /* FIXME: maybe this should go away */
  121. #if defined(USE_X11) && !defined(_DOXYGEN_SKIP_ME)
  122. struct x11
  123. {
  124. Display *dpy;
  125. Window window;
  126. Pixmap pixmap;
  127. GC gc;
  128. long int event_mask;
  129. int font_width, font_height;
  130. unsigned int new_width, new_height;
  131. int colors[16];
  132. Font font;
  133. XFontStruct *font_struct;
  134. int font_offset;
  135. #if defined(HAVE_X11_XKBLIB_H)
  136. Bool autorepeat;
  137. #endif
  138. } x11;
  139. #endif
  140. #if defined(USE_NCURSES)
  141. struct ncurses
  142. {
  143. int attr[16*16];
  144. mmask_t oldmask;
  145. } ncurses;
  146. #endif
  147. #if defined(USE_CONIO)
  148. struct conio
  149. {
  150. struct text_info ti;
  151. char *screen;
  152. } conio;
  153. #endif
  154. #if defined(USE_WIN32)
  155. struct win32
  156. {
  157. HANDLE hin, hout;
  158. HANDLE front, back;
  159. CHAR_INFO *buffer;
  160. CONSOLE_CURSOR_INFO cci;
  161. } win32;
  162. #endif
  163. #if defined(USE_GL)
  164. struct gl
  165. {
  166. int window;
  167. unsigned int width, height;
  168. float font_width, font_height;
  169. float incx, incy;
  170. int id[94];
  171. unsigned char resized, bit;
  172. unsigned char mouse_changed, mouse_clicked;
  173. unsigned int mouse_x, mouse_y;
  174. unsigned int mouse_button, mouse_state;
  175. unsigned char key;
  176. int special_key;
  177. int new_width;
  178. int new_height;
  179. float sw, sh;
  180. } gl;
  181. #endif
  182. };
  183. /* Timer functions */
  184. extern void _caca_sleep(unsigned int);
  185. extern unsigned int _caca_getticks(struct caca_timer *);
  186. #endif /* __CACA_INTERNALS_H__ */