Source code: gl4java/GLContext.java
1 /**
2 * @(#) GLContext.java
3 */
4
5
6 package gl4java;
7
8 import gl4java.jau.awt.WinHandleAccess;
9
10 import java.awt.*;
11 import java.applet.Applet;
12 import java.awt.event.*;
13 import java.lang.reflect.*;
14 import java.security.*;
15
16 /**
17 * The base manager class for the OpenGL language mapping for Java !
18 *
19 * <p>
20 * If you are interessting in further Documentation and/or
21 * the history of GL4Java follow the following link.
22 *
23 * <pre>
24 <a href="../GL4Java.html">The GL4Java Documentation</a>
25 * </pre>
26 * <p>
27 *
28 * All native libraries and GLFunc* and GLUFunc* implementations
29 * can/should be loaded right here !
30 *
31 * <pre>
32 <a href="GLContext.html#doLoadNativeLibraries(java.lang.String, java.lang.String, java.lang.String)">doLoadNativeLibraries</a>
33 <a href="GLContext.html#createGLFunc(java.lang.String)">createGLFunc</a>
34 <a href="GLContext.html#createGLUFunc(java.lang.String)">createGLUFunc</a>
35 <p>
36 To check the library versions, you can start the
37 <a href="GLContext.html#main(java.lang.String[])">main</a>
38 function with <code>java gl4java.GLContext</code>
39 * </pre>
40 *
41 * <p>
42 *
43 * This class creates a GLContext in the constructor which fits to the native Window
44 * of the given Component !
45 *
46 * <pre>
47 <a href="GLContext.html#GLContext(java.awt.Component, gl4java.GLFunc, gl4java.GLUFunc>
48 * </pre>
49 *
50 * <p>
51 *
52 * If you want to port any OpenGL program to GL4Java,
53 * you can use 'glc2glj'. This easy kornshell-sed script converts
54 * many types and Math function calls ;-). E.g.: All C double constant literals
55 * will be changed to floats (0.0 -> 0.0f) and all sin, cos, .. functions
56 * will get the '(float)Math.' prefix !
57 *
58 * <pre>
59 <a href="../../../demos/glc2glj">glc2glj - A simple c to java converter for C- and GL-types</a>
60 * </pre>
61 * <p>
62 *
63 * The native libraries are plattform depended.
64 *
65 * <pre>
66 The default native library's are:
67 <p>
68 GL4JavaJauGljJNI (jdk ==1.1),
69 GL4JavaJauGljJNI12 (jdk ==1.2),
70 GL4JavaJauGljJNI13 (jdk ==1.3)
71 GL4JavaJauGljJNI14 (jdk >=1.4)
72 <p>
73 To check wich version and vendors are currently used,
74 just call while a GLContext is created :
75 <p>
76 <a href="GLContext.html#gljShowVersions()">gljShowVersions</a>
77 <p>
78 Or just run at the command line:
79 <p>
80 java gl4java.GLContext -info
81 <p>
82 * </pre>
83 *
84 * Make sure that this library is installed in your library path.
85 * The library path is for Unices one path of the environment
86 * variable īLD_LIBRARY_PATHī and for Windows 32
87 * īc:/winnt/system32ī (WinNT) or 'c:/windows/system' (Windows 95) .
88 * Or it should be installed in the 'jre/bin' or
89 * 'Netscape/communicator/Program/java/bin' path !
90 *
91 * <p>
92 *
93 * To have a convinient usage, e.g. automatic resizing, GLContext
94 * and painting/gl-rendering, some classes in the package gl4java.awt
95 * may help you.
96 *
97 * <pre>
98 E.g.: <a href="awt/GLCanvas.html">gl4java.awt.GLCanvas</a>
99 <p>
100 <a href="awt/GLCanvas.html#init()">init</a> to create the java-stuff and GL-inits
101 <a href="awt/GLCanvas.html#display()">display</a> to render one frame, called by paint
102 <a href="awt/GLCanvas.html#reshape(int, int)">reshape</a> to reshape (window resize)
103 <p>
104 Or look for animation at
105 <a href="awt/GLAnimCanvas.html">gl4java.awt.GLAnimCanvas</a> !
106 * </pre>
107 *
108 * <p>
109 *
110 * IF you remove/release a The component which is binded to this GLContext,
111 * you have to release the GLContext also - while calling:
112 *
113 * <pre>
114 <a href="GLContext.html#gljDestroy()">gljDestroy</a>
115 * </pre>
116 *
117 * before releasing/dispose itīs Window !
118 *
119 * <p>
120 *
121 * We also define our own OpenGL extension. This extension functions
122 * start with the prefix glj like you can see here:
123 *
124 * <pre>
125 THIS FUNCTIONS ARE FOR USERS PURPOSES:
126 ======================================
127
128 <a href="GLContext.html#doLoadNativeLibraries(java.lang.String, java.lang.String, java.lang.String)">doLoadNativeLibraries</a>
129 <a href="GLContext.html#createGLFunc(java.lang.String)">createGLFunc</a>
130 <a href="GLContext.html#createGLUFunc(java.lang.String)">createGLUFunc</a>
131 <a href="GLContext.html#gljIsInit()">gljIsInit</a>
132 <a href="GLContext.html#gljMakeCurrent()">gljMakeCurrent</a>
133 <a href="GLContext.html#gljSwap()">gljSwap</a>
134 <a href="GLContext.html#gljFree()">gljFree</a>
135 <a href="GLContext.html#gljDestroy()">gljDestroy</a>
136 <a href="GLContext.html#gljGetNativeLibVersion()">gljGetNativeLibVersion</a>
137 <a href="GLContext.html#gljGetClassVersion()">gljGetClassVersion</a>
138 <a href="GLContext.html#gljShowVersions()">gljShowVersions</a>
139 <a href="GLContext.html#gljCheckGL()">gljCheckGL</a>
140 <a href="GLContext.html#gljCheckGLTypes()">gljCheckGLTypes</a>
141 <a href="GLContext.html#gljResize(int, int)">gljResize</a>
142
143 * </pre>
144 * <p>
145 *
146 * You can see our example demo sources:
147 * <pre>
148 <a href="../../../demos/olympicCvs.java">olympicCvs.java as java source</a>
149 <a href="../../../demos/glLogoCvs.java">glLogoCvs.java as java source</a>
150 <a href="../../../demos/glDemosCvs.java">glDemosCvs.java as java source</a>
151 * </pre>
152 * <p>
153 *
154 * If you are interessting in further Documentation, downloading the latest
155 * version, and/or the history of GL4Java click on the following link.
156 *
157 * <pre>
158 <a href="http://www.jausoft.com/gl4java.html">The GL4Java Homepage</a>
159 * </pre>
160 * <p>
161 *
162 * @version 2.00, 21. April 1999
163 * @author Sven Goethel
164 *
165 */
166 public class GLContext extends Object
167 implements Runnable
168 {
169 protected boolean isInitialized = false;
170
171 /**
172 * Flag is the native library is loaded.
173 * The native library is loaded at startup.
174 * If we failed loading the lib.,
175 * gljMakeCurrent and gljIsInit will return false.
176 *
177 * @see gl4java.GLContext#gljIsInit
178 */
179 protected static boolean libsLoaded = false;
180
181 /**
182 * The default extra native library for Windows 95/NT && MS-JVM
183 *
184 */
185 public final static String defGljMSWinLib = "GL4JavaGljMSJDirect" ;
186
187 /**
188 * The default GLContext/GLFunc/GLUFunc native library for all
189 *
190 */
191 public final static String defGljLib = "GL4JavaJauGljJNI" ;
192
193 /**
194 * The default GLFunc implementation
195 *
196 */
197 public static final String defGLFuncClass = "GLFuncJauJNI" ;
198 public static final String defGLFunc14Class = "GLFunc14JauJNI" ;
199
200 /**
201 * The default GLUFunc implementation
202 *
203 */
204 public static final String defGLUFuncClass = "GLUFuncJauJNI" ;
205 public static final String defGLUFunc14Class = "GLUFunc14JauJNI" ;
206
207 /**
208 * The default native GL library ... for X11
209 */
210 public final static String defNativeGLLibX11 = "libGL.so";
211
212 /**
213 * The default native GL library ... for MacOS9
214 */
215 public final static String defNativeGLLibMacOS9 = "\\pOpenGLLibrary";
216
217 /**
218 * The default native GL library ... for MacOSX
219 */
220 public final static String defNativeGLLibMacOSX = "libGL.so";
221
222 /**
223 * The default native GL library ... for Win32
224 */
225 public final static String defNativeGLLibWin32 = "OPENGL32.DLL";
226
227
228 /**
229 * The default native GLU library ... for X11
230 */
231 public final static String defNativeGLULibX11 = "libGLU.so";
232
233 /**
234 * The default native GLU library ... for MacOS9
235 */
236 public final static String defNativeGLULibMacOS9 = "\\pOpenGLULibrary";
237
238 /**
239 * The default native GLU library ... for MacOSX
240 */
241 public final static String defNativeGLULibMacOSX = "libGLU.so";
242
243 /**
244 * The default native GLU library ... for Win32
245 */
246 public final static String defNativeGLULibWin32 = "GLU32.DLL";
247
248 /**
249 * the version of this java-class
250 *
251 * <Major>.<Minor>.<BugFix>.<Release>
252 *
253 * Each <Value> is dezimal !
254 */
255 public final static String version = "2.8.0.8" ;
256
257 /**
258 * Flag's to enable/disable verbose Information.
259 * Usually for debugging.
260 */
261 public static boolean gljClassDebug = false;
262 public static boolean gljThreadDebug = false;
263 public static boolean gljNativeDebug = false;
264
265 /**
266 * We will store the GL Context right here.
267 *
268 * @see gl4java.GLContext#createGLContext
269 * @see gl4java.GLContext#gljInit
270 */
271 protected long glContext=0;
272 protected static int glContextNumber=0;
273
274 /**
275 * The context with witch display lists and textures will be shared.
276 *
277 * @see gl4java.GLContext#createGLContext
278 * @see gl4java.GLContext#gljInit
279 */
280 protected GLContext sharedGLContext;
281 protected long sharedGLContextNative= 0; // No sharing by default.
282
283 /**
284 * Xwindow data AND Windows data for the widget
285 *
286 * @see gl4java.GLContext#createGLContext
287 * @see gl4java.GLContext#gljInit
288 */
289 protected long pixmapHandle=0; // unique handle for the Pixmap
290 protected long windowHandle=0; // unique handle for this widget's window
291 protected long displayHandle=0; // unqiue handle to the display
292 private int createwinw;
293 private int createwinh;
294
295 /**
296 * MS-JDirect-Window data for the MS-JVM interface
297 *
298 * @see gl4java.GLContext#createGLContext
299 * @see gl4java.GLContext#gljInit
300 */
301 private int createwinx;
302 private int createwiny;
303 private boolean threadRunning = false;
304 private boolean destroyWindow = false;
305 protected Container containerWindow = null;
306
307 /**
308 * The custom set offscreen Size
309 *
310 * If this is set to != null,
311 * the offscreen pixmap is used in this size,
312 * not in the components-size (-> faster if smaller)
313 *
314 * Must be set via createOffScreenCtx
315 *
316 * @see gl4java.swing.GLJPanel#paint
317 * @see gl4java.GLContext#createOffScreenCtx
318 */
319 protected Dimension offScrnSize = null;
320
321 /**
322 * Windows data AND flag is Window-Handel is read (for X11 also) !
323 *
324 * @see gl4java.GLContext#createGLContext
325 * @see gl4java.GLContext#gljInit
326 */
327 long pData = 0; // stores the pointer structure that holds windows info
328
329 /**
330 * Flag to check, if the OpenGL-Context is active !
331 *
332 * @see gl4java.GLContext#isEnabled
333 * @see gl4java.GLContext#setEnabled
334 */
335 protected boolean glEnabled = true;
336
337 /**
338 * Do we use offscreen rendering
339 * X11: pixmap eq window-ressources,
340 * window eq. GLXPixmap a GLXDrawable
341 * glContext eq. GLXContext
342 *
343 * This is set via the constructor !
344 *
345 * @see gl4java.GLContext#GLContext
346 */
347 protected boolean offScreenRenderer = false;
348
349 /**
350 * We normally do not have to create an own Window !
351 * This is the default visual property ... !
352 * But some machines, like SGI's Irix,
353 * must use an own created overlapped window !
354 * For these machines, a compiler flag is set,
355 * so that this value is alsways set to true !
356 *
357 * This is set via the constructor !
358 *
359 * @see gl4java.GLContext#isOwnWindowCreated
360 * @see gl4java.GLContext#GLContext
361 */
362 protected boolean createOwnWindow = false;
363
364 /**
365 * The GLCapabilities ..
366 *
367 * This is set via the constructor !
368 *
369 * @see gl4java.GLContext#GLContext
370 */
371 protected GLCapabilities glCaps = null;
372
373 /**
374 * The resize flag, which indicates a resize for the next paint function !
375 * This flag will bes set in 'componentResized'
376 * and will be cleared after resize (glViewport) in sDisplay !!
377 *
378 * @see gl4java.awt.GLCanvas#sDisplay
379 */
380 protected boolean mustResize = false;
381
382 protected Dimension size = null;
383
384 /**
385 * the light- or heavy component
386 * where GL commands should be drawn
387 */
388 protected Component _comp = null;
389
390 /**
391 * the heavy component
392 * where GL commands should be drawn
393 *
394 * if the _comp component is a swing (light)
395 * component, this component contains its heavy parent !
396 */
397 protected Component _compHeavy = null;
398
399 /**
400 * Variable to tell is where windows or not (X11)
401 * Usally X11 ;-))
402 *
403 * Ok - lets give one to the Max :-)
404 */
405 public final static int
406 OsWindoof = -1,
407 OsUnknown = 0,
408 OsX11 = 1,
409 OsMac9 = 2, // for Gerard Ziemski's port
410 OsMacX = 3; // for Gerard Ziemski's port
411
412 private static int osType=OsUnknown;
413
414 private static boolean isNetscapeJvm = false;
415 private static boolean isMicrosoftJvm = false;
416 private static boolean isIBMJvm = false;
417 private static boolean useMSJDirect = false;
418 private static String jvmVendor = null;
419 private static String jvmVersion = null;
420 private static int jvmVersionMajor = 1; // min. defaults
421 private static int jvmVersionMinor = 1; // min. defaults
422 private static String osName = null;
423
424 private static String jniEXTsuff = "";
425
426 /**
427 * Get the native GL Context !
428 *
429 * @see gl4java.GLContext#glContext
430 */
431 public final long getNativeGLContext() { return glContext; }
432
433 public final static int getNativeGLContextNumber()
434 { return glContextNumber; }
435
436 /**
437 * Get the native Window Handle !
438 *
439 * @see gl4java.GLContext#windowHandle
440 *
441 * @deprecated The native window handle is no more accessible
442 * through this method since JDK >= 1.3 !
443 */
444 public final long getNativeWindoHandle() { return windowHandle; }
445
446 /**
447 * Get the optional shared GL Context !
448 *
449 * @see gl4java.GLContext#sharedGLContext
450 */
451 public final GLContext getSharedGLContext() { return sharedGLContext; }
452
453 /**
454 * Get the native OS-Type !
455 *
456 * @see gl4java.GLContext#OsWindoof
457 * @see gl4java.GLContext#OsUnknown
458 * @see gl4java.GLContext#OsX11
459 * @see gl4java.GLContext#OsMac9
460 * @see gl4java.GLContext#OsMacX
461 */
462 public static int getNativeOSType() { return osType; }
463
464 public static String getNativeOSName() { return osName; }
465
466 /**
467 * Query the visual property ... !
468 *
469 * After a GLContext is created, this property can be queried !
470 *
471 * @see gl4java.GLContext#glCaps
472 * @see gl4java.GLContext#GLContext
473 */
474 public final GLCapabilities getGLCapabilities() { return glCaps; }
475
476 /**
477 * Query the visual property ... !
478 *
479 * After a GLContext is created, this property can be queried !
480 *
481 * @see gl4java.GLContext#glCaps
482 * @see gl4java.GLContext#GLContext
483 */
484 public final boolean isDoubleBuffer() { return glCaps.getDoubleBuffered(); }
485
486 /**
487 * Query the visual property ... !
488 *
489 * After a GLContext is created, this property can be queried !
490 *
491 * @see gl4java.GLContext#glCaps
492 * @see gl4java.GLContext#GLContext
493 */
494 public final int getStencilBitNumber() { return glCaps.getStencilBits(); }
495
496 /**
497 * Query the visual property ... !
498 *
499 * After a GLContext is created, this property can be queried !
500 *
501 * @see gl4java.GLContext#glCaps
502 * @see gl4java.GLContext#GLContext
503 */
504 public final int getAccumSize()
505 { return glCaps.getAccumRedBits()+
506 glCaps.getAccumGreenBits()+
507 glCaps.getAccumBlueBits()+
508 glCaps.getAccumAlphaBits();
509 }
510
511 /**
512 * Query the visual property ... !
513 *
514 * After a GLContext is created, this property can be queried !
515 *
516 * @see gl4java.GLContext#glCaps
517 * @see gl4java.GLContext#GLContext
518 */
519 public final boolean isStereoView() { return glCaps.getStereo(); }
520
521 /**
522 * Query the visual property ... !
523 *
524 * After a GLContext is created, this property can be queried !
525 *
526 * @see gl4java.GLContext#glCaps
527 * @see gl4java.GLContext#GLContext
528 */
529 public final boolean isRGBA() { return glCaps.getTrueColor(); }
530
531 /**
532 * Query the visual property ... !
533 *
534 * After a GLContext is created, this property can be queried !
535 *
536 * @see gl4java.GLContext#createOwnWindow
537 * @see gl4java.GLContext#GLContext
538 */
539 public final boolean isOwnWindowCreated() { return createOwnWindow; }
540
541 /**
542 * Support of loading the native library seperatly.
543 *
544 * Link with the default native OpenGL library.
545 * If we cannot link, an exception is thrown.
546 *
547 * The name of the library is named e.g.: "GL4JavaJauGljJNI" at the
548 * Java level, or "libGL4JavaJauGljJNI.so" at the solaris level,
549 * or "GL4JavaJauGljJNI.dll" at the win32 level :-).
550 *
551 * <p>
552 *
553 * The user must call loadNativeLibrary !
554 * E.g. he can add the default loader like this:
555 * <pre>
556 static {
557 if(GLContext.loadNativeLibraries(null, null, null)==false)
558 System.out.println("could not load def. native libs.");
559 }
560 * </pre>
561 *
562 * @param gljLibName The name of the GLContex/GLFunc/GLUFunc
563 * native library.
564 * If gljLibName==null, the default library will be used !
565 *
566 * @param glLibName deprecated
567 *
568 * @param gluLibName deprecated
569 *
570 * @return boolean, true if succesfull !
571 *
572 * @see gl4java.GLContext#defGljLib
573 *
574 * @deprecated The arguments glLibName and gluLibName are obsolete,
575 * because all glj/gl/glu stuff resides within
576 * the gljLib !
577 * Now you can use doLoadNativeLibraries !
578 */
579 public final static boolean loadNativeLibraries ( String gljLibName,
580 String glLibName,
581 String gluLibName
582 )
583 {
584 return doLoadNativeLibraries(gljLibName, null, null);
585 }
586
587 /**
588 * Support of loading the native library seperatly.
589 *
590 * Link with the given OpenGL library.
591 * If we cannot link, an exception is thrown.
592 *
593 * You can also specify the OpenGL and GLU library by
594 * the environment variables:
595 * <pre>
596 GLTOOL_USE_GLLIB - OpenGL library name
597 GLTOOL_USE_GLULIB - GLU library name
598 * </pre>
599 * these environment variables does _always_ overrides
600 * any given ones at this point !!
601 *
602 * The name of the library is named e.g.: "GL4JavaJauGljJNI" at the
603 * Java level, or "libGL4JavaJauGljJNI.so" at the solaris level,
604 * or "GL4JavaJauGljJNI.dll" at the win32 level :-).
605 *
606 * <p>
607 *
608 * The user must call doLoadNativeLibrary !
609 * E.g. he can add the default loader like this:
610 * <pre>
611 static {
612 if(GLContext.doLoadNativeLibraries(null, null, null)==false)
613 System.out.println("could not load def. native libs.");
614 }
615 * </pre>
616 *
617 * @param gljLibName The name of the GLContex/GLFunc/GLUFunc
618 * native library.
619 * If gljLibName==null, the default library will be used !
620 *
621 * @param nativeGLLibName The name of the native GL library.
622 * If nativeGLLibName==null, the default library will be used !
623 *
624 * @param nativeGLULibName The name of the native GLU library.
625 * If nativeGLULibName==null, the default library will be used !
626 *
627 * @return boolean, true if succesfull !
628 *
629 * @see gl4java.GLContext#defGljLib
630 * @see gl4java.GLContext#defNativeGLLibX11
631 * @see gl4java.GLContext#defNativeGLLibMacOS9
632 * @see gl4java.GLContext#defNativeGLLibMacOSX
633 * @see gl4java.GLContext#defNativeGLLibWin32
634 * @see gl4java.GLContext#defNativeGLULibX11
635 * @see gl4java.GLContext#defNativeGLULibMacOS9
636 * @see gl4java.GLContext#defNativeGLULibMacOSX
637 * @see gl4java.GLContext#defNativeGLULibWin32
638 */
639 public final static boolean doLoadNativeLibraries ( String gljLibName,
640 String nativeGLLibName,
641 String nativeGLULibName
642 )
643 {
644 if(libsLoaded) return true;
645
646 if(gljClassDebug)
647 System.out.println("GLContext.doLoadNativeLibraries will do it !");
648
649 jvmVendor = java.lang.System.getProperty("java.vendor");
650 jvmVersion = java.lang.System.getProperty("java.version");
651
652 if(gljClassDebug)
653 {
654 System.out.println("jvm vendor: "+jvmVendor);
655 System.out.println("jvm version: "+jvmVersion);
656 }
657
658 int i0 = 0;
659 int i1 = jvmVersion.indexOf(".", i0);
660 String strhlp = null;
661 if(i1>0)
662 {
663 strhlp = jvmVersion.substring(i0,i1);
664 try {
665 jvmVersionMajor = Integer.valueOf(strhlp).intValue();
666 } catch (Exception e)
667 {System.out.println("Not a number: "+strhlp+" ("+jvmVersion+")");}
668 }
669 i0 = i1+1;
670 i1 = jvmVersion.indexOf(".", i0);
671 if( i1 < 0 )
672 i1 = jvmVersion.length(); // no 2nd dot, no bug version number
673
674 if( 0<i0 && i0<i1 )
675 {
676 strhlp = jvmVersion.substring(i0,i1);
677 try {
678 jvmVersionMinor = Integer.valueOf(strhlp).intValue();
679 } catch (Exception e)
680 {System.out.println("Not a number: "+strhlp+" ("+jvmVersion+")");}
681 }
682
683 if(gljClassDebug)
684 {
685 System.out.println("jvm version (parsed): "+
686 "major: "+jvmVersionMajor+
687 ", minor: "+jvmVersionMinor);
688 }
689
690 isNetscapeJvm = jvmVendor!=null && jvmVendor.indexOf("Netscape")>=0 ;
691 isMicrosoftJvm = jvmVendor!=null && jvmVendor.indexOf("Microsoft")>=0 ;
692 isIBMJvm = jvmVendor!=null && jvmVendor.indexOf("IBM")>=0 ;
693
694 // Determine the OS
695 osName = System.getProperty( "os.name" );
696 if( osName.startsWith( "Wind" ) )
697 osType = OsWindoof;
698 else if( osName.startsWith( "Mac OS X" ) )
699 osType = OsMacX;
700 else if( osName.startsWith( "Mac OS" ) )
701 osType = OsMac9;
702 else /* oops - lets guess unix/x11 :-) */
703 osType = OsX11;
704
705 String libNames[] = null;
706
707 if( jvmVersionMajor>=2 ||
708 ( jvmVersionMajor==1 && jvmVersionMinor>=4 )
709 )
710 {
711 jniEXTsuff = "14";
712 }
713
714 else
715
716 if( jvmVersionMajor==1 && jvmVersionMinor>=3
717 && !isIBMJvm && !isMicrosoftJvm
718 )
719 {
720 jniEXTsuff = "13";
721 }
722
723 else
724
725 if( jvmVersionMajor==1 && jvmVersionMinor>=2 )
726 {
727 jniEXTsuff = "12";
728 }
729
730 else
731
732 {
733 jniEXTsuff = "";
734 }
735
736
737 if(gljLibName==null)
738 gljLibName = defGljLib+jniEXTsuff;
739
740 if(nativeGLLibName==null)
741 {
742 if ( osType==OsWindoof )
743 nativeGLLibName = defNativeGLLibWin32;
744 else if ( osType==OsMac9 )
745 nativeGLLibName = defNativeGLLibMacOS9;
746 else if ( osType==OsMacX )
747 nativeGLLibName = defNativeGLLibMacOSX;
748 else
749 nativeGLLibName = defNativeGLLibX11;
750 }
751
752 if(nativeGLULibName==null)
753 {
754 if ( osType==OsWindoof )
755 nativeGLULibName = defNativeGLULibWin32;
756 else if ( osType==OsMac9 )
757 nativeGLULibName = defNativeGLULibMacOS9;
758 else if ( osType==OsMacX )
759 nativeGLULibName = defNativeGLULibMacOSX;
760 else
761 nativeGLULibName = defNativeGLULibX11;
762 }
763
764 if ( (osType==OsWindoof) && (isMicrosoftJvm) )
765 {
766 // JDirect loads the GL libraries automatically,
767 // so we don't have to.
768 libNames = new String[2];
769 libNames[0]= gljLibName;
770 libNames[1]= defGljMSWinLib;
771 useMSJDirect = true;
772 } else {
773 /* For MAC, Win32+SunJVM, Unices ...
774 */
775 libNames = new String[1];
776 libNames[0]= gljLibName;
777 useMSJDirect = false;
778 }
779
780 final String f_libNames[] = libNames;
781
782 if(isNetscapeJvm)
783 {
784 System.out.println("Netscape JVM try to get Privileges");
785 try {
786 Class privmgr =
787 Class.forName("netscape.security.PrivilegeManager");
788 Class[] parameterTypes = new Class[1];
789 parameterTypes[0] = Class.forName("java.lang.String");
790 Method m = privmgr.getMethod("enablePrivilege",parameterTypes);
791 Object args[] = new Object[1];
792 args[0] = (Object)(new String("UniversalLinkAccess"));
793 m.invoke(privmgr,args);
794 /*
795 netscape.security.PrivilegeManager.enablePrivilege
796 ("UniversalLinkAccess");
797 */
798 System.out.println("Netscape-Privilege: enabled UniversalLinkAccess priv.");
799 } catch (Exception ex)
800 {
801 System.out.println("Not enabled Netscape-Privilege: UniversalLinkAccess priv.");
802 }
803 }
804
805 boolean ok;
806
807 if( jvmVersionMajor>=2 ||
808 (jvmVersionMajor==1 && jvmVersionMinor>=2)
809 )
810 {
811 Boolean ook = (Boolean)
812 AccessController.doPrivileged(new PrivilegedAction() {
813 public Object run()
814 {
815 /* load libs */
816 int libNumber = 0;
817 String _libName = null ;
818 boolean libLoaded[] = new boolean[f_libNames.length];
819
820 for(libNumber=0; libNumber<f_libNames.length; libNumber++)
821 libLoaded[libNumber]=false;
822
823 for(libNumber=0; libNumber<f_libNames.length; libNumber++)
824 {
825 do {
826 try {
827 System.loadLibrary( f_libNames[libNumber] );
828 libLoaded[libNumber]=true;
829 if(gljClassDebug)
830 {
831 System.out.println("loaded native library: "+
832 f_libNames[libNumber]);
833 }
834 } catch ( UnsatisfiedLinkError e) {
835 System.out.println
836 ( "Sorry, can't find the library: "+
837 f_libNames[libNumber]+"\n"+e );
838
839 f_libNames[libNumber]=null; // stop trying ... :-(
840 }
841 } while( libLoaded[libNumber]==false &&
842 f_libNames[libNumber]!=null );
843 }
844 for(libNumber=0; libNumber<f_libNames.length; libNumber++)
845 if(libLoaded[libNumber]==false)
846 return new Boolean(false);
847 return new Boolean(true);
848 }
849 });
850 ok = ook.booleanValue();
851 } else
852 {
853 /* load libs */
854 int libNumber = 0;
855 String _libName = null ;
856 boolean libLoaded[] = new boolean[f_libNames.length];
857
858 for(libNumber=0; libNumber<f_libNames.length; libNumber++)
859 libLoaded[libNumber]=false;
860
861 for(libNumber=0; libNumber<f_libNames.length; libNumber++)
862 {
863 do {
864 try {
865 System.loadLibrary( f_libNames[libNumber] );
866 libLoaded[libNumber]=true;
867 if(gljClassDebug)
868 {
869 System.out.println("loaded native library: "+
870 f_libNames[libNumber]);
871 }
872 } catch ( UnsatisfiedLinkError e) {
873 System.out.println
874 ( "Sorry, can't find the library: "+
875 f_libNames[libNumber]+"\n"+e );
876
877 f_libNames[libNumber]=null; // stop trying ... :-(
878 }
879 } while( libLoaded[libNumber]==false &&
880 f_libNames[libNumber]!=null );
881 }
882 ok = true;
883 for(libNumber=0; libNumber<f_libNames.length; libNumber++)
884 if(libLoaded[libNumber]==false) { ok = false; break; }
885 }
886
887 if(ok)
888 {
889 /**
890 * load the GL/GLU libs natively first, so
891 * the OS can use the dynamic loader to
892 * solve the symbol names ..
893 */
894 if(gljClassDebug)
895 System.out.println("fetching GL/GLU functions ...");
896 if(gljFetchGLFunctions
897 (nativeGLLibName, nativeGLULibName, true)
898 )
899 {
900 System.out.println("fetched GL/GLU functions succesfully !");
901 libsLoaded=true;
902 } else {
903 System.out.println("GL4Java-ERROR: can't fetch GL/GLU functions !");
904 }
905
906 }
907
908 if(!libsLoaded)
909 System.exit(1);
910
911 return libsLoaded;
912 }
913
914 /**
915 * Test to load the native library, GLFunc and GLUFunc implementation !
916 * If succesfull, a Frame will created and the GL-Infos (vendor, ...)
917 * are shown in it !
918 *
919 * @param args, a list of args,
920 *
921 * -GLLib <OpenGL libname>
922 * -GLULib <GLU libname>
923 * -gljlib <glj-libname> gl4java-glj-lib native library
924 * -glclass <gl-class> gl4java-gl-class java GLFunc implementation
925 * -gluclass <glu-class> gl4java-glu-class java GLUFunc implementation
926 * -info creates a GLContext and prints all avaiable information of GL/GLU and GL4Java
927 * -infotxt like -info, but exits straight after -info !
928 *
929 * without any arguments, a help screen is shown
930 */
931 public static void main( String args[] )
932 {
933 String nativeGLLib = null;
934 String nativeGLULib = null;
935 String gljLibName = null;
936 String glName = null;
937 String gluName = null;
938 boolean info=false;
939 boolean exitImmediatly=false;
940 boolean noFactory=false;
941 int i = 0;
942 boolean ok=true;
943
944 if(args.length==0)
945 {
946 System.out.println("usage: java gl4java.GLContext <options>, where options can be: ");
947 System.out.println(" -GLLib <OpenGL Libname> \t choose a custom OpenGL native library (default: libGL, or OPENGL32, ..)");
948 System.out.println(" -GLULib <GLU Libname> \t choose a custom GLU native library (default: libGLU, or GLU32, ..)");
949 System.out.println(" -gljlib <glj-libname> \t choose a custom gl4java-glj-lib native library (default: GL4JavaJauGljJNI)");
950 System.out.println(" -glclass <gl-class> \t choose a custom gl4java-gl-class java GLFunc implementation (default: GLFuncJauJNI)");
951 System.out.println(" -gluclass <glu-class> \t choose a custom gl4java-glu-class java GLUFunc implementation (default: GLUFuncJauJNI)");
952 System.out.println(" -info \t creates a GLContext and prints all avaiable information of GL/GLU and GL4Java");
953 System.out.println(" -infotxt \t like -info, but exits straight after -info !");
954 System.out.println(" -noFactory \t creates a GLContext without the new GLDrawableFactory API");
955 System.exit(0);
956 }
957
958 while(args.length>i)
959 {
960 if(args[i].equals("-GLLib")) {
961 if(args.length>++i) nativeGLLib=args[i];
962 } else if(args[i].equals("-GLULib")) {
963 if(args.length>++i) nativeGLULib=args[i];
964 } else if(args[i].equals("-gljlib")) {
965 if(args.length>++i) gljLibName=args[i];
966 } else if(args[i].equals("-glclass")) {
967 if(args.length>++i) glName=args[i];
968 } else if(args[i].equals("-gluclass")) {
969 if(args.length>++i) gluName=args[i];
970 } else if(args[i].equals("-info")) {
971 info=true;
972 } else if(args[i].equals("-infotxt")) {
973 info=true;
974 exitImmediatly=true;
975 } else if(args[i].equals("-noFactory")) {
976 noFactory=true;
977 } else {
978 System.out.println("illegal arg "+i+": "+args[i]);
979 ok=false;
980 }
981 i++;
982 }
983
984 GLContext.gljNativeDebug = true;
985 GLContext.gljClassDebug = true;
986
987 GLFunc gl = null;
988 GLUFunc glu = null;
989
990 if(GLContext.doLoadNativeLibraries(gljLibName,
991 nativeGLLib, nativeGLULib
992 )
993 )
994 System.out.println("native Libraries loaded succesfull");
995 else {
996 System.out.println("native library NOT loaded complete");
997 ok=false;
998 }
999
1000 if( (gl=GLContext.createGLFunc(glName)) !=null)
1001 System.out.println("GLFunc implementation "+gl.getClass().getName()+" created succesfull");
1002 else {
1003 System.out.println("GLFunc implementation "+glName+" not created");
1004 ok=false;
1005 }
1006 if( (glu=GLContext.createGLUFunc(gluName)) !=null)
1007 System.out.println("GLUFunc implementation "+glu.getClass().getName()+" created succesfull");
1008 else {
1009 System.out.println("GLUFunc implementation "+gluName+" not created");
1010 ok=false;
1011 }
1012
1013 if( info && ok==true) {
1014 Frame f = new Frame("GL4Java Info");
1015 f.setSize(10, 10);
1016
1017 Canvas cvs = null;
1018 GLCapabilities glCaps = new GLCapabilities();
1019 gl4java.drawable.GLDrawableFactory df =
1020 gl4java.drawable.GLDrawableFactory.getFactory();
1021
1022 if(noFactory ||
1023 !(df instanceof gl4java.drawable.SunJDK13GLDrawableFactory)
1024 )
1025 {
1026 cvs = new Canvas();
1027 } else {
1028 gl4java.drawable.SunJDK13GLDrawableFactory sdf =
1029 (gl4java.drawable.SunJDK13GLDrawableFactory)df;
1030 cvs = new Canvas(sdf.getGraphicsConfiguration(glCaps));
1031 }
1032 cvs.setVisible(true);
1033 cvs.setSize(50,50);
1034 f.add("Center", cvs);
1035 f.setSize(60,60);
1036
1037 // f.pack();
1038 f.setVisible(true);
1039
1040 GLContext glj = new GLContext( cvs, gl, glu, glCaps, null);
1041
1042 Frame fInfo = glj.gljShowVersions();
1043
1044 fInfo.addWindowListener
1045 ( new WindowAdapter()
1046 {
1047 public void windowClosed(WindowEvent e)
1048 {
1049 // button exit
1050 System.exit(0);
1051 }
1052 }
1053 );
1054
1055 glj.gljDestroy();
1056
1057 if(exitImmediatly)
1058 System.exit(0);
1059 }
1060 }
1061
1062 public static String getJVMVersion() { return jvmVersion; }
1063 public static int getJVMVersionMajor() { return jvmVersionMajor; }
1064 public static int getJVMVersionMinor() { return jvmVersionMinor; }
1065
1066 public static String getJVMVendor() { return jvmVendor; }
1067 public static boolean isNetscapeJVM() { return isNetscapeJvm; }
1068 public static boolean isMicrosoftJVM() { return isMicrosoftJvm; }
1069
1070 /**
1071 * Used to hold the user given GLFunc implementation
1072 */
1073 private GLFunc gl = null;
1074
1075 /**
1076 * Used to hold the user given GLUFunc implementation
1077 */
1078 private GLUFunc glu = null;
1079
1080 /**
1081 *
1082 * Constructor
1083 *
1084 * This privat constructor is for all possible
1085 * compinations and is called from the customized
1086 * constructors.
1087 *
1088 * First the GLContext is fetched from the Component itself !
1089 * To do so, the Component is set visible if it is not !
1090 *
1091 * If a GLContext is fetched, it is current !
1092 *
1093 * @param comp the users component for the gl-context
1094 * @param glf the users selected GLFunc implementation
1095 * @param glf the users selected GLUFunc implementation
1096 * @param _createOwnWindow the flag for the visual property
1097 * @param _offScreenRenderer the flag for the visual property
1098 * @param _offScrnSize the fixed offscreen pixmap size
1099 * @param _glCaps the GLCapabilities
1100 * @param _sharedGLContext the shared GLContext
1101 *
1102 */
1103 protected GLContext( Component comp, GLFunc glf, GLUFunc gluf,
1104 boolean _createOwnWindow,
1105 boolean _offScreenRenderer,
1106 Dimension _offScrnSize,
1107 GLCapabilities _glCaps,
1108 GLContext _sharedGLContext
1109 )
1110 {
1111 super( );
1112
1113 _comp = comp ; // the light- or heavy component
1114 gl = glf ;
1115 glu = gluf ;
1116 createOwnWindow = _createOwnWindow;
1117 offScreenRenderer = _offScreenRenderer;
1118 offScrnSize= _offScrnSize;
1119
1120 glCaps = _glCaps;
1121
1122 this.sharedGLContext = _sharedGLContext;
1123 if(sharedGLContext != null)
1124 sharedGLContextNative =
1125 (int)sharedGLContext.getNativeGLContext();
1126
1127 // fetch the heavy peer component in temporary var. comp
1128 while(comp!=null &&
1129 (comp.getPeer() instanceof java.awt.peer.LightweightPeer)
1130 )
1131 comp=comp.getParent();
1132
1133 _compHeavy = comp ; // the heavy component
1134
1135 Graphics _gr = null;
1136
1137 if(_compHeavy!=null)
1138 {
1139 if( ! _comp.isVisible() )
1140 setVisible(true); // use our own ...
1141
1142
1143 _gr = _compHeavy.getGraphics();
1144 if(_gr==null)
1145 System.out.println("got empty Graphics");
1146 } else
1147 System.out.println("got empty Component");
1148
1149 if(_comp!=null && _gr!=null)
1150 {
1151 int i = 0;
1152 do {
1153 createGLContext(_gr); // uses _comp
1154 if(gljIsInit()==false)
1155 {
1156 try
1157 {
1158 Thread.sleep( 100 );
1159 }
1160 catch( Exception e )
1161 { }
1162 }
1163 i++;
1164 } while(gljIsInit()==false && i<5) ;
1165 }
1166
1167 if(gljClassDebug)
1168 {
1169 if(gljIsInit())
1170 System.out.println("GLContext GLContext() succeded");
1171 else
1172 System.out.println("GLContext GLContext() failed");
1173 }
1174 }
1175
1176 /**
1177 *
1178 * Constructor
1179 *
1180 * This privat constructor is for all possible
1181 * compinations and is called from the customized
1182 * constructors.
1183 *
1184 * First the GLContext is fetched from the Component itself !
1185 * To do so, the Component is set visible if it is not !
1186 *
1187 * If a GLContext is fetched, it is current !
1188 *
1189 * @param comp the users component for the gl-context
1190 * @param glf the users selected GLFunc implementation
1191 * @param glf the users selected GLUFunc implementation
1192 * @param _createOwnWindow the flag for the visual property
1193 * @param _offScreenRenderer the flag for the visual property
1194 * @param _doubleBuffer the flag for the visual property
1195 * @param _stereoView the flag for the visual property
1196 * @param _rgba the flag for the visual property
1197 * @param _stencilBits the flag for the visual property
1198 * @param _accumSize the flag for the visual property
1199 * @param _sharedGLContext the shared GLContext
1200 * @param _offScrnSize the fixed offscreen pixmap size
1201 *
1202 */
1203 protected GLContext( Component comp, GLFunc glf, GLUFunc gluf,
1204 boolean _createOwnWindow, boolean _offScreenRenderer,
1205 boolean _doubleBuffer, boolean _stereoView,
1206 boolean _rgba,
1207 int _stencilBits,
1208 int _accumSize,
1209 GLContext _sharedGLContext,
1210 Dimension _offScrnSize
1211 )
1212 {
1213 this( comp, glf, gluf, _createOwnWindow,
1214 _offScreenRenderer, _offScrnSize,
1215 new GLCapabilities(_doubleBuffer, _stereoView,
1216 _rgba, _stencilBits,
1217 _accumSize, _accumSize,
1218 _accumSize, _accumSize),
1219 _sharedGLContext);
1220 }
1221
1222 /**
1223 *
1224 * Constructor
1225 *
1226 * First the GLContext is fetched from the Component itself !
1227 * To do so, the Component is set visible if it is not !
1228 *
1229 * If a GLContext is fetched, it is current !
1230 *
1231 * @param comp the users component for the gl-context
1232 * @param glf the users selected GLFunc implementation
1233 * @param glf the users selected GLUFunc implementation
1234 * @param _glCaps the GLCapabilities
1235 * @param _sharedGLContext the shared GLContext
1236 *
1237 */
1238 public GLContext( Component comp, GLFunc glf, GLUFunc gluf,
1239 GLCapabilities _glCaps,
1240 GLContext _sharedGLContext
1241 )
1242 {
1243 this( comp, glf, gluf, false,
1244 false, null, _glCaps,
1245 _sharedGLContext);
1246 }
1247
1248 /**
1249 *
1250 * Constructor
1251 *
1252 * First the GLContext is fetched from the Component itself !
1253 * To do so, the Component is set visible if it is not !
1254 *
1255 * If a GLContext is fetched, it is current !
1256 *
1257 * @param comp the users component for the gl-context
1258 * @param glf the users selected GLFunc implementation
1259 * @param glf the users selected GLUFunc implementation
1260 * @param _createOwnWindow the flag for the visual property
1261 * @param _doubleBuffer the flag for the visual property
1262 * @param _stereoView the flag for the visual property
1263 * @param _rgba the flag for the visual property
1264 * @param _stencilBits the flag for the visual property
1265 * @param _accumSize the flag for the visual property
1266 * @param _sharedGLContext the shared GLContext
1267 *
1268 */
1269 public GLContext( Component comp, GLFunc glf, GLUFunc gluf,
1270 boolean _createOwnWindow,
1271 boolean _doubleBuffer, boolean _stereoView,
1272 boolean _rgba,
1273 int _stencilBits,
1274 int _accumSize,
1275 GLContext _sharedGLContext
1276 )
1277 {
1278 this(comp, glf, gluf,
1279 _createOwnWindow, false /* offscreen renderer */,
1280 _doubleBuffer,
1281 _stereoView,
1282 _rgba,
1283 _stencilBits,
1284 _accumSize,
1285 _sharedGLContext,
1286 null /* offscreen size */
1287 );
1288 }
1289
1290 /**
1291 *
1292 * Constructor
1293 *
1294 * First the GLContext is fetched from the Component itself !
1295 * To do so, the Component is set visible if it is not !
1296 *
1297 * If a GLContext is fetched, it is current !
1298 *
1299 * @param comp the users component for the gl-context
1300 * @param glf the users selected GLFunc implementation
1301 * @param glf the users selected GLUFunc implementation
1302 * @param _createOwnWindow the flag for the visual property
1303 * @param _doubleBuffer the flag for the visual property
1304 * @param _stereoView the flag for the visual property
1305 * @param _rgba the flag for the visual property
1306 * @param _stencilBits the flag for the visual property
1307 * @param _accumSize the flag for the visual property
1308 *
1309 */
1310 public GLContext( Component comp, GLFunc glf, GLUFunc gluf,
1311 boolean _createOwnWindow,
1312 boolean _doubleBuffer, boolean _stereoView,
1313 boolean _rgba,
1314 int _stencilBits,
1315 int _accumSize
1316 )
1317 {
1318 this(comp, glf, gluf,
1319 _createOwnWindow, false /* offscreen renderer */,
1320 _doubleBuffer,
1321 _stereoView,
1322 _rgba,
1323 _stencilBits,
1324 _accumSize,
1325 null /* sharedGLContext */,
1326 null /* offscreen size */
1327 );
1328 }
1329
1330 /**
1331 *
1332 * Constructor
1333 *
1334 * First the GLContext is fetched from the Component itself !
1335 * To do so, the Component is set visible if it is not !
1336 *
1337 * If a GLContext is fetched, it is current !
1338 *
1339 * @param comp the users component for the gl-context
1340 * @param glf the users selected GLFunc implementation
1341 * @param glf the users selected GLUFunc implementation
1342 * @param _createOwnWindow the flag for the visual property
1343 * @param _doubleBuffer the flag for the visual property
1344 * @param _stereoView the flag for the visual property
1345 * @param _rgba the flag for the visual property
1346 * @param _stencilBits the flag for the visual property
1347 *
1348 */
1349 public GLContext( Component comp, GLFunc glf, GLUFunc gluf,
1350 boolean _createOwnWindow,
1351 boolean _doubleBuffer, boolean _stereoView,
1352 boolean _rgba,
1353 int _stencilBits
1354 )
1355 {
1356 this(comp, glf, gluf,
1357 _createOwnWindow, false /* offscreen renderer */,
1358 _doubleBuffer,
1359 _stereoView,
1360 _rgba,
1361 _stencilBits,
1362 0 /* accumSize */,
1363 null /* sharedGLContext */,
1364 null /* offscreen size */
1365 );
1366 }
1367
1368 /**
1369 *
1370 * Constructor
1371 *
1372 * First the GLContext is fetched from the Component itself !
1373 * To do so, the Component is set visible if it is not !
1374 *
1375 * If a GLContext is fetched, it is current !
1376 *
1377 * @param comp the users component for the gl-context
1378 * @param glf the users selected GLFunc implementation
1379 * @param glf the users selected GLUFunc implementation
1380 * @param _doubleBuffer the flag for the visual property
1381 * @param _stereoView the flag for the visual property
1382 * @param _rgba the flag for the visual property
1383 * @param _stencilBits the flag for the visual property
1384 *
1385 */
1386 public GLContext( Component comp, GLFunc glf, GLUFunc gluf,
1387 boolean _doubleBuffer, boolean _stereoView,
1388 boolean _rgba,
1389 int _stencilBits,
1390 int _accumSize
1391 )
1392 {
1393 this(comp, glf, gluf,
1394 false /* ownWindow */, false /* offscreen renderer */,
1395 _doubleBuffer,
1396 _stereoView,
1397 _rgba,
1398 _stencilBits,
1399 _accumSize,
1400 null /* sharedGLContext */,
1401 null /* offscreen size */
1402 );
1403 }
1404
1405 /**
1406 *
1407 * Constructor
1408 *
1409 * First the GLContext is fetched from the Component itself !
1410 * To do so, the Component is set visible if it is not !
1411 *
1412 * If a GLContext is fetched, it is current !
1413 *
1414 * @param comp the users component for the gl-context
1415 * @param glf the users selected GLFunc implementation
1416 * @param glf the users selected GLUFunc implementation
1417 * @param _doubleBuffer the flag for the visual property
1418 * @param _stereoView the flag for the visual property
1419 * @param _rgba the flag for the visual property
1420 * @param _stencilBits the flag for the visual property
1421 *
1422 */
1423 public GLContext( Component comp, GLFunc glf, GLUFunc gluf,
1424 boolean _doubleBuffer, boolean _stereoView,
1425 boolean _rgba,
1426 int _stencilBits
1427 )
1428 {
1429 this(comp, glf, gluf,
1430 false /* ownWindow */, false /* offscreen renderer */,
1431 _doubleBuffer,
1432 _stereoView,
1433 _rgba,
1434 _stencilBits,
1435 0 /* accumSize */,
1436 null /* sharedGLContext */,
1437 null /* offscreen size */
1438 );
1439 }
1440
1441 /**
1442 *
1443 * Constructor
1444 *
1445 * First the GLContext is fetched from the Component itself !
1446 * To do so, the Component is set visible if it is not !
1447 *
1448 * If a GLContext is fetched, it is current !
1449 *
1450 * @param comp the users component for the gl-context
1451 * @param glf the users selected GLFunc implementation
1452 * @param glf the users selected GLUFunc implementation
1453 * @param _doubleBuffer the flag for the visual property
1454 * @param _stereoView the flag for the visual property
1455 * @param _rgba the flag for the visual property
1456 * @param _stencilBits the flag for the visual property
1457 *
1458 */
1459 public GLContext( Component comp, GLFunc glf, GLUFunc gluf,
1460 boolean _doubleBuffer, boolean _stereoView,
1461 boolean _rgba
1462 )
1463 {
1464 this(comp, glf, gluf,
1465 false /* ownWindow */, false /* offscreen renderer */,
1466 _doubleBuffer,
1467 _stereoView,
1468 _rgba,
1469 0, /* _stencilBits */
1470 0 /* accumSize */,
1471 null /* sharedGLContext */,
1472 null /* offscreen size */
1473 );
1474 }
1475
1476 /**
1477 *
1478 * Constructor
1479 *
1480 * First the GLContext is fetched from the Component itself !
1481 * To do so, the Component is set visible if it is not !
1482 *
1483 * If a GLContext is fetched, it is current !
1484 *
1485 * ! WARNING ! This flag is just for testing purpose !!!
1486 *
1487 * @param comp the users component for the gl-context
1488 * @param glf the users selected GLFunc implementation
1489 * @param glf the users selected GLUFunc implementation
1490 * @param _doubleBuffer the flag for the visual property
1491 * @param _stereoView the flag for the visual property
1492 *
1493 */
1494 public GLContext( Component comp, GLFunc glf, GLUFunc gluf,
1495 boolean _doubleBuffer, boolean _stereoView
1496 )
1497 {
1498 this(comp, glf, gluf,
1499 false /* ownWindow */, false /* offscreen renderer */,
1500 _doubleBuffer,
1501 _stereoView,
1502 true /* _rgba */,
1503 0, /* _stencilBits */
1504 0 /* accumSize */,
1505 null /* sharedGLContext */,
1506 null /* offscreen size */
1507 );
1508 }
1509
1510 /**
1511 *
1512 * Constructor
1513 *
1514 * First the GLContext is fetched from the Component itself !
1515 * To do so, the Component is set visible if it is not !
1516 *
1517 * We use a visual with doubleBuffer and NO stereoView !
1518 * Do not force a new native window !
1519 *
1520 * If a GLContext is fetched, it is current !
1521 *
1522 * @param comp the users component for the gl-context
1523 * @param glf the users selected GLFunc implementation
1524 * @param glf the users selected GLUFunc implementation
1525 */
1526 public GLContext( Component comp, GLFunc glf, GLUFunc gluf )
1527 {
1528 this(comp, glf, gluf,
1529 false /* ownWindow */, false /* offscreen renderer */,
1530 true /* _doubleBuffer */,
1531 false /* _stereoView */,
1532 true /* _rgba */,
1533 0, /* _stencilBits */
1534 0 /* accumSize */,
1535 null /* sharedGLContext */,
1536 null /* offscreen size */
1537 );
1538 }
1539
1540 /**
1541 *
1542 * Constructor Function for offscreen rendering !
1543 *
1544 *