home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 1 / CD_Magazyn_EXEC_nr_1.iso / Gry / battalion.lha / Battalion / source / tk.h < prev    next >
C/C++ Source or Header  |  1999-12-23  |  8KB  |  242 lines

  1. /*
  2.  * (c) Copyright 1993, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED 
  4.  * Permission to use, copy, modify, and distribute this software for 
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that 
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission. 
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  * 
  25.  * US Government Users Restricted Rights 
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
  36.  */
  37. #include <X11/Xlib.h>
  38. #include <X11/Xutil.h>
  39. #include <GL/glx.h>
  40. #include <GL/gl.h>
  41. #include <GL/glu.h>
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47.  
  48.  
  49. /*
  50. ** Window Types
  51. */
  52.  
  53. #define TK_RGB          0
  54. #define TK_INDEX        1
  55. #define TK_SINGLE       0
  56. #define TK_DOUBLE       2
  57. #define TK_DIRECT       0
  58. #define TK_INDIRECT     4
  59. #define TK_ACCUM        8
  60. #define TK_ALPHA        16
  61. #define TK_DEPTH        32
  62. #define TK_STENCIL      64
  63.  
  64. /* 
  65. ** Window Masks
  66. */
  67.  
  68. #define TK_IS_RGB(x)            (((x) & TK_INDEX) == 0)
  69. #define TK_IS_INDEX(x)          (((x) & TK_INDEX) != 0)
  70. #define TK_IS_SINGLE(x)         (((x) & TK_DOUBLE) == 0)
  71. #define TK_IS_DOUBLE(x)         (((x) & TK_DOUBLE) != 0)
  72. #define TK_HAS_ACCUM(x)         (((x) & TK_ACCUM) != 0)
  73. #define TK_HAS_ALPHA(x)         (((x) & TK_ALPHA) != 0)
  74. #define TK_HAS_DEPTH(x)         (((x) & TK_DEPTH) != 0)
  75. #define TK_HAS_STENCIL(x)       (((x) & TK_STENCIL) != 0)
  76. #define TK_IS_DIRECT(x)         (((x) & TK_INDIRECT) != 0)
  77. #define TK_IS_INDIRECT(x)       (((x) & TK_INDIRECT) == 0)
  78.  
  79. /*
  80. ** Event Status
  81. */
  82.  
  83. #define TK_LEFTBUTTON           1
  84. #define TK_RIGHTBUTTON          2
  85. #define TK_MIDDLEBUTTON         4
  86. #define TK_SHIFT                1
  87. #define TK_CONTROL              2
  88.  
  89. /* 
  90. ** Key Codes
  91. */
  92.  
  93. #define TK_SHIFT_L              0x01
  94. #define TK_SHIFT_R              0x02
  95. #define TK_CONTROL_L            0x03
  96. #define TK_CONTROL_R            0x04
  97.  
  98.  
  99.  
  100. #define TK_RETURN               0x0D
  101. #define TK_ESCAPE               0x1B
  102. #define TK_SPACE                0x20
  103. #define TK_LEFT                 0x25
  104. #define TK_UP                   0x26
  105. #define TK_RIGHT                0x27
  106. #define TK_DOWN                 0x28
  107. #define TK_A                    'A'
  108. #define TK_B                    'B'
  109. #define TK_C                    'C'
  110. #define TK_D                    'D'
  111. #define TK_E                    'E'
  112. #define TK_F                    'F'
  113. #define TK_G                    'G'
  114. #define TK_H                    'H'
  115. #define TK_I                    'I'
  116. #define TK_J                    'J'
  117. #define TK_K                    'K'
  118. #define TK_L                    'L'
  119. #define TK_M                    'M'
  120. #define TK_N                    'N'
  121. #define TK_O                    'O'
  122. #define TK_P                    'P'
  123. #define TK_Q                    'Q'
  124. #define TK_R                    'R'
  125. #define TK_S                    'S'
  126. #define TK_T                    'T'
  127. #define TK_U                    'U'
  128. #define TK_V                    'V'
  129. #define TK_W                    'W'
  130. #define TK_X                    'X'
  131. #define TK_Y                    'Y'
  132. #define TK_Z                    'Z'
  133. #define TK_a                    'a'
  134. #define TK_b                    'b'
  135. #define TK_c                    'c'
  136. #define TK_d                    'd'
  137. #define TK_e                    'e'
  138. #define TK_f                    'f'
  139. #define TK_g                    'g'
  140. #define TK_h                    'h'
  141. #define TK_i                    'i'
  142. #define TK_j                    'j'
  143. #define TK_k                    'k'
  144. #define TK_l                    'l'
  145. #define TK_m                    'm'
  146. #define TK_n                    'n'
  147. #define TK_o                    'o'
  148. #define TK_p                    'p'
  149. #define TK_q                    'q'
  150. #define TK_r                    'r'
  151. #define TK_s                    's'
  152. #define TK_t                    't'
  153. #define TK_u                    'u'
  154. #define TK_v                    'v'
  155. #define TK_w                    'w'
  156. #define TK_x                    'x'
  157. #define TK_y                    'y'
  158. #define TK_z                    'z'
  159. #define TK_0                    '0'
  160. #define TK_1                    '1'
  161. #define TK_2                    '2'
  162. #define TK_3                    '3'
  163. #define TK_4                    '4'
  164. #define TK_5                    '5'
  165. #define TK_6                    '6'
  166. #define TK_7                    '7'
  167. #define TK_8                    '8'
  168. #define TK_9                    '9'
  169.  
  170. /*
  171. ** Color Macros
  172. */
  173.  
  174. enum {
  175.     TK_BLACK = 0,
  176.     TK_RED,
  177.     TK_GREEN,
  178.     TK_YELLOW,
  179.     TK_BLUE,
  180.     TK_MAGENTA,
  181.     TK_CYAN,
  182.     TK_WHITE
  183. };
  184.  
  185. extern float tkRGBMap[8][3];
  186.  
  187. #define TK_SETCOLOR(x, y) (TK_IS_RGB((x)) ? \
  188.                            glColor3fv(tkRGBMap[(y)]) : glIndexf((y)))
  189.  
  190. /*
  191. ** RGB Image Structure
  192. */
  193.  
  194. typedef struct _TK_RGBImageRec {
  195.     GLint sizeX, sizeY;
  196.     unsigned char *data;
  197. } TK_RGBImageRec;
  198.  
  199. /*
  200. ** Prototypes
  201. */
  202.  
  203. extern void tkInitDisplayMode(GLenum);
  204. extern void tkInitPosition(int, int, int, int);
  205. extern GLenum tkInitWindow(char *);
  206. extern void tkCloseWindow(void);
  207. extern void tkQuit(void);
  208.  
  209. extern void tkExec(void);
  210. extern void tkExposeFunc(void (*)(int, int));
  211. extern void tkReshapeFunc(void (*)(int, int));
  212. extern void tkDisplayFunc(void (*)(void));
  213. extern void tkKeyDownFunc(GLenum (*)(int, GLenum));
  214. extern void tkMouseDownFunc(GLenum (*)(int, int, GLenum));
  215. extern void tkMouseUpFunc(GLenum (*)(int, int, GLenum));
  216. extern void tkMouseMoveFunc(GLenum (*)(int, int, GLenum));
  217. extern void tkIdleFunc(void (*)(void));
  218.  
  219. extern void tkSwapBuffers(void);
  220.  
  221. extern int tkGetColorMapSize(void);
  222. extern void tkGetMouseLoc(int *, int *);
  223. extern Display *tkGetXDisplay(void);
  224. extern Window tkGetXWindow(void);
  225.  
  226. extern void tkSetOneColor(int, float, float, float);
  227. extern void tkSetFogRamp(int, int);
  228. extern void tkSetGreyRamp(void);
  229. extern void tkSetRGBMap(int, float *);
  230.  
  231. extern TK_RGBImageRec *tkRGBImageLoad(char *);
  232.  
  233. extern GLenum tkCreateStrokeFont(GLuint);
  234. extern GLenum tkCreateOutlineFont(GLuint);
  235. extern GLenum tkCreateFilledFont(GLuint);
  236. extern GLenum tkCreateBitmapFont(GLuint);
  237. extern void tkDrawStr(GLuint, char *);
  238.  
  239. #ifdef __cplusplus
  240. }
  241. #endif
  242.