home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / togl15.zip / togl.h < prev    next >
C/C++ Source or Header  |  2000-02-16  |  8KB  |  326 lines

  1. /* $Id: togl.h,v 1.17 1997/11/15 04:14:37 brianp Exp $ */
  2.  
  3. /*
  4.  * Togl - a Tk OpenGL widget
  5.  * Version 1.5
  6.  * Copyright (C) 1996-1997  Brian Paul and Ben Bederson
  7.  * See the LICENSE file for copyright details.
  8.  */
  9.  
  10.  
  11. /*
  12.  * $Log: togl.h,v $
  13.  * Revision 1.17  1997/11/15 04:14:37  brianp
  14.  * changed version to 1.5
  15.  *
  16.  * Revision 1.16  1997/11/15 02:58:48  brianp
  17.  * added Togl_TkWin() per Glenn Lewis
  18.  *
  19.  * Revision 1.15  1997/10/01 02:49:45  brianp
  20.  * added SGI stereo functions from Ben Evans
  21.  *
  22.  * Revision 1.14  1997/08/26 02:05:19  brianp
  23.  * added Togl_ResetDefaultCallbacks() and Togl_ClientData() (Greg Couch)
  24.  *
  25.  * Revision 1.13  1997/08/26 01:35:41  brianp
  26.  * added Togl_Set*Func() functions from Matthias Ott
  27.  *
  28.  * Revision 1.12  1997/08/22 02:48:25  brianp
  29.  * added WIN32 header stuff.  changed Togl version to 1.4.
  30.  *
  31.  * Revision 1.11  1997/04/11 01:37:22  brianp
  32.  * added Togl_TimerFunc() and related code from Elmar Gerwalin
  33.  *
  34.  * Revision 1.10  1997/02/16 10:03:33  brianp
  35.  * removed GL/glx.h include, added X11/Xlib.h include
  36.  *
  37.  * Revision 1.9  1997/02/16 01:25:34  brianp
  38.  * added new overlay and EPS functions from Miguel A. De Riera Pasenau
  39.  *
  40.  * Revision 1.8  1996/12/13 21:24:41  brianp
  41.  * added Togl_DestroyFunc() contributed by scotter@iname.com
  42.  *
  43.  * Revision 1.7  1996/11/14 00:49:54  brianp
  44.  * added Togl_Get/SetClientData() functions
  45.  *
  46.  * Revision 1.6  1996/11/05 02:40:12  brianp
  47.  * added Togl_Configure() and Togl_UnloadBitmapFont()
  48.  *
  49.  * Revision 1.5  1996/10/25 03:44:06  brianp
  50.  * updated version to 1.2
  51.  *
  52.  * Revision 1.4  1996/10/24 01:20:17  brianp
  53.  * added overlay constants and functions
  54.  *
  55.  * Revision 1.3  1996/10/24 00:13:34  brianp
  56.  * added const qualifier to many function parameters
  57.  *
  58.  * Revision 1.2  1996/10/23 23:28:06  brianp
  59.  * updated version to 1.1
  60.  * added TOGL_BITMAP_* constants
  61.  * added Togl_LoadBitmapFont()
  62.  *
  63.  * Revision 1.1  1996/10/23 23:15:27  brianp
  64.  * Initial revision
  65.  *
  66.  */
  67.  
  68.  
  69. #ifndef TOGL_H
  70. #define TOGL_H
  71.  
  72.  
  73. /*** Windows headers ***/
  74. #ifdef WIN32
  75. #define WIN32_LEAN_AND_MEAN
  76. #include <windows.h>
  77. #undef WIN32_LEAN_AND_MEAN
  78. #include <winnt.h>
  79. #endif /*WIN32*/
  80.  
  81. /*** OS/2 headers ***/
  82. #ifdef __EMX__
  83. #define INCL_WIN
  84. #include <os2.h>
  85. #undef INCL_WIN
  86. #endif
  87.  
  88. #include <tcl.h>
  89. #include <tk.h>
  90. #include <GL/gl.h>
  91. #ifdef TOGL_X11
  92. #include <X11/Xlib.h>
  93. #endif
  94.  
  95. #ifdef __sgi
  96. #include <GL/glx.h>
  97. #include <X11/extensions/SGIStereo.h>
  98. #endif
  99.  
  100.  
  101. #ifndef NULL
  102. #define NULL    0
  103. #endif
  104.  
  105.  
  106. #ifdef __cplusplus
  107. extern "C" {
  108. #endif
  109.  
  110.  
  111.  
  112. #define TOGL_VERSION "1.5"
  113. #define TOGL_MAJOR_VERSION 1
  114. #define TOGL_MINOR_VERSION 5
  115.  
  116.  
  117.  
  118. /*
  119.  * "Standard" fonts which can be specified to Togl_LoadBitmapFont()
  120.  */
  121. #define TOGL_BITMAP_8_BY_13        ((char *) 1)
  122. #define TOGL_BITMAP_9_BY_15        ((char *) 2)
  123. #define TOGL_BITMAP_TIMES_ROMAN_10    ((char *) 3)
  124. #define TOGL_BITMAP_TIMES_ROMAN_24    ((char *) 4)
  125. #define TOGL_BITMAP_HELVETICA_10    ((char *) 5)
  126. #define TOGL_BITMAP_HELVETICA_12    ((char *) 6)
  127. #define TOGL_BITMAP_HELVETICA_18    ((char *) 7)
  128.  
  129.  
  130. /*
  131.  * Normal and overlay plane constants
  132.  */
  133. #define TOGL_NORMAL    1
  134. #define TOGL_OVERLAY    2
  135.  
  136.  
  137.  
  138. struct Togl;
  139.  
  140.  
  141. typedef void (Togl_Callback) (struct Togl *togl);
  142. typedef int  (Togl_CmdProc) (struct Togl *togl, int argc, char *argv[]);
  143.  
  144.  
  145.  
  146. extern int Togl_Init( Tcl_Interp *interp );
  147.  
  148.  
  149.  
  150. /*
  151.  * Callback setup functions
  152.  */
  153.  
  154. extern void Togl_CreateFunc( Togl_Callback *proc );
  155.  
  156. extern void Togl_DisplayFunc( Togl_Callback *proc );
  157.  
  158. extern void Togl_ReshapeFunc( Togl_Callback *proc );
  159.  
  160. extern void Togl_DestroyFunc( Togl_Callback *proc );
  161.  
  162. extern void Togl_TimerFunc( Togl_Callback *proc );
  163.  
  164. extern void Togl_ResetDefaultCallbacks( void );
  165.  
  166.  
  167. /*
  168.  * Change callbacks for existing widget
  169.  */
  170.  
  171. extern void Togl_SetCreateFunc( struct Togl *togl, Togl_Callback *proc );
  172.  
  173. extern void Togl_SetDisplayFunc( struct Togl *togl, Togl_Callback *proc );
  174.  
  175. extern void Togl_SetReshapeFunc( struct Togl *togl, Togl_Callback *proc );
  176.  
  177. extern void Togl_SetDestroyFunc( struct Togl *togl, Togl_Callback *proc );
  178.  
  179.  
  180. /*
  181.  * Miscellaneous
  182.  */
  183.  
  184. extern int Togl_Configure( Tcl_Interp *interp, struct Togl *togl, 
  185.                            int argc, char *argv[], int flags );
  186.  
  187. extern void Togl_MakeCurrent( const struct Togl *togl );
  188.  
  189. extern void Togl_CreateCommand( char *cmd_name,
  190.                                 Togl_CmdProc *cmd_proc );
  191.  
  192. extern void Togl_PostRedisplay( struct Togl *togl );
  193.  
  194. extern void Togl_SwapBuffers( const struct Togl *togl );
  195.  
  196.  
  197. /*
  198.  * Query functions
  199.  */
  200.  
  201. extern char *Togl_Ident( const struct Togl *togl );
  202.  
  203. extern int Togl_Width( const struct Togl *togl );
  204.  
  205. extern int Togl_Height( const struct Togl *togl );
  206.  
  207. extern Tcl_Interp *Togl_Interp( const struct Togl *togl );
  208.  
  209. extern Tk_Window Togl_TkWin( const struct Togl *togl );
  210.  
  211.  
  212. /*
  213.  * Color Index mode
  214.  */
  215.  
  216. #ifndef __EMX__
  217. /*  paletted mode unsupported in OS/2 */
  218.  
  219. extern unsigned long Togl_AllocColor( const struct Togl *togl,
  220.                                       float red, float green, float blue );
  221.  
  222. extern void Togl_FreeColor( const struct Togl *togl, unsigned long index );
  223.  
  224. extern void Togl_SetColor( const struct Togl *togl, unsigned long index,
  225.                            float red, float green, float blue );
  226. #endif /* __EMX__ */
  227.  
  228. /*
  229.  * Bitmap fonts
  230.  */
  231.  
  232. #ifndef __EMX__
  233. /*  fonts unsupported in OS/2 */
  234.  
  235. extern GLuint Togl_LoadBitmapFont( const struct Togl *togl,
  236.                                    const char *fontname );
  237.  
  238. extern void Togl_UnloadBitmapFont( const struct Togl *togl, GLuint fontbase );
  239.  
  240. #endif /* __EMX__ */
  241.  
  242. /*
  243.  * Overlay functions
  244.  */
  245.  
  246. extern void Togl_UseLayer( struct Togl *togl, int layer );
  247.  
  248. extern void Togl_ShowOverlay( struct Togl *togl );
  249.  
  250. extern void Togl_HideOverlay( struct Togl *togl );
  251.  
  252. extern void Togl_PostOverlayRedisplay( struct Togl *togl );
  253.  
  254. extern void Togl_OverlayDisplayFunc( Togl_Callback *proc );
  255.  
  256. extern int Togl_ExistsOverlay( const struct Togl *togl );
  257.  
  258. extern int Togl_GetOverlayTransparentValue( const struct Togl *togl );
  259.  
  260. extern int Togl_IsMappedOverlay( const struct Togl *togl );
  261.  
  262. extern unsigned long Togl_AllocColorOverlay( const struct Togl *togl,
  263.                                              float red, float green, 
  264.                                              float blue );
  265.  
  266. extern void Togl_FreeColorOverlay( const struct Togl *togl, 
  267.                                    unsigned long index );
  268.  
  269. /*
  270.  * User client data
  271.  */
  272.  
  273. extern void Togl_ClientData( ClientData clientData );
  274.  
  275. extern ClientData Togl_GetClientData( const struct Togl *togl );
  276.  
  277. extern void Togl_SetClientData( struct Togl *togl, ClientData clientData );
  278.  
  279.  
  280. /*
  281.  * X11-only commands.
  282.  * Contributed by Miguel A. De Riera Pasenau (miguel@DALILA.UPC.ES)
  283.  */
  284.  
  285. #ifdef TOGL_X11
  286. extern Display *Togl_Display( const struct Togl *togl );
  287. extern Screen *Togl_Screen( const struct Togl *togl );
  288. extern int Togl_ScreenNumber( const struct Togl *togl );
  289. extern Colormap Togl_Colormap( const struct Togl *togl );
  290. #endif
  291.  
  292.  
  293. /*
  294.  * SGI stereo-only commands.
  295.  * Contributed by Ben Evans (Ben.Evans@anusf.anu.edu.au)
  296.  */
  297.  
  298. #ifdef __sgi
  299. extern void Togl_StereoDrawBuffer( GLenum mode );
  300. extern void Togl_StereoFrustum( GLfloat left, GLfloat right,
  301.                                 GLfloat bottom, GLfloat top,
  302.                                 GLfloat near, GLfloat far,
  303.                                 GLfloat eyeDist, GLfloat eyeOffset );
  304. extern void Togl_StereoClear( GLbitfield mask );
  305. #endif
  306.  
  307.  
  308. /*
  309.  * Generate EPS file.
  310.  * Contributed by Miguel A. De Riera Pasenau (miguel@DALILA.UPC.ES)
  311.  */
  312.  
  313. extern int Togl_DumpToEpsFile( const struct Togl *togl,
  314.                                const char *filename,
  315.                                int inColor,
  316.                                void (*user_redraw)(const struct Togl *) );
  317.  
  318.  
  319.  
  320. #ifdef __cplusplus
  321. }
  322. #endif
  323.  
  324.  
  325. #endif
  326.