22 |
22 |
23 !GLXWorkstation primitiveDefinitions! |
23 !GLXWorkstation primitiveDefinitions! |
24 %{ |
24 %{ |
25 #include "stxOSDefs.h" |
25 #include "stxOSDefs.h" |
26 |
26 |
27 /* |
27 |
28 * on SGI, this class is compiled with -DGLX, while |
|
29 * for simulation (using vogl), this is compiled with -DVGL |
|
30 * |
|
31 * New note: starting to support openGL (tm) (compile with -DOPENGL) |
|
32 * or its simulation (compile with -DMESA) |
|
33 */ |
|
34 |
|
35 /* |
|
36 * SAD, SAD: |
|
37 * on SGI, the GL library seems to come in different versions, |
|
38 * some include the functions below, others dont. |
|
39 * To avoid getting undefined symbol errors when linking, these |
|
40 * functions are not included by default. |
|
41 * |
|
42 * enable the #define below (or compile with -DFULL_GLX) to enable |
|
43 * the following: |
|
44 * |
|
45 * blendcolor getgconfig getmultisample leftbuffer rightbuffer monobuffer |
|
46 * msalpha msmask mspattern mssize multisample stereobuffer |
|
47 * t3s t3i t3f t3d t4s t4i t4f t4d tlutbind zbsize |
|
48 * |
|
49 * these are not available on all gl's |
|
50 */ |
|
51 |
|
52 #ifdef GLX |
|
53 /* #define FULL_GLX */ |
|
54 #endif |
|
55 |
|
56 /* |
|
57 * this is stupid, GLX type-defs String, which is also defined here ... |
|
58 * ... and xlib defines True and False |
|
59 * It might be a better idea, to completely separate GLX stuff from ST/X |
|
60 */ |
|
61 #ifdef String |
28 #ifdef String |
62 # undef String |
29 # undef String |
63 #endif |
30 #endif |
64 #define String GLX_String |
31 #define String GLX_String |
65 |
32 |
109 |
76 |
110 #ifdef __linux__ |
77 #ifdef __linux__ |
111 # include <signal.h> |
78 # include <signal.h> |
112 #endif |
79 #endif |
113 |
80 |
114 #ifndef OPENGL |
81 #include "GL/gl.h" |
115 # ifdef MESA |
82 #include "GL/glx.h" |
116 # define OPENGL |
83 |
117 # endif |
84 #define OPENGLCONTEXT GLXContext |
118 #endif |
85 #define GLXMAKECURRENT(dpy, draw, con) glXMakeCurrent(dpy, draw, con) |
119 |
86 |
120 #ifdef OPENGL /* SGI or other OPENGL library */ |
|
121 |
|
122 # include "GL/gl.h" |
|
123 # include "GL/glx.h" |
|
124 |
|
125 # ifdef MESA /* GNU MESA openGL simulation */ |
|
126 # include "GL/xmesa.h" |
|
127 # define OPENGLCONTEXT XMesaContext |
|
128 # define GLXMAKECURRENT(dpy, draw, con) XMesaMakeCurrent(con) |
|
129 # else |
|
130 /* not yet known what else to include */ |
|
131 # define OPENGLCONTEXT GLXContext |
|
132 # define GLXMAKECURRENT(dpy, draw, con) glxMakeCurrent(dpy, draw, con) |
|
133 # endif |
|
134 |
|
135 #else |
|
136 |
|
137 # ifdef GLX /* SGI native GL library */ |
|
138 # include <gl/glws.h> |
|
139 # include <gl/sphere.h> |
|
140 # else /* VOGL GL subset simulation */ |
|
141 # undef memset |
|
142 # include <vogl.h> |
|
143 # undef move |
|
144 # include <X11/Xlib.h> |
|
145 # endif |
|
146 #endif |
|
147 |
87 |
148 /* |
88 /* |
149 * XSGIStereo extension - if available |
89 * XSGIStereo extension - if available |
150 */ |
90 */ |
151 #ifdef XSGIStereo |
91 #ifdef XSGIStereo |
152 # include <X11/extensions/SGIStereo.h> |
92 # include <X11/extensions/SGIStereo.h> |
153 #endif |
93 #endif |
154 |
|
155 #ifndef NULL |
|
156 # define NULL (char *)0 /* sigh */ |
|
157 #endif |
|
158 |
|
159 |
94 |
160 typedef enum { |
95 typedef enum { |
161 GLXcolorIndexSingleBuffer, |
96 GLXcolorIndexSingleBuffer, |
162 GLXcolorIndexDoubleBuffer, |
97 GLXcolorIndexDoubleBuffer, |
163 GLXrgbSingleBuffer, |
98 GLXrgbSingleBuffer, |
182 /* |
117 /* |
183 * mhmh - openGL has its separate gl-context, |
118 * mhmh - openGL has its separate gl-context, |
184 * which is distinct (?) from the windowID. |
119 * which is distinct (?) from the windowID. |
185 * We dont want to add another instvar to View - do we ? |
120 * We dont want to add another instvar to View - do we ? |
186 */ |
121 */ |
187 #if defined(OPENGL) |
122 #ifndef MAX_OPENGL_VIEWS |
188 |
123 # define MAX_OPENGL_VIEWS 50 |
189 # ifndef MAX_OPENGL_VIEWS |
124 #endif |
190 # define MAX_OPENGL_VIEWS 50 |
|
191 # endif |
|
192 |
125 |
193 struct windowIDToGLContextMapping { |
126 struct windowIDToGLContextMapping { |
194 Window win; |
127 Window win; |
195 OPENGLCONTEXT con; |
128 OPENGLCONTEXT con; |
196 }; |
129 }; |
238 } \ |
171 } \ |
239 } \ |
172 } \ |
240 } |
173 } |
241 |
174 |
242 |
175 |
243 #else /* old GL */ |
176 |
244 |
177 |
245 /* |
178 #define Boolean int |
246 * set the GLXWindow for followup drawing |
179 #define TRUE 1 |
247 */ |
180 #define FALSE 0 |
248 #define SETWIN(aGLXWindowId) \ |
181 #define Coord float |
249 { \ |
182 #define Icoord int |
250 if (_INST(activeWindow) != aGLXWindowId) { \ |
183 #define Scoord int |
251 if (! ISCONNECTED ) { \ |
184 #define Colorindex int |
252 RETURN (false); \ |
185 #define Linestyle int |
253 } \ |
186 #define Offset int |
254 if (! __isExternalAddress(aGLXWindowId)) { \ |
187 #define Angle int |
255 RETURN (false); \ |
188 #define Screencoord int |
256 } \ |
|
257 if (GLXwinset(myDpy, _WindowVal(aGLXWindowId)) < 0) { \ |
|
258 RETURN (false); \ |
|
259 } \ |
|
260 _INST(activeWindow) = aGLXWindowId; \ |
|
261 __STORE(self, aGLXWindowId); \ |
|
262 } else { \ |
|
263 if (aGLXWindowId == nil) { \ |
|
264 RETURN (false); \ |
|
265 } \ |
|
266 } \ |
|
267 } |
|
268 |
|
269 #endif /* old GL */ |
|
270 |
189 |
271 /* |
190 /* |
272 * some defines - tired of typing ... |
191 * some defines - tired of typing ... |
273 * most of these macros/functions extract values from smalltalk objects or |
192 * most of these macros/functions extract values from smalltalk objects or |
274 * put/pack them into corresponding c variables. |
193 * put/pack them into corresponding c variables. |
275 * |
194 * |
276 */ |
195 */ |
277 #ifdef OPENGL |
|
278 # define Boolean int |
|
279 # define TRUE 1 |
|
280 # define FALSE 0 |
|
281 # define Coord float |
|
282 # define Icoord int |
|
283 # define Scoord int |
|
284 # define Colorindex int |
|
285 # define Linestyle int |
|
286 # define Offset int |
|
287 # define Angle int |
|
288 # define Screencoord int |
|
289 #endif |
|
290 |
|
291 #define myDpy (Display *)(__MKCP(_INST(displayId))) |
196 #define myDpy (Display *)(__MKCP(_INST(displayId))) |
292 #define ISCONNECTED (_INST(displayId) != nil) |
197 #define ISCONNECTED (_INST(displayId) != nil) |
293 #define _WindowVal(o) (Window)(__MKCP(o)) |
198 #define _WindowVal(o) (Window)(__MKCP(o)) |
294 |
199 |
295 #define __MKBOOLEAN(b) ((b==FALSE) ? false : true) |
200 #define __MKBOOLEAN(b) ((b==FALSE) ? false : true) |
428 * this duplicates the functionality as found in XWorkstation; |
333 * this duplicates the functionality as found in XWorkstation; |
429 * the reason is to allow dynamic loading systems to load this module |
334 * the reason is to allow dynamic loading systems to load this module |
430 * before XWorkstation (which was not possible otherwise, due to unresolved |
335 * before XWorkstation (which was not possible otherwise, due to unresolved |
431 * external references while loading this one) |
336 * external references while loading this one) |
432 */ |
337 */ |
433 static |
338 static int |
434 __XErrorHandler__(dpy, event) |
339 __XErrorHandler__(Display *dpy, XErrorEvent *event) |
435 Display *dpy; |
340 ; |
436 XErrorEvent *event; |
|
437 { |
341 { |
438 XGetErrorText(dpy, event->error_code, lastErrorMsg, 80); |
342 XGetErrorText(dpy, event->error_code, lastErrorMsg, 80); |
439 if (lastErrorMsg[0] == '\0') { |
343 if (lastErrorMsg[0] == '\0') { |
440 sprintf(lastErrorMsg, "code: %d", event->error_code); |
344 sprintf(lastErrorMsg, "code: %d", event->error_code); |
441 } |
345 } |