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 3.5 KiB

20 år sedan
20 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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_X11)
  21. #include <X11/Xlib.h>
  22. #endif
  23. /* Graphics driver */
  24. enum caca_driver
  25. {
  26. #if defined(USE_CONIO)
  27. CACA_DRIVER_CONIO = 1,
  28. #endif
  29. #if defined(USE_NCURSES)
  30. CACA_DRIVER_NCURSES = 2,
  31. #endif
  32. #if defined(USE_SLANG)
  33. CACA_DRIVER_SLANG = 3,
  34. #endif
  35. #if defined(USE_X11)
  36. CACA_DRIVER_X11 = 4,
  37. #endif
  38. #if defined(USE_WIN32)
  39. CACA_DRIVER_WIN32 = 5,
  40. #endif
  41. #if defined(USE_GL)
  42. CACA_DRIVER_GL = 6,
  43. #endif
  44. CACA_DRIVER_NONE = 0
  45. };
  46. /* Timer structure */
  47. struct caca_timer
  48. {
  49. int last_sec, last_usec;
  50. };
  51. /* Internal caca context */
  52. struct caca_context
  53. {
  54. cucul_t *qq;
  55. enum caca_driver driver;
  56. unsigned int width, height;
  57. int resize;
  58. int resize_event;
  59. unsigned int delay, rendertime;
  60. struct caca_timer timer;
  61. int lastticks;
  62. struct events
  63. {
  64. #if defined(USE_SLANG) || defined(USE_NCURSES)
  65. struct caca_timer key_timer;
  66. unsigned int last_key_ticks;
  67. unsigned int autorepeat_ticks;
  68. unsigned int last_key;
  69. #endif
  70. } events;
  71. #if defined(USE_X11) && !defined(_DOXYGEN_SKIP_ME)
  72. struct x11
  73. {
  74. Display *dpy;
  75. Window window;
  76. Pixmap pixmap;
  77. GC gc;
  78. long int event_mask;
  79. int font_width, font_height;
  80. unsigned int new_width, new_height;
  81. int colors[16];
  82. Font font;
  83. XFontStruct *font_struct;
  84. int font_offset;
  85. #if defined(HAVE_X11_XKBLIB_H)
  86. Bool autorepeat;
  87. #endif
  88. } x11;
  89. #endif
  90. #if defined(USE_NCURSES)
  91. struct ncurses
  92. {
  93. int attr[16*16];
  94. } ncurses;
  95. #endif
  96. #if defined(USE_CONIO)
  97. struct conio
  98. {
  99. struct text_info ti;
  100. char *screen;
  101. } conio;
  102. #endif
  103. #if defined(USE_WIN32)
  104. struct win32
  105. {
  106. HANDLE hin, hout;
  107. HANDLE front, back;
  108. CHAR_INFO *buffer;
  109. } win32;
  110. #endif
  111. #if defined(USE_GL)
  112. struct gl
  113. {
  114. int window;
  115. unsigned int width, height;
  116. float font_width, font_height;
  117. float incx, incy;
  118. int id[94];
  119. unsigned char resized, bit;
  120. unsigned char mouse_changed, mouse_clicked;
  121. unsigned int mouse_x, mouse_y;
  122. unsigned int mouse_button, mouse_state;
  123. unsigned char key;
  124. int special_key;
  125. int new_width;
  126. int new_height;
  127. float sw, sh;
  128. } gl;
  129. #endif
  130. };
  131. /* Initialisation functions */
  132. extern int _caca_init_graphics(caca_t *kk);
  133. extern int _caca_end_graphics(caca_t *kk);
  134. /* Timer functions */
  135. extern void _caca_sleep(unsigned int);
  136. extern unsigned int _caca_getticks(struct caca_timer *);
  137. /* Cached screen size */
  138. extern unsigned int _caca_width;
  139. extern unsigned int _caca_height;
  140. extern int _caca_resize;
  141. extern int _caca_resize_event;
  142. #if defined(USE_WIN32)
  143. #include <windows.h>
  144. extern HANDLE win32_hin, win32_hout;
  145. #endif
  146. #if defined(USE_GL)
  147. #include <GL/glut.h>
  148. extern unsigned int gl_width, gl_height;
  149. #endif
  150. #endif /* __CACA_INTERNALS_H__ */