home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / opengl / siggraphCD / lib / libtk / tk.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  6.8 KB  |  261 lines

  1. /*
  2.  * (c) Copyright 1993, 1994, 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. /*
  44. ** Nano Window Toolkit.
  45. ** Version 1.1
  46. */
  47.  
  48. /*
  49. ** Window Types
  50. */
  51.  
  52. #define TK_RGB        0
  53. #define TK_INDEX    1
  54. #define TK_SINGLE    0
  55. #define TK_DOUBLE    2
  56. #define TK_DIRECT    0
  57. #define TK_INDIRECT    4
  58. #define TK_ACCUM    8
  59. #define TK_ALPHA    16
  60. #define TK_DEPTH    32
  61. #define TK_OVERLAY    64
  62. #define TK_UNDERLAY    128
  63. #define TK_STENCIL    512
  64.  
  65. /* 
  66. ** Window Masks
  67. */
  68.  
  69. #define TK_IS_RGB(x)        (((x) & TK_INDEX) == 0)
  70. #define TK_IS_INDEX(x)        (((x) & TK_INDEX) != 0)
  71. #define TK_IS_SINGLE(x)        (((x) & TK_DOUBLE) == 0)
  72. #define TK_IS_DOUBLE(x)        (((x) & TK_DOUBLE) != 0)
  73. #define TK_IS_DIRECT(x)        (((x) & TK_INDIRECT) == 0)
  74. #define TK_IS_INDIRECT(x)    (((x) & TK_INDIRECT) != 0)
  75. #define TK_HAS_ACCUM(x)        (((x) & TK_ACCUM) != 0)
  76. #define TK_HAS_ALPHA(x)        (((x) & TK_ALPHA) != 0)
  77. #define TK_HAS_DEPTH(x)        (((x) & TK_DEPTH) != 0)
  78. #define TK_HAS_OVERLAY(x)    (((x) & TK_OVERLAY) != 0)
  79. #define TK_HAS_UNDERLAY(x)    (((x) & TK_UNDERLAY) != 0)
  80. #define TK_HAS_STENCIL(x)    (((x) & TK_STENCIL) != 0)
  81.  
  82. /*
  83. ** Windowing System Specific Gets
  84. */
  85.  
  86. enum {
  87.     TK_X_DISPLAY = 1,
  88.     TK_X_WINDOW
  89. };
  90.  
  91. /*
  92. ** Event Status
  93. */
  94.  
  95. #define    TK_LEFTBUTTON        1
  96. #define    TK_RIGHTBUTTON        2
  97. #define    TK_MIDDLEBUTTON        4
  98. #define    TK_SHIFT        1
  99. #define    TK_CONTROL        2
  100.  
  101. /* 
  102. ** Key Codes
  103. */
  104.  
  105. #define TK_RETURN        0x0D
  106. #define TK_ESCAPE        0x1B
  107. #define TK_SPACE        0x20
  108. #define TK_LEFT            0x25
  109. #define TK_UP            0x26
  110. #define TK_RIGHT        0x27
  111. #define TK_DOWN            0x28
  112. #define TK_A            'A'
  113. #define TK_B            'B'
  114. #define TK_C            'C'
  115. #define TK_D            'D'
  116. #define TK_E            'E'
  117. #define TK_F            'F'
  118. #define TK_G            'G'
  119. #define TK_H            'H'
  120. #define TK_I            'I'
  121. #define TK_J            'J'
  122. #define TK_K            'K'
  123. #define TK_L            'L'
  124. #define TK_M            'M'
  125. #define TK_N            'N'
  126. #define TK_O            'O'
  127. #define TK_P            'P'
  128. #define TK_Q            'Q'
  129. #define TK_R            'R'
  130. #define TK_S            'S'
  131. #define TK_T            'T'
  132. #define TK_U            'U'
  133. #define TK_V            'V'
  134. #define TK_W            'W'
  135. #define TK_X            'X'
  136. #define TK_Y            'Y'
  137. #define TK_Z            'Z'
  138. #define TK_a            'a'
  139. #define TK_b            'b'
  140. #define TK_c            'c'
  141. #define TK_d            'd'
  142. #define TK_e            'e'
  143. #define TK_f            'f'
  144. #define TK_g            'g'
  145. #define TK_h            'h'
  146. #define TK_i            'i'
  147. #define TK_j            'j'
  148. #define TK_k            'k'
  149. #define TK_l            'l'
  150. #define TK_m            'm'
  151. #define TK_n            'n'
  152. #define TK_o            'o'
  153. #define TK_p            'p'
  154. #define TK_q            'q'
  155. #define TK_r            'r'
  156. #define TK_s            's'
  157. #define TK_t            't'
  158. #define TK_u            'u'
  159. #define TK_v            'v'
  160. #define TK_w            'w'
  161. #define TK_x            'x'
  162. #define TK_y            'y'
  163. #define TK_z            'z'
  164. #define TK_0            '0'
  165. #define TK_1            '1'
  166. #define TK_2            '2'
  167. #define TK_3            '3'
  168. #define TK_4            '4'
  169. #define TK_5            '5'
  170. #define TK_6            '6'
  171. #define TK_7            '7'
  172. #define TK_8            '8'
  173. #define TK_9            '9'
  174.  
  175. /*
  176. ** Color Macros
  177. */
  178.  
  179. enum {
  180.     TK_BLACK = 0,
  181.     TK_RED,
  182.     TK_GREEN,
  183.     TK_YELLOW,
  184.     TK_BLUE,
  185.     TK_MAGENTA,
  186.     TK_CYAN,
  187.     TK_WHITE
  188. };
  189.  
  190. extern float tkRGBMap[8][3];
  191.  
  192. #define TK_SETCOLOR(x, y) (TK_IS_RGB((x)) ? \
  193.                    glColor3fv(tkRGBMap[(y)]) : glIndexf((y)))
  194.  
  195. /*
  196. ** RGB Image Structure
  197. */
  198.  
  199. typedef struct _TK_RGBImageRec {
  200.     GLint sizeX, sizeY;
  201.     unsigned char *data;
  202. } TK_RGBImageRec;
  203.  
  204. /*
  205. ** Prototypes
  206. */
  207.  
  208. extern void tkInitDisplayMode(GLenum);
  209. extern void tkInitPosition(int, int, int, int);
  210. extern GLenum tkInitWindow(char *);
  211. extern void tkCloseWindow(void);
  212. extern void tkQuit(void);
  213.  
  214. extern GLenum tkSetWindowLevel(GLenum);
  215. extern void tkSwapBuffers(void);
  216.  
  217. extern void tkExec(void);
  218. extern void tkExposeFunc(void (*)(int, int));
  219. extern void tkReshapeFunc(void (*)(int, int));
  220. extern void tkDisplayFunc(void (*)(void));
  221. extern void tkKeyDownFunc(GLenum (*)(int, GLenum));
  222. extern void tkMouseDownFunc(GLenum (*)(int, int, GLenum));
  223. extern void tkMouseUpFunc(GLenum (*)(int, int, GLenum));
  224. extern void tkMouseMoveFunc(GLenum (*)(int, int, GLenum));
  225. extern void tkIdleFunc(void (*)(void));
  226.  
  227. extern int tkGetColorMapSize(void);
  228. extern void tkGetMouseLoc(int *, int *);
  229. extern void tkGetSystem(GLenum, void *);
  230.  
  231. extern void tkSetOneColor(int, float, float, float);
  232. extern void tkSetFogRamp(int, int);
  233. extern void tkSetGreyRamp(void);
  234. extern void tkSetRGBMap(int, float *);
  235. extern void tkSetOverlayMap(int, float *);
  236.  
  237. extern void tkNewCursor(GLint, GLubyte *, GLubyte *, GLenum, GLenum,
  238.             GLint, GLint);
  239. extern void tkSetCursor(GLint);
  240.  
  241. extern TK_RGBImageRec *tkRGBImageLoad(char *);
  242.  
  243. extern GLenum tkCreateStrokeFont(GLuint);
  244. extern GLenum tkCreateOutlineFont(GLuint);
  245. extern GLenum tkCreateFilledFont(GLuint);
  246. extern GLenum tkCreateBitmapFont(GLuint);
  247. extern void tkDrawStr(GLuint, char *);
  248.  
  249. extern void tkWireSphere(GLuint, float);
  250. extern void tkSolidSphere(GLuint, float);
  251. extern void tkWireCube(GLuint, float);
  252. extern void tkSolidCube(GLuint, float);
  253. extern void tkWireBox(GLuint, float, float, float);
  254. extern void tkSolidBox(GLuint, float, float, float);
  255. extern void tkWireTorus(GLuint, float, float);
  256. extern void tkSolidTorus(GLuint, float, float);
  257. extern void tkWireCylinder(GLuint, float, float);
  258. extern void tkSolidCylinder(GLuint, float, float);
  259. extern void tkWireCone(GLuint, float, float);
  260. extern void tkSolidCone(GLuint, float, float);
  261.