1 /* $Id: togl.h,v 1.28 2005/10/27 07:45:48 gregcouch Exp $ */
2 
3 /* vi:set sw=4: */
4 
5 /*
6  * Togl - a Tk OpenGL widget
7  *
8  * Copyright (C) 1996-1998  Brian Paul and Ben Bederson
9  * See the LICENSE file for copyright details.
10  */
11 
12 
13 #ifndef TOGL_H
14 #  define TOGL_H
15 
16 #if !defined TOGL_X11 && !defined TOGL_WGL && !defined TOGL_AGL_CLASSIC && !defined TOGL_AGL
17 #  include "togl_ws.h"
18 #endif
19 
20 #  ifdef TOGL_WGL
21 #    define WIN32_LEAN_AND_MEAN
22 #    include <windows.h>
23 #    undef WIN32_LEAN_AND_MEAN
24 #    if defined(_MSC_VER)
25 #      	define DllEntryPoint DllMain
26 #    endif
27 #  endif
28 
29 #  ifdef _WIN32
30 #    define TOGL_EXTERN __declspec(dllexport) extern
31 #  else
32 #    define TOGL_EXTERN extern
33 #  endif /* _WIN32 */
34 
35 #  ifdef TOGL_AGL_CLASSIC
36 #    ifndef MAC_TCL
37 #      define MAC_TCL 1
38 #    endif
39 #  endif
40 
41 #  ifdef TOGL_AGL
42 #    ifndef MAC_OSX_TCL
43 #      define MAC_OSX_TCL 1
44 #    endif
45 #    ifndef MAC_OSX_TK
46 #      define MAC_OSX_TK 1
47 #    endif
48 #  endif
49 
50 #  include <tcl.h>
51 #  include <tk.h>
52 #  if defined(TOGL_AGL) || defined(TOGL_AGL_CLASSIC)
53 #    include <OpenGL/gl.h>
54 #  else
55 #    include <GL/gl.h>
56 #  endif
57 
58 #  ifdef __sgi
59 #    include <GL/glx.h>
60 #    include <X11/extensions/SGIStereo.h>
61 #  endif
62 
63 #  ifndef CONST84
64 #    define CONST84
65 #  endif
66 
67 #  ifndef NULL
68 #    define NULL 0
69 #  endif
70 
71 #  ifndef TOGL_USE_FONTS
72 #    define TOGL_USE_FONTS 1    /* needed for demos */
73 #  endif
74 
75 #  ifdef __cplusplus
76 /* *INDENT-OFF* */
77 extern "C" {
78 /* *INDENT-ON* */
79 #  endif
80 
81 #  define TOGL_VERSION "1.7"
82 #  define TOGL_MAJOR_VERSION 1
83 #  define TOGL_MINOR_VERSION 7
84 
85 /*
86  * "Standard" fonts which can be specified to Togl_LoadBitmapFont()
87  */
88 #  define TOGL_BITMAP_8_BY_13		((char *) 1)
89 #  define TOGL_BITMAP_9_BY_15		((char *) 2)
90 #  define TOGL_BITMAP_TIMES_ROMAN_10	((char *) 3)
91 #  define TOGL_BITMAP_TIMES_ROMAN_24	((char *) 4)
92 #  define TOGL_BITMAP_HELVETICA_10	((char *) 5)
93 #  define TOGL_BITMAP_HELVETICA_12	((char *) 6)
94 #  define TOGL_BITMAP_HELVETICA_18	((char *) 7)
95 
96 /*
97  * Normal and overlay plane constants
98  */
99 #  define TOGL_NORMAL	1
100 #  define TOGL_OVERLAY	2
101 
102 struct Togl;
103 typedef struct Togl Togl;
104 
105 typedef void (Togl_Callback) (Togl *togl);
106 typedef int (Togl_CmdProc) (Togl *togl, int argc, CONST84 char *argv[]);
107 
108 TOGL_EXTERN int Togl_Init(Tcl_Interp *interp);
109 
110 /*
111  * Default/initial callback setup functions
112  */
113 
114 TOGL_EXTERN void Togl_CreateFunc(Togl_Callback *proc);
115 TOGL_EXTERN void Togl_DisplayFunc(Togl_Callback *proc);
116 TOGL_EXTERN void Togl_ReshapeFunc(Togl_Callback *proc);
117 TOGL_EXTERN void Togl_DestroyFunc(Togl_Callback *proc);
118 TOGL_EXTERN void Togl_TimerFunc(Togl_Callback *proc);
119 TOGL_EXTERN void Togl_ResetDefaultCallbacks(void);
120 
121 /*
122  * Change callbacks for existing widget
123  */
124 
125 TOGL_EXTERN void Togl_SetCreateFunc(Togl *togl, Togl_Callback *proc);
126 TOGL_EXTERN void Togl_SetDisplayFunc(Togl *togl, Togl_Callback *proc);
127 TOGL_EXTERN void Togl_SetReshapeFunc(Togl *togl, Togl_Callback *proc);
128 TOGL_EXTERN void Togl_SetDestroyFunc(Togl *togl, Togl_Callback *proc);
129 TOGL_EXTERN void Togl_SetTimerFunc(Togl *togl, Togl_Callback *proc);
130 
131 /*
132  * Miscellaneous
133  */
134 
135 TOGL_EXTERN int Togl_Configure(Tcl_Interp *interp, Togl *togl,
136         int argc, const char *argv[], int flags);
137 TOGL_EXTERN void Togl_MakeCurrent(const Togl *togl);
138 TOGL_EXTERN void Togl_CreateCommand(char *cmd_name, Togl_CmdProc *cmd_proc);
139 TOGL_EXTERN void Togl_PostRedisplay(Togl *togl);
140 TOGL_EXTERN void Togl_SwapBuffers(const Togl *togl);
141 
142 /*
143  * Query functions
144  */
145 
146 TOGL_EXTERN const char *Togl_Ident(const Togl *togl);
147 TOGL_EXTERN int Togl_Width(const Togl *togl);
148 TOGL_EXTERN int Togl_Height(const Togl *togl);
149 TOGL_EXTERN Tcl_Interp *Togl_Interp(const Togl *togl);
150 TOGL_EXTERN Tk_Window Togl_TkWin(const Togl *togl);
151 
152 /*
153  * Color Index mode
154  */
155 
156 TOGL_EXTERN unsigned long Togl_AllocColor(const Togl *togl, float red,
157         float green, float blue);
158 TOGL_EXTERN void Togl_FreeColor(const Togl *togl, unsigned long index);
159 TOGL_EXTERN void Togl_SetColor(const Togl *togl, unsigned long index,
160         float red, float green, float blue);
161 
162 #  if TOGL_USE_FONTS == 1
163 /*
164  * Bitmap fonts
165  */
166 
167 TOGL_EXTERN GLuint Togl_LoadBitmapFont(const Togl *togl, const char *fontname);
168 TOGL_EXTERN void Togl_UnloadBitmapFont(const Togl *togl, GLuint fontbase);
169 
170 #  endif
171 /*
172  * Overlay functions
173  */
174 
175 TOGL_EXTERN void Togl_UseLayer(Togl *togl, int layer);
176 TOGL_EXTERN void Togl_ShowOverlay(Togl *togl);
177 TOGL_EXTERN void Togl_HideOverlay(Togl *togl);
178 TOGL_EXTERN void Togl_PostOverlayRedisplay(Togl *togl);
179 TOGL_EXTERN void Togl_OverlayDisplayFunc(Togl_Callback *proc);
180 TOGL_EXTERN int Togl_ExistsOverlay(const Togl *togl);
181 TOGL_EXTERN int Togl_GetOverlayTransparentValue(const Togl *togl);
182 TOGL_EXTERN int Togl_IsMappedOverlay(const Togl *togl);
183 TOGL_EXTERN unsigned long Togl_AllocColorOverlay(const Togl *togl,
184         float red, float green, float blue);
185 TOGL_EXTERN void Togl_FreeColorOverlay(const Togl *togl, unsigned long index);
186 
187 /*
188  * User client data
189  */
190 
191 TOGL_EXTERN void Togl_ClientData(ClientData clientData);
192 TOGL_EXTERN ClientData Togl_GetClientData(const Togl *togl);
193 TOGL_EXTERN void Togl_SetClientData(Togl *togl, ClientData clientData);
194 
195 #  ifdef TOGL_X11
196 /*
197  * X11-only commands.
198  * Contributed by Miguel A. De Riera Pasenau (miguel@DALILA.UPC.ES)
199  */
200 
201 TOGL_EXTERN Display *Togl_Display(const Togl *togl);
202 TOGL_EXTERN Screen *Togl_Screen(const Togl *togl);
203 TOGL_EXTERN int Togl_ScreenNumber(const Togl *togl);
204 TOGL_EXTERN Colormap Togl_Colormap(const Togl *togl);
205 
206 #  endif
207 #  ifdef __sgi
208 /*
209  * SGI stereo-only commands.
210  * Contributed by Ben Evans (Ben.Evans@anusf.anu.edu.au)
211  */
212 
213 TOGL_EXTERN void Togl_OldStereoDrawBuffer(GLenum mode);
214 TOGL_EXTERN void Togl_OldStereoClear(GLbitfield mask);
215 #  endif
216 
217 TOGL_EXTERN void Togl_StereoFrustum(GLfloat left, GLfloat right, GLfloat bottom,
218         GLfloat top, GLfloat near, GLfloat far, GLfloat eyeDist,
219         GLfloat eyeOffset);
220 
221 /*
222  * Generate EPS file.
223  * Contributed by Miguel A. De Riera Pasenau (miguel@DALILA.UPC.ES)
224  */
225 
226 TOGL_EXTERN int Togl_DumpToEpsFile(const Togl *togl, const char *filename,
227         int inColor, void (*user_redraw) (const Togl *));
228 
229 #  ifdef TOGL_AGL_CLASSIC
230 /*
231  * Mac-specific setup functions
232  */
233 extern int Togl_MacInit(void);
234 extern int Togl_MacSetupMainInterp(Tcl_Interp *interp);
235 #  endif
236 
237 #  ifdef __cplusplus
238 /* *INDENT-OFF* */
239 }
240 /* *INDENT-ON* */
241 #  endif
242 
243 
244 #endif
245