Leaked source code of windows server 2003
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.

234 lines
6.4 KiB

  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 <windows.h>
  38. #include <GL/gl.h>
  39. #include <GL/glu.h>
  40. /*
  41. ** Window Types
  42. */
  43. #define TK_RGB 0
  44. #define TK_INDEX 1
  45. #define TK_SINGLE 0
  46. #define TK_DOUBLE 2
  47. #define TK_DIRECT 0
  48. #define TK_INDIRECT 4
  49. #define TK_ACCUM 8
  50. #define TK_ALPHA 16
  51. #define TK_DEPTH 32
  52. #define TK_STENCIL 64
  53. /*
  54. ** Window Masks
  55. */
  56. #define TK_IS_RGB(x) (((x) & TK_INDEX) == 0)
  57. #define TK_IS_INDEX(x) (((x) & TK_INDEX) != 0)
  58. #define TK_IS_SINGLE(x) (((x) & TK_DOUBLE) == 0)
  59. #define TK_IS_DOUBLE(x) (((x) & TK_DOUBLE) != 0)
  60. #define TK_HAS_ACCUM(x) (((x) & TK_ACCUM) != 0)
  61. #define TK_HAS_ALPHA(x) (((x) & TK_ALPHA) != 0)
  62. #define TK_HAS_DEPTH(x) (((x) & TK_DEPTH) != 0)
  63. #define TK_HAS_STENCIL(x) (((x) & TK_STENCIL) != 0)
  64. #define TK_IS_DIRECT(x) (((x) & TK_INDIRECT) == 0)
  65. #define TK_IS_INDIRECT(x) (((x) & TK_INDIRECT) != 0)
  66. /*
  67. ** Event Status
  68. */
  69. #define TK_LEFTBUTTON 1
  70. #define TK_RIGHTBUTTON 2
  71. #define TK_MIDDLEBUTTON 4
  72. #define TK_SHIFT 1
  73. #define TK_CONTROL 2
  74. /*
  75. ** Key Codes
  76. */
  77. #define TK_RETURN 0x0D
  78. #define TK_ESCAPE 0x1B
  79. #define TK_SPACE 0x20
  80. #define TK_LEFT 0x25
  81. #define TK_UP 0x26
  82. #define TK_RIGHT 0x27
  83. #define TK_DOWN 0x28
  84. #define TK_A 'A'
  85. #define TK_B 'B'
  86. #define TK_C 'C'
  87. #define TK_D 'D'
  88. #define TK_E 'E'
  89. #define TK_F 'F'
  90. #define TK_G 'G'
  91. #define TK_H 'H'
  92. #define TK_I 'I'
  93. #define TK_J 'J'
  94. #define TK_K 'K'
  95. #define TK_L 'L'
  96. #define TK_M 'M'
  97. #define TK_N 'N'
  98. #define TK_O 'O'
  99. #define TK_P 'P'
  100. #define TK_Q 'Q'
  101. #define TK_R 'R'
  102. #define TK_S 'S'
  103. #define TK_T 'T'
  104. #define TK_U 'U'
  105. #define TK_V 'V'
  106. #define TK_W 'W'
  107. #define TK_X 'X'
  108. #define TK_Y 'Y'
  109. #define TK_Z 'Z'
  110. #define TK_a 'a'
  111. #define TK_b 'b'
  112. #define TK_c 'c'
  113. #define TK_d 'd'
  114. #define TK_e 'e'
  115. #define TK_f 'f'
  116. #define TK_g 'g'
  117. #define TK_h 'h'
  118. #define TK_i 'i'
  119. #define TK_j 'j'
  120. #define TK_k 'k'
  121. #define TK_l 'l'
  122. #define TK_m 'm'
  123. #define TK_n 'n'
  124. #define TK_o 'o'
  125. #define TK_p 'p'
  126. #define TK_q 'q'
  127. #define TK_r 'r'
  128. #define TK_s 's'
  129. #define TK_t 't'
  130. #define TK_u 'u'
  131. #define TK_v 'v'
  132. #define TK_w 'w'
  133. #define TK_x 'x'
  134. #define TK_y 'y'
  135. #define TK_z 'z'
  136. #define TK_0 '0'
  137. #define TK_1 '1'
  138. #define TK_2 '2'
  139. #define TK_3 '3'
  140. #define TK_4 '4'
  141. #define TK_5 '5'
  142. #define TK_6 '6'
  143. #define TK_7 '7'
  144. #define TK_8 '8'
  145. #define TK_9 '9'
  146. /*
  147. ** Color Macros - Default Windows Logical palette
  148. */
  149. enum {
  150. TK_BLACK = 0,
  151. TK_RED = 13,
  152. TK_GREEN,
  153. TK_YELLOW,
  154. TK_BLUE,
  155. TK_MAGENTA,
  156. TK_CYAN,
  157. TK_WHITE
  158. };
  159. extern float auxRGBMap[20][3];
  160. #define tkRGBMap auxRGBMap
  161. #define TK_SETCOLOR(x, y) (TK_IS_RGB((x)) ? \
  162. glColor3fv(auxRGBMap[(y)]) : glIndexf((y)))
  163. /*
  164. ** RGB Image Structure
  165. */
  166. typedef struct _TK_RGBImageRec {
  167. GLint sizeX, sizeY;
  168. unsigned char *data;
  169. } TK_RGBImageRec;
  170. /*
  171. ** Prototypes
  172. */
  173. extern void tkInitDisplayMode(GLenum);
  174. extern void tkInitPosition(int, int, int, int);
  175. extern GLenum tkInitWindow(char *);
  176. extern GLenum tkInitWindowAW(char *, BOOL);
  177. extern void tkCloseWindow(void);
  178. extern void tkQuit(void);
  179. extern void tkExec(void);
  180. extern void tkExposeFunc(void (*)(int, int));
  181. extern void tkReshapeFunc(void (*)(int, int));
  182. extern void tkDisplayFunc(void (*)(void));
  183. extern void tkKeyDownFunc(GLenum (*)(int, GLenum));
  184. extern void tkMouseDownFunc(GLenum (*)(int, int, GLenum));
  185. extern void tkMouseUpFunc(GLenum (*)(int, int, GLenum));
  186. extern void tkMouseMoveFunc(GLenum (*)(int, int, GLenum));
  187. extern void tkIdleFunc(void (*)(void));
  188. extern void tkSwapBuffers(void);
  189. extern GLint tkGetColorMapSize(void);
  190. extern void tkGetMouseLoc(int *, int *);
  191. //extern Display *tkGetXDisplay(void);
  192. //extern Window tkGetXWindow(void);
  193. extern void tkSetOneColor(int, float, float, float);
  194. extern void tkSetFogRamp(int, int);
  195. extern void tkSetGreyRamp(void);
  196. extern void tkSetRGBMap(int, float *);
  197. extern TK_RGBImageRec *tkRGBImageLoad(char *);
  198. extern TK_RGBImageRec *tkRGBImageLoadAW(char *, BOOL);
  199. extern TK_RGBImageRec *tkDIBImageLoad(char *);
  200. extern TK_RGBImageRec *tkDIBImageLoadAW(char *, BOOL);
  201. extern GLenum tkCreateStrokeFont(GLuint);
  202. extern GLenum tkCreateOutlineFont(GLuint);
  203. extern GLenum tkCreateFilledFont(GLuint);
  204. extern GLenum tkCreateBitmapFont(GLuint);
  205. extern void tkDrawStr(GLuint, char *);
  206. /* Windows specific routines */
  207. extern HWND tkGetHWND(void);
  208. extern HDC tkGetHDC(void);
  209. extern HGLRC tkGetHRC(void);