From 3e2b16a820bfe03f8f3837c3aaa615c8c4b7f18c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 13 Feb 2001 05:32:07 +0000 Subject: JAWT Support JDK >=1.3 --- gl4java/GL4JavaReflections.java | 1 - gl4java/GLContext.java.skel | 559 ++++++++++++++++------- gl4java/GLEnum.java | 4 +- gl4java/GLFunc.java | 8 +- gl4java/GLFuncJauJNI.java | 4 +- gl4java/GLFuncJauJNInf.java | 4 +- gl4java/GLUEnum.java | 4 +- gl4java/GLUFunc.java | 133 +++--- gl4java/GLUFuncJauJNI.java | 133 +++--- gl4java/GLUFuncJauJNInf.java | 133 +++--- gl4java/applet/SimpleGLAnimApplet1.java | 46 ++ gl4java/awt/GLAnimCanvas.java | 229 ++++++---- gl4java/awt/GLCanvas.java | 110 +++-- gl4java/jau/awt/WinHandleAccess.java | 4 +- gl4java/jau/awt/macintosh/MacHandleAccess.java | 8 +- gl4java/jau/awt/motif/X11HandleAccess.java | 7 +- gl4java/jau/awt/windows/MSWin32HandleAccess.java | 7 +- gl4java/jau/awt/windows/Win32HandleAccess.java | 7 +- gl4java/swing/GLAnimJPanel.java | 155 ++++--- gl4java/swing/GLJPanel.java | 95 ++-- gl4java/system/GljMSJDirect.java | 12 +- gl4java/utils/Test.java | 2 +- gl4java/utils/glut/GLUTFuncLightImpl.java | 2 +- 23 files changed, 974 insertions(+), 693 deletions(-) (limited to 'gl4java') diff --git a/gl4java/GL4JavaReflections.java b/gl4java/GL4JavaReflections.java index 79969bf..7ae4d28 100644 --- a/gl4java/GL4JavaReflections.java +++ b/gl4java/GL4JavaReflections.java @@ -12,7 +12,6 @@ import java.lang.reflect.*; /** * The function-declaration holder ! * - * @see CFuncVariable * @version 1.00, 12. Novemeber 1999 * @author Sven Goethel * diff --git a/gl4java/GLContext.java.skel b/gl4java/GLContext.java.skel index c91e4f6..449a3b3 100644 --- a/gl4java/GLContext.java.skel +++ b/gl4java/GLContext.java.skel @@ -62,27 +62,27 @@ import java.lang.reflect.*; * The native libraries are plattform depended. * *
-	  The default native library for Win32 and Unice's is :
-	  

- GLContext: GL4JavaJauGljJNI - GLFuncJauJNI: GL4JavaJauGLJNI - GLUFuncJauJNI: GL4JavaJauGLUJNI -

- Note: -

- The default native library for Macintosh is : -

- GLContext: GL4JavaMacGZGljJNI - GLFuncJauJNI: GL4JavaMacGZGLJNI - GLUFuncJauJNI: GL4JavaMacGZGLUJNI + The default native library's are:

+ GLContext: GL4JavaJauGljJNI (jdk ==1.1), + GL4JavaJauGljJNI12 (jdk ==1.2), + GL4JavaJauGljJNI13 (jdk >=1.3) + + GLFuncJauJNI: GL4JavaJauGLJNI (jdk ==1.1), + GL4JavaJauGLJNI12 (jdk >=1.2) + + GLUFuncJauJNI: GL4JavaJauGLUJNI (jdk ==1.1), + GL4JavaJauGLUJNI12 (jdk >=1.2)

To check wich version and vendors are currently used, just call while a GLContext is created :

gljShowVersions

- Where an own Frame is opened ! + Or just run at the command line: +

+ java gl4java.GLContext -info +

*

* * Make sure that this library is installed in your library path. @@ -132,17 +132,17 @@ import java.lang.reflect.*; loadNativeLibraries createGLFunc createGLUFunc + gljIsInit + gljMakeCurrent + gljSwap + gljFree + gljDestroy gljGetNativeLibVersion gljGetClassVersion gljShowVersions gljCheckGL gljCheckGLTypes gljResize - gljSwap - gljIsInit - gljMakeCurrent - gljDestroy - gljFree * *

@@ -163,7 +163,6 @@ import java.lang.reflect.*; * *

* - * @see WinDataAccess * @version 2.00, 21. April 1999 * @author Sven Goethel * @@ -171,7 +170,6 @@ import java.lang.reflect.*; public class GLContext extends Object implements Runnable { - protected boolean isInitialized = false; /** @@ -180,8 +178,7 @@ public class GLContext extends Object * If we failed loading the lib., * gljMakeCurrent and gljIsInit will return false. * - * @see GLContext#gljMakeCurrent - * @see GLContext#gljIsInit + * @see gl4java.GLContext#gljIsInit */ protected static boolean libsLoaded = false; @@ -234,45 +231,47 @@ public class GLContext extends Object * Usually for debugging. */ public static boolean gljClassDebug = false; + public static boolean gljThreadDebug = false; public static boolean gljNativeDebug = false; /** * We will store the GL Context right here. * - * @see GLContext#createGLContext - * @see GLContext#gljInit + * @see gl4java.GLContext#createGLContext + * @see gl4java.GLContext#gljInit */ - protected int glContext=0; + protected long glContext=0; + protected static int glContextNumber=0; /** * The context with witch display lists and textures will be shared. * - * @see GLContext#createGLContext - * @see GLContext#gljInit + * @see gl4java.GLContext#createGLContext + * @see gl4java.GLContext#gljInit */ protected GLContext sharedGLContext; - protected int sharedGLContextNative= 0; // No sharing by default. + protected long sharedGLContextNative= 0; // No sharing by default. /** * Xwindow data AND Windows data for the widget * - * @see GLContext#createGLContext - * @see GLContext#gljInit + * @see gl4java.GLContext#createGLContext + * @see gl4java.GLContext#gljInit */ - protected int pixmapHandle=0; // unique handle for the Pixmap - protected int windowHandle=0; // unique handle for this widget's window - protected int displayHandle=0; // unqiue handle to the display + protected long pixmapHandle=0; // unique handle for the Pixmap + protected long windowHandle=0; // unique handle for this widget's window + protected long displayHandle=0; // unqiue handle to the display + private int createwinw; + private int createwinh; /** * MS-JDirect-Window data for the MS-JVM interface * - * @see GLContext#createGLContext - * @see GLContext#gljInit + * @see gl4java.GLContext#createGLContext + * @see gl4java.GLContext#gljInit */ private int createwinx; private int createwiny; - private int createwinw; - private int createwinh; private boolean threadRunning = false; private boolean destroyWindow = false; protected Container containerWindow = null; @@ -286,24 +285,24 @@ public class GLContext extends Object * * Must be set via createOffScreenCtx * - * @see GLJPanel#paint - * @see GLJPanel#createOffScreenCtx + * @see gl4java.swing.GLJPanel#paint + * @see gl4java.GLContext#createOffScreenCtx */ protected Dimension offScrnSize = null; /** * Windows data AND flag is Window-Handel is read (for X11 also) ! * - * @see GLContext#createGLContext - * @see GLContext#gljInit + * @see gl4java.GLContext#createGLContext + * @see gl4java.GLContext#gljInit */ - int pData = 0; // stores the pointer structure that holds windows info + long pData = 0; // stores the pointer structure that holds windows info /** * Flag to check, if the OpenGL-Context is active ! * - * @see GLCanvas#gljIsEnabled - * @see GLCanvas#gljSetEnabled + * @see gl4java.GLContext#isEnabled + * @see gl4java.GLContext#setEnabled */ protected boolean glEnabled = true; @@ -315,7 +314,7 @@ public class GLContext extends Object * * This is set via the constructor ! * - * @see GLContext#GLContext + * @see gl4java.GLContext#GLContext */ protected boolean offScreenRenderer = false; @@ -325,15 +324,15 @@ public class GLContext extends Object * * This is set via the constructor ! * - * @see GLContext#isDoubleBuffer - * @see GLContext#GLContext + * @see gl4java.GLContext#isDoubleBuffer + * @see gl4java.GLContext#GLContext */ protected boolean doubleBuffer = true; /** * Visual pre-set for stencil-bit number, default: 0 * - * @see GLContext#GLContext + * @see gl4java.GLContext#GLContext */ protected int stencilBits = 0; @@ -347,7 +346,7 @@ public class GLContext extends Object * The output value, after the constructor returns, * it is the summary of all accumulation bits of all components ! * - * @see GLContext#GLContext + * @see gl4java.GLContext#GLContext */ protected int accumSize = 0; @@ -357,8 +356,8 @@ public class GLContext extends Object * * This is set via the constructor ! * - * @see GLContext#isStereoView - * @see GLContext#GLContext + * @see gl4java.GLContext#isStereoView + * @see gl4java.GLContext#GLContext */ protected boolean stereoView = false; @@ -368,8 +367,8 @@ public class GLContext extends Object * * This is set via the constructor ! * - * @see GLContext#isRGBA - * @see GLContext#GLContext + * @see gl4java.GLContext#isRGBA + * @see gl4java.GLContext#GLContext */ protected boolean rgba = true; @@ -383,8 +382,8 @@ public class GLContext extends Object * * This is set via the constructor ! * - * @see GLContext#isOwnWindowCreated - * @see GLContext#GLContext + * @see gl4java.GLContext#isOwnWindowCreated + * @see gl4java.GLContext#GLContext */ protected boolean createOwnWindow = false; @@ -430,6 +429,7 @@ public class GLContext extends Object private static boolean isNetscapeJvm = false; private static boolean isMicrosoftJvm = false; + private static boolean isIBMJvm = false; private static boolean useMSJDirect = false; private static String jvmVendor = null; private static String jvmVersion = null; @@ -437,35 +437,43 @@ public class GLContext extends Object private static int jvmVersionMinor = 1; // min. defaults private static String osName = null; + private static String jniEXTsuff_gl_glu = ""; + private static String jniEXTsuff_glj = ""; + /** * Get the native GL Context ! * - * @see GLContext#glContext + * @see gl4java.GLContext#glContext */ - public final long getNativeGLContext() { return (long)glContext; } + public final long getNativeGLContext() { return glContext; } + + public static final int getNativeGLContextNumber() + { return glContextNumber; } /** * Get the native Window Handle ! * - * @see GLContext#windowHandle + * @see gl4java.GLContext#windowHandle + * + * @deprecated The native window handle is no more accessible + * through this method since JDK >= 1.3 ! */ - public final long getNativeWindoHandle() { return (long)windowHandle; } + public final long getNativeWindoHandle() { return windowHandle; } /** * Get the optional shared GL Context ! * - * @see GLContext#sharedGLContext + * @see gl4java.GLContext#sharedGLContext */ public final GLContext getSharedGLContext() { return sharedGLContext; } /** * Get the native OS-Type ! * - * @see GLContext#osType - * @see GLContext#OsWindoof - * @see GLContext#OsUnknown - * @see GLContext#OsX11 - * @see GLContext#OsMac + * @see gl4java.GLContext#OsWindoof + * @see gl4java.GLContext#OsUnknown + * @see gl4java.GLContext#OsX11 + * @see gl4java.GLContext#OsMac */ public final int getNativeOSType() { return osType; } @@ -474,8 +482,8 @@ public class GLContext extends Object * * After a GLContext is created, this property can be queried ! * - * @see GLContext#doubleBuffer - * @see GLContext#GLContext + * @see gl4java.GLContext#doubleBuffer + * @see gl4java.GLContext#GLContext */ public final boolean isDoubleBuffer() { return doubleBuffer; } @@ -484,8 +492,8 @@ public class GLContext extends Object * * After a GLContext is created, this property can be queried ! * - * @see GLContext#stereoView - * @see GLContext#GLContext + * @see gl4java.GLContext#stereoView + * @see gl4java.GLContext#GLContext */ public final int getStencilBitNumber() { return stencilBits; } @@ -494,7 +502,7 @@ public class GLContext extends Object * * After a GLContext is created, this property can be queried ! * - * @see GLContext#GLContext + * @see gl4java.GLContext#GLContext */ public final int getAccumSize() { return accumSize; } @@ -503,8 +511,8 @@ public class GLContext extends Object * * After a GLContext is created, this property can be queried ! * - * @see GLContext#stereoView - * @see GLContext#GLContext + * @see gl4java.GLContext#stereoView + * @see gl4java.GLContext#GLContext */ public final boolean isStereoView() { return stereoView; } @@ -513,8 +521,8 @@ public class GLContext extends Object * * After a GLContext is created, this property can be queried ! * - * @see GLContext#rgba - * @see GLContext#GLContext + * @see gl4java.GLContext#rgba + * @see gl4java.GLContext#GLContext */ public final boolean isRGBA() { return rgba; } @@ -523,8 +531,8 @@ public class GLContext extends Object * * After a GLContext is created, this property can be queried ! * - * @see GLContext#createOwnWindow - * @see GLContext#GLContext + * @see gl4java.GLContext#createOwnWindow + * @see gl4java.GLContext#GLContext */ public final boolean isOwnWindowCreated() { return createOwnWindow; } @@ -537,6 +545,17 @@ public class GLContext extends Object * Java level, or "libGL4JavaJauGljJNI.so" at the solaris level, * or "GL4JavaJauGljJNI.dll" at the win32 level :-). * + *

+ * + * The user must call loadNativeLibrary ! + * E.g. he can add the default loader like this: + *

+	    static {
+		if(GLContext.loadNativeLibraries(null, null, null)==false)
+		  System.out.println("could not load def. native libs.");
+	    }
+     * 
+ * * @param gljLibName The name of the GLContex native library. * If gljLibName==null, the default library will be used ! * @@ -548,11 +567,11 @@ public class GLContext extends Object * * @return boolean, true if succesfull ! * - * @see GLContext#defGljLib + * @see gl4java.GLContext#defGljLib * - * @see GLContext#defGLFuncLib + * @see gl4java.GLContext#defGLFuncLib * - * @see GLContext#defGLUFuncLib + * @see gl4java.GLContext#defGLUFuncLib */ public static boolean loadNativeLibraries ( String gljLibName, String glLibName, @@ -606,6 +625,7 @@ public class GLContext extends Object isNetscapeJvm = jvmVendor!=null && jvmVendor.indexOf("Netscape")>=0 ; isMicrosoftJvm = jvmVendor!=null && jvmVendor.indexOf("Microsoft")>=0 ; + isIBMJvm = jvmVendor!=null && jvmVendor.indexOf("IBM")>=0 ; // Determine the OS osName = System.getProperty( "os.name" ); @@ -616,21 +636,46 @@ public class GLContext extends Object else /* oops - lets guess unix/x11 :-) */ osType = OsX11; - String jniEXTsuff = ""; - if( jvmVersionMajor>=2 || - ( jvmVersionMajor==1 && jvmVersionMinor>=2 ) + ( jvmVersionMajor==1 && jvmVersionMinor>=4 ) ) { - jniEXTsuff = "12"; + jniEXTsuff_gl_glu = "12"; + jniEXTsuff_glj = "13"; + } + + else + + if( jvmVersionMajor==1 && jvmVersionMinor>=3 + && !isIBMJvm && !isMicrosoftJvm + ) + { + jniEXTsuff_gl_glu = "12"; + jniEXTsuff_glj = "13"; + } + + else + + if( jvmVersionMajor==1 && jvmVersionMinor>=2 ) + { + jniEXTsuff_gl_glu = "12"; + jniEXTsuff_glj = "12"; + } + + else + + { + jniEXTsuff_gl_glu = ""; + jniEXTsuff_glj = ""; } + if(gljLibName==null) - gljLibName = defGljLib+jniEXTsuff; + gljLibName = defGljLib+jniEXTsuff_glj; if(glLibName==null) - glLibName = defGLFuncLib+jniEXTsuff; + glLibName = defGLFuncLib+jniEXTsuff_gl_glu; if(gluLibName==null) - gluLibName = defGLUFuncLib+jniEXTsuff; + gluLibName = defGLUFuncLib+jniEXTsuff_gl_glu; if ( (osType==OsWindoof) && (isMicrosoftJvm) ) { @@ -717,19 +762,6 @@ public class GLContext extends Object return libsLoaded; } - /** - * no no no .. the user has to choose ! - * - * The user must call loadNativeLibrary ! - * - * @see GLContext#loadNativeLibrary - * - * static { - * if(!libLoaded) - * loadNativeLibrares(null, null, null); - * } - */ - /** * Test to load the native library, GLFunc and GLUFunc implementation ! * If succesfull, a Frame will created and the GL-Infos (vendor, ...) @@ -826,10 +858,16 @@ public class GLContext extends Object Frame f = new Frame("GL4Java Info"); f.setSize(10, 10); - f.pack(); + Canvas cvs = new Canvas(); + cvs.setVisible(true); + cvs.setSize(50,50); + f.add("Center", cvs); + f.setSize(60,60); + + // f.pack(); f.setVisible(true); - GLContext glj = new GLContext(f, gl, glu); + GLContext glj = new GLContext(cvs, gl, glu); Frame fInfo = glj.gljShowVersions(); @@ -1382,7 +1420,7 @@ public class GLContext extends Object * @return GLFunc, the implementation's instance if exists * and valid, or null * - * @see GLContext#defGLFuncClass + * @see gl4java.GLContext#defGLFuncClass */ public static final GLFunc createGLFunc(String vendorClass) { @@ -1427,7 +1465,7 @@ public class GLContext extends Object * @return GLUFunc, the implementation's instance if exists * and valid, or null * - * @see GLContext#defGLUFuncClass + * @see gl4java.GLContext#defGLUFuncClass */ public static final GLUFunc createGLUFunc(String vendorClass) { @@ -1505,7 +1543,7 @@ public class GLContext extends Object * * @return void * - * @see GLContext#GLContext + * @see gl4java.GLContext#GLContext */ public final void createGLContext(Graphics g) { @@ -1524,7 +1562,9 @@ public class GLContext extends Object System.out.println("using MSJDirect ..."); win_access = (WinHandleAccess) - Class.forName(access_name + "windows.MSWin32HandleAccess").newInstance(); + Class.forName( + access_name+"windows.MSWin32HandleAccess" + ).newInstance(); /* _comp should be a subclass of Canvas, and its parent class should be of type Panel, Frame or Window. If not, this all falls apart. */ @@ -1549,7 +1589,7 @@ public class GLContext extends Object if(g==null) System.out.println("GL4Java-MSJVM: got empty Graphics"); - pData = (int)win_access.getWinHandle(ob,g); + pData = win_access.getWinHandle(ob,g); if (pData != 0) { @@ -1588,25 +1628,31 @@ public class GLContext extends Object { } } } - } else if(osType==OsWindoof) + } else if(osType==OsWindoof && !useJAWT()) { win_access = (WinHandleAccess) - Class.forName(access_name + "windows.Win32HandleAccess").newInstance(); - pData = (int) win_access.getWinHandle(_compHeavy, g); + Class.forName( + access_name+"windows.Win32HandleAccess" + ).newInstance(); + pData = win_access.getWinHandle(_compHeavy, g); windowHandle = pData; } - else if(osType==OsMac) + else if(osType==OsMac && !useJAWT()) { win_access = (WinHandleAccess) - Class.forName(access_name + "macintosh.MacHandleAccess").newInstance(); - pData = (int) win_access.getWinHandle(_compHeavy, g); + Class.forName( + access_name+"macintosh.MacHandleAccess" + ).newInstance(); + pData = win_access.getWinHandle(_compHeavy, g); windowHandle = pData; } - else /* X11 */ + else if(!useJAWT()) { win_access = (WinHandleAccess) - Class.forName(access_name + "motif.X11HandleAccess").newInstance(); - pData = (int) win_access.getWinHandle(_compHeavy, g); + Class.forName( + access_name+"motif.X11HandleAccess" + ).newInstance(); + pData = win_access.getWinHandle(_compHeavy, g); windowHandle = pData; } } @@ -1652,7 +1698,7 @@ public class GLContext extends Object * @exception GL4Java.GL4JavaInitException * this class throws an exception * if the native call to create a OpenGL context failed. - * @see GLContext#createGLContext + * @see gl4java.GLContext#createGLContext * @see gl4java.awt.GLCanvas#paint * @see gl4java.awt.GLCanvas#init */ @@ -1661,7 +1707,7 @@ public class GLContext extends Object { if( libsLoaded==false ) return ; - if(pData==0 && !offScreenRenderer) + if(pData==0 && !offScreenRenderer && !useJAWT()) { System.out.println("could not open a GL widget -- Win CONTEXT"); throw new GL4JavaInitException (); @@ -1670,7 +1716,11 @@ public class GLContext extends Object if(gljClassDebug) System.out.println(">>> gljInit"); - if( openOpenGLNative() == false ) + boolean ok; + + ok = openOpenGLNative(_comp); + + if( ! ok ) { if ( useMSJDirect ) { @@ -1691,6 +1741,7 @@ public class GLContext extends Object throw new GL4JavaInitException (); } else { isInitialized = true; + glContextNumber++; } } @@ -1755,7 +1806,7 @@ public class GLContext extends Object *

* * @return boolean - * @see GLContext#gljInit + * @see gl4java.GLContext#gljInit * @see gl4java.awt.GLCanvas#cvsIsInit */ public final boolean gljIsInit() @@ -1803,13 +1854,30 @@ public class GLContext extends Object } private final native void gljResizeNative( boolean isOwnWindow, - int disp, int thisWin, + long disp, long thisWin, int width, int height ); + /** + * native C function of GLJ Library, + * which query if it uses the JDK 1.3 JAWT interface + * to fetch the native window handle + */ + protected final native boolean useJAWT(); + + /** + * native C function of GLJ Library, + * which query if the JAWT Surface has changed ! + * + * Use this after gljMakeCurrent -> jawt_lock ! + * + * If true, we need a new GLContext ! + */ + protected final native boolean hasJAWTSurfaceChanged(long thisWin); + /** * native C function to open the OpenGLwidget */ - protected final native boolean openOpenGLNative(); + protected final native boolean openOpenGLNative(Component canvas); /** * native C function to check the gl types. @@ -1856,24 +1924,153 @@ public class GLContext extends Object return true; } + private Thread ctxThread = null; + private Thread nextThread = null; + /** * * gljMakeCurrent checks whether GL4Java is initializes * AND makes the GL-Context current for this thread. * - * It's more save to use ´gljMakeCurrent´, instead of - * ´gljMakeCurrentNative´, because we do check if GL is initalised ! + *

+ * + * You MUST encapsulate your OpenGL call's within: + *

+    	- gljMakeCurrent()
+		YOUR OpenGL commands here !
+    	- gljFree()
+    * 
* * @return boolean + * + * @see gl4java.GLContext#gljSwap + * @see gl4java.awt.GLCanvas#display + * @see gl4java.awt.GLCanvas#sDisplay */ - public final boolean gljMakeCurrent() + public synchronized final boolean gljMakeCurrent() { if ( ! isInitialized || !glEnabled ) return false; - return gljMakeCurrentNative( displayHandle, - windowHandle, - glContext); + Thread thisThread = Thread.currentThread(); + boolean dbgPrinted = false; + + /** + * force a thread switch to improve responsiveness ! + * + * if an earmarked thread exist (nextThread) + * we have to wait .. + */ + while (nextThread!=null && nextThread!=thisThread) + { + if(gljThreadDebug && !dbgPrinted) + { + System.out.println("wait-switch: "+thisThread); + System.out.println("\tctxThread="+ctxThread+", next="+nextThread); + dbgPrinted=true; + } + + /** + * Force freeing this threads context .. to avoid a deadlock .. + * This makes sense, because it is possible, + * that the same thread enters this point twice, + * before calling gljFree ! + */ + if (ctxThread!=null && ctxThread==thisThread) + gljFree(); + + try { + // wait till earmarked nextThread has its chance .. + wait(); + } catch (InterruptedException e) { } + } + dbgPrinted=false; + + /** + * put all req. threads to the wait-state, + * if another thread owns the GLXContext ! + */ + while (ctxThread!=null && ctxThread!=thisThread) + { + /** + * remember this thread as earmarked, + * to be sure being the next one ... + */ + nextThread = thisThread; + + if(gljThreadDebug && !dbgPrinted) + { + System.out.println("wait-earmarked: "+thisThread); + System.out.println("\tctxThread="+ctxThread+", next="+nextThread); + dbgPrinted=true; + } + + try { + // wait for gljFree to release the GLXContext + wait(); + } catch (InterruptedException e) { } + } + + ctxThread = thisThread ; // blocking asap .. + + if(gljThreadDebug) + { + if(nextThread==thisThread) + { + System.out.println(thisThread+" "); + System.out.println("\tctxThread="+ctxThread+", next:=NULL"); + } else { + System.out.println(thisThread); + System.out.println("\tctxThread="+ctxThread+", next="+nextThread); + } + } + + /** + * if next thread gotten the context, it is no more earmarked .. + */ + if(nextThread==thisThread) + nextThread = null; + + boolean result = gljMakeCurrentNative( _comp, displayHandle, + windowHandle, glContext); + + /** + * If glXMakeCurrent failed, nobody holds this GLXContext .. + */ + if(!result) + { + ctxThread=null; + if(hasJAWTSurfaceChanged(windowHandle)) + { + /** + * This can only happen while using JAWT .. + */ + System.out.println("GL4Java: JAWT Surface-Change !!!"); + System.out.println("\t destroying GLContext ...!!!"); + gljDestroy(); + + System.out.println("GL4Java: JAWT Surface-Change !!!"); + System.out.println("\t creating GLContext ...!!!"); + + /* try to establish a context to OpenGL */ + try + { + System.out.println("GL4Java: JAWT Surface-Change !!!"); + gljInit(); + System.out.println("GL4Java: JAWT Surface-Change finished !!!"); + } + catch( GL4JavaInitException e ) + { + System.out.println( "\tcan't create a GL context\n"); + System.out.println("GL4Java: JAWT Surface Change FAILED!!!"); + } + System.out.println("\t GLContext Recreated ...!!!"); + } + } + + notifyAll(); // notify gljFree after action is done .. + + return result; } @@ -1891,20 +2088,16 @@ public class GLContext extends Object * * @deprecated The argument freeContextFirst is obsolete ! */ - public final boolean gljMakeCurrent(boolean freeContextFirst) + public synchronized final boolean gljMakeCurrent(boolean freeContextFirst) { - if ( ! isInitialized || !glEnabled ) - return false; - - return gljMakeCurrentNative( displayHandle, - windowHandle, - glContext); + return gljMakeCurrent(); } private static final native boolean gljMakeCurrentNative( - int disp, - int thisWin, - int glContext); + Component canvas, + long disp, + long thisWin, + long glContext); /** * @@ -1917,21 +2110,24 @@ public class GLContext extends Object /** * - * gljDestroy free´s AND destroy´s the GL Context + * gljDestroy destroy´s the GL Context * * This function should be called when removing * a GLContext !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * + * Call gljFree befor this method, to be sure .. + * * @return void * - * @see GLContext#gljMakeCurrent - * @see GLContext#gljSwap + * @see gl4java.GLContext#gljMakeCurrent + * @see gl4java.GLContext#gljFree + * @see gl4java.GLContext#gljSwap */ - public final synchronized boolean gljDestroy() + public synchronized final boolean gljDestroy() { boolean result = true; - if (!gljDestroyNative()) + if (!gljDestroyNative(_comp)) result = false; windowHandle = 0; @@ -1948,37 +2144,77 @@ public class GLContext extends Object } pData = 0; + isInitialized = false; + glContextNumber--; return result; } - private final native boolean gljDestroyNative(); + private final native boolean gljDestroyNative(Component canvas); /** * * gljFree free´s the GL Context * - * This could be called after at last in your display function, - * if you have GC problems .... + * This MUST be called at last in your display function ! * * @return void * - * @see GLContext#gljMakeCurrent - * @see GLContext#gljSwap + * @see gl4java.GLContext#gljMakeCurrent + * @see gl4java.GLContext#gljSwap + * @see gl4java.awt.GLCanvas#display * @see gl4java.awt.GLCanvas#sDisplay */ - public final boolean gljFree() + public synchronized final boolean gljFree() { if ( ! isInitialized ) return false; - return gljFreeNative ( displayHandle, - windowHandle, - glContext); + Thread thisThread = Thread.currentThread(); + boolean dbgPrinted = false; + + /** + * I do skip a lock for the gljFree semantics, + * because: + * - to minimize a deadlock + * - believing that gljFree is semantically the last call ;-) + * - see above -> redundant + while (ctxThread!=null && ctxThread!=thisThread) + { + if(gljThreadDebug && !dbgPrinted) + { + System.out.println("* wait: "+thisThread); + System.out.println("\tctxThread="+ctxThread+", next="+nextThread); + dbgPrinted=true; + } + + try { + // wait for gljMakeCurrent to lock the GLXContext + wait(); + } catch (InterruptedException e) { } + } + + if(gljThreadDebug) + { + System.out.println("*: "+thisThread); + System.out.println("\tctxThread="+ctxThread+", next="+nextThread); + } + */ + + + boolean result = + gljFreeNative ( _comp, displayHandle, + windowHandle, + glContext); + ctxThread = null ; + notifyAll(); + + return result; } - private static final native boolean gljFreeNative( int disp, - int thisWin, - int glContext ); + private static final native boolean gljFreeNative( Component canvas, + long disp, + long thisWin, + long glContext ); /** * swap method are for double buffering @@ -1993,9 +2229,9 @@ public class GLContext extends Object doubleBuffer); } - private static final native boolean gljSwapNative( int disp, - int thisWin, - int glContext, + private static final native boolean gljSwapNative( long disp, + long thisWin, + long glContext, boolean doubleBuffer ); /** @@ -2007,8 +2243,7 @@ public class GLContext extends Object * * @return boolean * - * @see GLContext#gljIsEnabled - * @see GLContext#gljMakeCurrent + * @see gl4java.GLContext#gljMakeCurrent */ public void setEnabled(boolean b) { @@ -2022,8 +2257,8 @@ public class GLContext extends Object * * @return boolean * - * @see GLContext#setEnabled - * @see GLContext#gljMakeCurrent + * @see gl4java.GLContext#setEnabled + * @see gl4java.GLContext#gljMakeCurrent */ public boolean isEnabled() { diff --git a/gl4java/GLEnum.java b/gl4java/GLEnum.java index ee53d8b..a096e56 100644 --- a/gl4java/GLEnum.java +++ b/gl4java/GLEnum.java @@ -25,7 +25,7 @@ public interface GLEnum public static final boolean GL_TRUE = true; /** - * C2J Parser Version 1.4 Beta + * C2J Parser Version 1.5 Beta * Jausoft - Sven Goethel Software Development * Reading from file: gl-enum-auto.orig.h . . . * Destination-Class: gl4java_GLEnum ! @@ -1340,7 +1340,7 @@ public interface GLEnum public static final int GL_ZERO = 0x0; public static final int GL_ZOOM_X = 0x0D16; public static final int GL_ZOOM_Y = 0x0D17; -/* C2J Parser Version 1.4 Beta: Java program parsed successfully. */ +/* C2J Parser Version 1.5 Beta: Java program parsed successfully. */ } diff --git a/gl4java/GLFunc.java b/gl4java/GLFunc.java index 3879569..896f7ca 100644 --- a/gl4java/GLFunc.java +++ b/gl4java/GLFunc.java @@ -31,7 +31,7 @@ public String getClassVersion ( ) ; public static final String[] GL_PROC_NAMES = { /** - * C2J Parser Version 1.4 Beta + * C2J Parser Version 1.5 Beta * Jausoft - Sven Goethel Software Development * Reading from file: gl-proto-auto.orig.h . . . * Destination-Class: gl4java_GLFuncJauJNI ! @@ -474,11 +474,11 @@ public static final String[] GL_PROC_NAMES = { "glMultiTexCoord4ivARB", "glMultiTexCoord4sARB", "glMultiTexCoord4svARB", -/* C2J Parser Version 1.4 Beta: Java program parsed successfully. */ +/* C2J Parser Version 1.5 Beta: Java program parsed successfully. */ null }; /** - * C2J Parser Version 1.4 Beta + * C2J Parser Version 1.5 Beta * Jausoft - Sven Goethel Software Development * Reading from file: gl-proto-auto.orig.h . . . * Destination-Class: gl4java_GLFuncJauJNI ! @@ -7431,7 +7431,7 @@ public static final String[] GL_PROC_NAMES = { short[] v ) ; -/* C2J Parser Version 1.4 Beta: Java program parsed successfully. */ +/* C2J Parser Version 1.5 Beta: Java program parsed successfully. */ } diff --git a/gl4java/GLFuncJauJNI.java b/gl4java/GLFuncJauJNI.java index 7887860..b8ee949 100644 --- a/gl4java/GLFuncJauJNI.java +++ b/gl4java/GLFuncJauJNI.java @@ -37,7 +37,7 @@ public final String getClassVersion ( ) /** - * C2J Parser Version 1.4 Beta + * C2J Parser Version 1.5 Beta * Jausoft - Sven Goethel Software Development * Reading from file: gl-proto-auto.orig.h . . . * Destination-Class: gl4java_GLFuncJauJNI ! @@ -6990,7 +6990,7 @@ public final String getClassVersion ( ) short[] v ) ; -/* C2J Parser Version 1.4 Beta: Java program parsed successfully. */ +/* C2J Parser Version 1.5 Beta: Java program parsed successfully. */ } diff --git a/gl4java/GLFuncJauJNInf.java b/gl4java/GLFuncJauJNInf.java index 5187e83..68a5b8d 100644 --- a/gl4java/GLFuncJauJNInf.java +++ b/gl4java/GLFuncJauJNInf.java @@ -37,7 +37,7 @@ public String getClassVersion ( ) /** - * C2J Parser Version 1.4 Beta + * C2J Parser Version 1.5 Beta * Jausoft - Sven Goethel Software Development * Reading from file: gl-proto-auto.orig.h . . . * Destination-Class: gl4java_GLFuncJauJNInf ! @@ -6990,7 +6990,7 @@ public String getClassVersion ( ) short[] v ) ; -/* C2J Parser Version 1.4 Beta: Java program parsed successfully. */ +/* C2J Parser Version 1.5 Beta: Java program parsed successfully. */ } diff --git a/gl4java/GLUEnum.java b/gl4java/GLUEnum.java index 41982b5..b34eb08 100644 --- a/gl4java/GLUEnum.java +++ b/gl4java/GLUEnum.java @@ -22,7 +22,7 @@ public interface GLUEnum { /** - * C2J Parser Version 1.4 Beta + * C2J Parser Version 1.5 Beta * Jausoft - Sven Goethel Software Development * Reading from file: glu-enum-auto.orig.h . . . * Destination-Class: gl4java_GLUEnum ! @@ -134,7 +134,7 @@ public interface GLUEnum public static final int GLU_EDGE_FLAG = GLU_TESS_EDGE_FLAG; public static final int GLU_END = GLU_TESS_END; public static final int GLU_ERROR = GLU_TESS_ERROR; -/* C2J Parser Version 1.4 Beta: Java program parsed successfully. */ +/* C2J Parser Version 1.5 Beta: Java program parsed successfully. */ } diff --git a/gl4java/GLUFunc.java b/gl4java/GLUFunc.java index a36448d..afee2cb 100644 --- a/gl4java/GLUFunc.java +++ b/gl4java/GLUFunc.java @@ -31,15 +31,19 @@ public String getNativeVersion ( ) ; public String getClassVendor ( ) ; public String getClassVersion ( ) ; +public long gluNewQuadric( ); +public long gluNewNurbsRenderer( ); +public long gluNewTess( ); + public void gluQuadricCallback( - int qobj, int which, + long qobj, int which, Object methodClassInstance, String methodName, String signature ); public void gluNurbsCallback( - int nobj, int which, + long nobj, int which, Object methodClassInstance, String methodName, String signature @@ -47,7 +51,7 @@ public void gluNurbsCallback( public void gluTessCallback( - int tobj, int which, + long tobj, int which, Object methodClassInstance, String methodName, String signature, @@ -58,14 +62,14 @@ public void gluTessCallback( int voidArrayLen5 ); -public void gluDeleteQuadric( int qobj ); +public void gluDeleteQuadric( long qobj ); -public void gluDeleteNurbsRenderer( int nobj ); +public void gluDeleteNurbsRenderer( long nobj ); -public void gluDeleteTess( int tobj ); +public void gluDeleteTess( long tobj ); /** - * C2J Parser Version 1.4 Beta + * C2J Parser Version 1.5 Beta * Jausoft - Sven Goethel Software Development * Reading from file: glu-proto-auto.orig.h . . . * Destination-Class: gl4java_GLUFuncJauJNI ! @@ -316,15 +320,6 @@ public void gluDeleteTess( int tobj ); long[] data ) ; -/** - * Original Function-Prototype : - *
 
-   extern GLUquadricObj * gluNewQuadric ( void ) ;
- * 
- */ - public int gluNewQuadric ( - ) ; - /** * Original Function-Prototype : *
 
@@ -332,7 +327,7 @@ public void  gluDeleteTess( int tobj );
  * 
*/ public void gluQuadricDrawStyle ( - int quadObject, + long quadObject, int drawStyle ) ; @@ -343,7 +338,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluQuadricOrientation ( - int quadObject, + long quadObject, int orientation ) ; @@ -354,7 +349,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluQuadricNormals ( - int quadObject, + long quadObject, int normals ) ; @@ -365,7 +360,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluQuadricTexture ( - int quadObject, + long quadObject, boolean textureCoords ) ; @@ -376,7 +371,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluCylinder ( - int qobj, + long qobj, double baseRadius, double topRadius, double height, @@ -391,7 +386,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluSphere ( - int qobj, + long qobj, double radius, int slices, int stacks @@ -404,7 +399,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluDisk ( - int qobj, + long qobj, double innerRadius, double outerRadius, int slices, @@ -418,7 +413,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluPartialDisk ( - int qobj, + long qobj, double innerRadius, double outerRadius, int slices, @@ -427,15 +422,6 @@ public void gluDeleteTess( int tobj ); double sweepAngle ) ; -/** - * Original Function-Prototype : - *
 
-   extern GLUnurbsObj * gluNewNurbsRenderer ( void ) ;
- * 
- */ - public int gluNewNurbsRenderer ( - ) ; - /** * Original Function-Prototype : *
 
@@ -443,7 +429,7 @@ public void  gluDeleteTess( int tobj );
  * 
*/ public void gluLoadSamplingMatrices ( - int nobj, + long nobj, float[] modelMatrix, float[] projMatrix, int[] viewport @@ -456,7 +442,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluNurbsProperty ( - int nobj, + long nobj, int property, float value ) ; @@ -468,7 +454,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluGetNurbsProperty ( - int nobj, + long nobj, int property, float[] value ) ; @@ -480,7 +466,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluBeginCurve ( - int nobj + long nobj ) ; /** @@ -490,7 +476,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluEndCurve ( - int nobj + long nobj ) ; /** @@ -500,7 +486,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluNurbsCurve ( - int nobj, + long nobj, int nknots, float[] knot, int stride, @@ -516,7 +502,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluBeginSurface ( - int nobj + long nobj ) ; /** @@ -526,7 +512,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluEndSurface ( - int nobj + long nobj ) ; /** @@ -536,7 +522,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluNurbsSurface ( - int nobj, + long nobj, int sknot_count, float[] sknot, int tknot_count, @@ -556,7 +542,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluBeginTrim ( - int nobj + long nobj ) ; /** @@ -566,7 +552,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluEndTrim ( - int nobj + long nobj ) ; /** @@ -576,22 +562,13 @@ public void gluDeleteTess( int tobj ); * */ public void gluPwlCurve ( - int nobj, + long nobj, int count, float[] array, int stride, int type ) ; -/** - * Original Function-Prototype : - *
 
-   extern GLUtesselator * gluNewTess ( void ) ;
- * 
- */ - public int gluNewTess ( - ) ; - /** * Original Function-Prototype : *
 
@@ -599,31 +576,31 @@ public void  gluDeleteTess( int tobj );
  * 
*/ public void gluTessBeginPolygon ( - int tobj, + long tobj, byte[] polygon_data ) ; public void gluTessBeginPolygon ( - int tobj, + long tobj, short[] polygon_data ) ; public void gluTessBeginPolygon ( - int tobj, + long tobj, int[] polygon_data ) ; public void gluTessBeginPolygon ( - int tobj, + long tobj, float[] polygon_data ) ; public void gluTessBeginPolygon ( - int tobj, + long tobj, double[] polygon_data ) ; public void gluTessBeginPolygon ( - int tobj, + long tobj, boolean[] polygon_data ) ; public void gluTessBeginPolygon ( - int tobj, + long tobj, long[] polygon_data ) ; @@ -634,7 +611,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluTessBeginContour ( - int tobj + long tobj ) ; /** @@ -644,37 +621,37 @@ public void gluDeleteTess( int tobj ); * */ public void gluTessVertex ( - int tobj, + long tobj, double[] coords, byte[] vertex_data ) ; public void gluTessVertex ( - int tobj, + long tobj, double[] coords, short[] vertex_data ) ; public void gluTessVertex ( - int tobj, + long tobj, double[] coords, int[] vertex_data ) ; public void gluTessVertex ( - int tobj, + long tobj, double[] coords, float[] vertex_data ) ; public void gluTessVertex ( - int tobj, + long tobj, double[] coords, double[] vertex_data ) ; public void gluTessVertex ( - int tobj, + long tobj, double[] coords, boolean[] vertex_data ) ; public void gluTessVertex ( - int tobj, + long tobj, double[] coords, long[] vertex_data ) ; @@ -686,7 +663,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluTessEndContour ( - int tobj + long tobj ) ; /** @@ -696,7 +673,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluTessEndPolygon ( - int tobj + long tobj ) ; /** @@ -706,7 +683,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluTessProperty ( - int tobj, + long tobj, int which, double value ) ; @@ -718,7 +695,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluTessNormal ( - int tobj, + long tobj, double x, double y, double z @@ -731,7 +708,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluGetTessProperty ( - int tobj, + long tobj, int which, double[] value ) ; @@ -743,7 +720,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluBeginPolygon ( - int tobj + long tobj ) ; /** @@ -753,7 +730,7 @@ public void gluDeleteTess( int tobj ); * */ public void gluNextContour ( - int tobj, + long tobj, int type ) ; @@ -764,10 +741,10 @@ public void gluDeleteTess( int tobj ); * */ public void gluEndPolygon ( - int tobj + long tobj ) ; -/* C2J Parser Version 1.4 Beta: Java program parsed successfully. */ +/* C2J Parser Version 1.5 Beta: Java program parsed successfully. */ } diff --git a/gl4java/GLUFuncJauJNI.java b/gl4java/GLUFuncJauJNI.java index 439a758..5ba2f08 100644 --- a/gl4java/GLUFuncJauJNI.java +++ b/gl4java/GLUFuncJauJNI.java @@ -50,7 +50,7 @@ public final String getClassVersion ( ) * @see GLUFunc#gluNewQuadric */ public final native void gluQuadricCallback( - int qobj, int which, + long qobj, int which, Object methodClassInstance, String methodName, String signature @@ -71,7 +71,7 @@ public final native void gluQuadricCallback( * @see GLUFunc#gluNewNurbsRenderer */ public final native void gluNurbsCallback( - int nobj, int which, + long nobj, int which, Object methodClassInstance, String methodName, String signature @@ -103,7 +103,7 @@ public final native void gluNurbsCallback( * @see GLUFunc#gluNewTess */ public final native void gluTessCallback( - int tobj, int which, + long tobj, int which, Object methodClassInstance, String methodName, String signature, @@ -120,7 +120,7 @@ public final native void gluTessCallback( * @param qobj the quadratic id, for which all callback-methods * should be de-registered */ -public final native void gluDeleteQuadric( int qobj ); +public final native void gluDeleteQuadric( long qobj ); /** * The Callback de-registry function. @@ -128,7 +128,7 @@ public final native void gluDeleteQuadric( int qobj ); * @param nobj the nurbs id, for which all callback-methods * should be de-registered */ -public final native void gluDeleteNurbsRenderer( int nobj ); +public final native void gluDeleteNurbsRenderer( long nobj ); /** * The Callback de-registry function. @@ -136,10 +136,14 @@ public final native void gluDeleteNurbsRenderer( int nobj ); * @param tobj the tesselation id, for which all callback-methods * should be de-registered */ -public final native void gluDeleteTess( int tobj ); +public final native void gluDeleteTess( long tobj ); + +public final native long gluNewQuadric( ); +public final native long gluNewNurbsRenderer( ); +public final native long gluNewTess( ); /** - * C2J Parser Version 1.4 Beta + * C2J Parser Version 1.5 Beta * Jausoft - Sven Goethel Software Development * Reading from file: glu-proto-auto.orig.h . . . * Destination-Class: gl4java_GLUFuncJauJNI ! @@ -390,15 +394,6 @@ public final native void gluDeleteTess( int tobj ); long[] data ) ; -/** - * Original Function-Prototype : - *
 
-   extern GLUquadricObj * gluNewQuadric ( void ) ;
- * 
- */ - public final native int gluNewQuadric ( - ) ; - /** * Original Function-Prototype : *
 
@@ -406,7 +401,7 @@ public final native void  gluDeleteTess( int tobj );
  * 
*/ public final native void gluQuadricDrawStyle ( - int quadObject, + long quadObject, int drawStyle ) ; @@ -417,7 +412,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluQuadricOrientation ( - int quadObject, + long quadObject, int orientation ) ; @@ -428,7 +423,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluQuadricNormals ( - int quadObject, + long quadObject, int normals ) ; @@ -439,7 +434,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluQuadricTexture ( - int quadObject, + long quadObject, boolean textureCoords ) ; @@ -450,7 +445,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluCylinder ( - int qobj, + long qobj, double baseRadius, double topRadius, double height, @@ -465,7 +460,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluSphere ( - int qobj, + long qobj, double radius, int slices, int stacks @@ -478,7 +473,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluDisk ( - int qobj, + long qobj, double innerRadius, double outerRadius, int slices, @@ -492,7 +487,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluPartialDisk ( - int qobj, + long qobj, double innerRadius, double outerRadius, int slices, @@ -501,15 +496,6 @@ public final native void gluDeleteTess( int tobj ); double sweepAngle ) ; -/** - * Original Function-Prototype : - *
 
-   extern GLUnurbsObj * gluNewNurbsRenderer ( void ) ;
- * 
- */ - public final native int gluNewNurbsRenderer ( - ) ; - /** * Original Function-Prototype : *
 
@@ -517,7 +503,7 @@ public final native void  gluDeleteTess( int tobj );
  * 
*/ public final native void gluLoadSamplingMatrices ( - int nobj, + long nobj, float[] modelMatrix, float[] projMatrix, int[] viewport @@ -530,7 +516,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluNurbsProperty ( - int nobj, + long nobj, int property, float value ) ; @@ -542,7 +528,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluGetNurbsProperty ( - int nobj, + long nobj, int property, float[] value ) ; @@ -554,7 +540,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluBeginCurve ( - int nobj + long nobj ) ; /** @@ -564,7 +550,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluEndCurve ( - int nobj + long nobj ) ; /** @@ -574,7 +560,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluNurbsCurve ( - int nobj, + long nobj, int nknots, float[] knot, int stride, @@ -590,7 +576,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluBeginSurface ( - int nobj + long nobj ) ; /** @@ -600,7 +586,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluEndSurface ( - int nobj + long nobj ) ; /** @@ -610,7 +596,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluNurbsSurface ( - int nobj, + long nobj, int sknot_count, float[] sknot, int tknot_count, @@ -630,7 +616,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluBeginTrim ( - int nobj + long nobj ) ; /** @@ -640,7 +626,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluEndTrim ( - int nobj + long nobj ) ; /** @@ -650,22 +636,13 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluPwlCurve ( - int nobj, + long nobj, int count, float[] array, int stride, int type ) ; -/** - * Original Function-Prototype : - *
 
-   extern GLUtesselator * gluNewTess ( void ) ;
- * 
- */ - public final native int gluNewTess ( - ) ; - /** * Original Function-Prototype : *
 
@@ -673,31 +650,31 @@ public final native void  gluDeleteTess( int tobj );
  * 
*/ public final native void gluTessBeginPolygon ( - int tobj, + long tobj, byte[] polygon_data ) ; public final native void gluTessBeginPolygon ( - int tobj, + long tobj, short[] polygon_data ) ; public final native void gluTessBeginPolygon ( - int tobj, + long tobj, int[] polygon_data ) ; public final native void gluTessBeginPolygon ( - int tobj, + long tobj, float[] polygon_data ) ; public final native void gluTessBeginPolygon ( - int tobj, + long tobj, double[] polygon_data ) ; public final native void gluTessBeginPolygon ( - int tobj, + long tobj, boolean[] polygon_data ) ; public final native void gluTessBeginPolygon ( - int tobj, + long tobj, long[] polygon_data ) ; @@ -708,7 +685,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluTessBeginContour ( - int tobj + long tobj ) ; /** @@ -718,37 +695,37 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluTessVertex ( - int tobj, + long tobj, double[] coords, byte[] vertex_data ) ; public final native void gluTessVertex ( - int tobj, + long tobj, double[] coords, short[] vertex_data ) ; public final native void gluTessVertex ( - int tobj, + long tobj, double[] coords, int[] vertex_data ) ; public final native void gluTessVertex ( - int tobj, + long tobj, double[] coords, float[] vertex_data ) ; public final native void gluTessVertex ( - int tobj, + long tobj, double[] coords, double[] vertex_data ) ; public final native void gluTessVertex ( - int tobj, + long tobj, double[] coords, boolean[] vertex_data ) ; public final native void gluTessVertex ( - int tobj, + long tobj, double[] coords, long[] vertex_data ) ; @@ -760,7 +737,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluTessEndContour ( - int tobj + long tobj ) ; /** @@ -770,7 +747,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluTessEndPolygon ( - int tobj + long tobj ) ; /** @@ -780,7 +757,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluTessProperty ( - int tobj, + long tobj, int which, double value ) ; @@ -792,7 +769,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluTessNormal ( - int tobj, + long tobj, double x, double y, double z @@ -805,7 +782,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluGetTessProperty ( - int tobj, + long tobj, int which, double[] value ) ; @@ -817,7 +794,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluBeginPolygon ( - int tobj + long tobj ) ; /** @@ -827,7 +804,7 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluNextContour ( - int tobj, + long tobj, int type ) ; @@ -838,10 +815,10 @@ public final native void gluDeleteTess( int tobj ); * */ public final native void gluEndPolygon ( - int tobj + long tobj ) ; -/* C2J Parser Version 1.4 Beta: Java program parsed successfully. */ +/* C2J Parser Version 1.5 Beta: Java program parsed successfully. */ } diff --git a/gl4java/GLUFuncJauJNInf.java b/gl4java/GLUFuncJauJNInf.java index b1ea21a..f509fe4 100644 --- a/gl4java/GLUFuncJauJNInf.java +++ b/gl4java/GLUFuncJauJNInf.java @@ -50,7 +50,7 @@ public String getClassVersion ( ) * @see GLUFunc#gluNewQuadric */ public native void gluQuadricCallback( - int qobj, int which, + long qobj, int which, Object methodClassInstance, String methodName, String signature @@ -71,7 +71,7 @@ public native void gluQuadricCallback( * @see GLUFunc#gluNewNurbsRenderer */ public native void gluNurbsCallback( - int nobj, int which, + long nobj, int which, Object methodClassInstance, String methodName, String signature @@ -103,7 +103,7 @@ public native void gluNurbsCallback( * @see GLUFunc#gluNewTess */ public native void gluTessCallback( - int tobj, int which, + long tobj, int which, Object methodClassInstance, String methodName, String signature, @@ -120,7 +120,7 @@ public native void gluTessCallback( * @param qobj the quadratic id, for which all callback-methods * should be de-registered */ -public native void gluDeleteQuadric( int qobj ); +public native void gluDeleteQuadric( long qobj ); /** * The Callback de-registry function. @@ -128,7 +128,7 @@ public native void gluDeleteQuadric( int qobj ); * @param nobj the nurbs id, for which all callback-methods * should be de-registered */ -public native void gluDeleteNurbsRenderer( int nobj ); +public native void gluDeleteNurbsRenderer( long nobj ); /** * The Callback de-registry function. @@ -136,10 +136,14 @@ public native void gluDeleteNurbsRenderer( int nobj ); * @param tobj the tesselation id, for which all callback-methods * should be de-registered */ -public native void gluDeleteTess( int tobj ); +public native void gluDeleteTess( long tobj ); + +public native long gluNewQuadric( ); +public native long gluNewNurbsRenderer( ); +public native long gluNewTess( ); /** - * C2J Parser Version 1.4 Beta + * C2J Parser Version 1.5 Beta * Jausoft - Sven Goethel Software Development * Reading from file: glu-proto-auto.orig.h . . . * Destination-Class: gl4java_GLUFuncJauJNInf ! @@ -390,15 +394,6 @@ public native void gluDeleteTess( int tobj ); long[] data ) ; -/** - * Original Function-Prototype : - *
 
-   extern GLUquadricObj * gluNewQuadric ( void ) ;
- * 
- */ - public native int gluNewQuadric ( - ) ; - /** * Original Function-Prototype : *
 
@@ -406,7 +401,7 @@ public native void  gluDeleteTess( int tobj );
  * 
*/ public native void gluQuadricDrawStyle ( - int quadObject, + long quadObject, int drawStyle ) ; @@ -417,7 +412,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluQuadricOrientation ( - int quadObject, + long quadObject, int orientation ) ; @@ -428,7 +423,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluQuadricNormals ( - int quadObject, + long quadObject, int normals ) ; @@ -439,7 +434,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluQuadricTexture ( - int quadObject, + long quadObject, boolean textureCoords ) ; @@ -450,7 +445,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluCylinder ( - int qobj, + long qobj, double baseRadius, double topRadius, double height, @@ -465,7 +460,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluSphere ( - int qobj, + long qobj, double radius, int slices, int stacks @@ -478,7 +473,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluDisk ( - int qobj, + long qobj, double innerRadius, double outerRadius, int slices, @@ -492,7 +487,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluPartialDisk ( - int qobj, + long qobj, double innerRadius, double outerRadius, int slices, @@ -501,15 +496,6 @@ public native void gluDeleteTess( int tobj ); double sweepAngle ) ; -/** - * Original Function-Prototype : - *
 
-   extern GLUnurbsObj * gluNewNurbsRenderer ( void ) ;
- * 
- */ - public native int gluNewNurbsRenderer ( - ) ; - /** * Original Function-Prototype : *
 
@@ -517,7 +503,7 @@ public native void  gluDeleteTess( int tobj );
  * 
*/ public native void gluLoadSamplingMatrices ( - int nobj, + long nobj, float[] modelMatrix, float[] projMatrix, int[] viewport @@ -530,7 +516,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluNurbsProperty ( - int nobj, + long nobj, int property, float value ) ; @@ -542,7 +528,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluGetNurbsProperty ( - int nobj, + long nobj, int property, float[] value ) ; @@ -554,7 +540,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluBeginCurve ( - int nobj + long nobj ) ; /** @@ -564,7 +550,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluEndCurve ( - int nobj + long nobj ) ; /** @@ -574,7 +560,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluNurbsCurve ( - int nobj, + long nobj, int nknots, float[] knot, int stride, @@ -590,7 +576,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluBeginSurface ( - int nobj + long nobj ) ; /** @@ -600,7 +586,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluEndSurface ( - int nobj + long nobj ) ; /** @@ -610,7 +596,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluNurbsSurface ( - int nobj, + long nobj, int sknot_count, float[] sknot, int tknot_count, @@ -630,7 +616,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluBeginTrim ( - int nobj + long nobj ) ; /** @@ -640,7 +626,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluEndTrim ( - int nobj + long nobj ) ; /** @@ -650,22 +636,13 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluPwlCurve ( - int nobj, + long nobj, int count, float[] array, int stride, int type ) ; -/** - * Original Function-Prototype : - *
 
-   extern GLUtesselator * gluNewTess ( void ) ;
- * 
- */ - public native int gluNewTess ( - ) ; - /** * Original Function-Prototype : *
 
@@ -673,31 +650,31 @@ public native void  gluDeleteTess( int tobj );
  * 
*/ public native void gluTessBeginPolygon ( - int tobj, + long tobj, byte[] polygon_data ) ; public native void gluTessBeginPolygon ( - int tobj, + long tobj, short[] polygon_data ) ; public native void gluTessBeginPolygon ( - int tobj, + long tobj, int[] polygon_data ) ; public native void gluTessBeginPolygon ( - int tobj, + long tobj, float[] polygon_data ) ; public native void gluTessBeginPolygon ( - int tobj, + long tobj, double[] polygon_data ) ; public native void gluTessBeginPolygon ( - int tobj, + long tobj, boolean[] polygon_data ) ; public native void gluTessBeginPolygon ( - int tobj, + long tobj, long[] polygon_data ) ; @@ -708,7 +685,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluTessBeginContour ( - int tobj + long tobj ) ; /** @@ -718,37 +695,37 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluTessVertex ( - int tobj, + long tobj, double[] coords, byte[] vertex_data ) ; public native void gluTessVertex ( - int tobj, + long tobj, double[] coords, short[] vertex_data ) ; public native void gluTessVertex ( - int tobj, + long tobj, double[] coords, int[] vertex_data ) ; public native void gluTessVertex ( - int tobj, + long tobj, double[] coords, float[] vertex_data ) ; public native void gluTessVertex ( - int tobj, + long tobj, double[] coords, double[] vertex_data ) ; public native void gluTessVertex ( - int tobj, + long tobj, double[] coords, boolean[] vertex_data ) ; public native void gluTessVertex ( - int tobj, + long tobj, double[] coords, long[] vertex_data ) ; @@ -760,7 +737,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluTessEndContour ( - int tobj + long tobj ) ; /** @@ -770,7 +747,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluTessEndPolygon ( - int tobj + long tobj ) ; /** @@ -780,7 +757,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluTessProperty ( - int tobj, + long tobj, int which, double value ) ; @@ -792,7 +769,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluTessNormal ( - int tobj, + long tobj, double x, double y, double z @@ -805,7 +782,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluGetTessProperty ( - int tobj, + long tobj, int which, double[] value ) ; @@ -817,7 +794,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluBeginPolygon ( - int tobj + long tobj ) ; /** @@ -827,7 +804,7 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluNextContour ( - int tobj, + long tobj, int type ) ; @@ -838,10 +815,10 @@ public native void gluDeleteTess( int tobj ); * */ public native void gluEndPolygon ( - int tobj + long tobj ) ; -/* C2J Parser Version 1.4 Beta: Java program parsed successfully. */ +/* C2J Parser Version 1.5 Beta: Java program parsed successfully. */ } diff --git a/gl4java/applet/SimpleGLAnimApplet1.java b/gl4java/applet/SimpleGLAnimApplet1.java index db74690..aa2b97b 100644 --- a/gl4java/applet/SimpleGLAnimApplet1.java +++ b/gl4java/applet/SimpleGLAnimApplet1.java @@ -72,6 +72,7 @@ public class SimpleGLAnimApplet1 extends Applet { checkUseFpsSleep.setState(canvas.getUseFpsSleep()); checkUseRepaint.setState(canvas.getUseRepaint()); + canvas.addMouseListener(this); canvas.start(); } @@ -111,10 +112,55 @@ public class SimpleGLAnimApplet1 extends Applet { } + Container _cont = null; + public void mouseClicked( MouseEvent evt ) { Component comp = evt.getComponent(); + if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0) + { + if(comp instanceof GLAnimCanvas) + { + GLAnimCanvas glcvs = (GLAnimCanvas)comp; + glcvs.cvsDispose(); + + Container c = glcvs.getParent(); + c.remove(glcvs); + + System.out.println("\n\nremoved: "+glcvs); + System.out.println("Global GLAnimCanvas Render-Thread Number: "+ GLAnimCanvas.getGlobalThreadNumber()); + System.out.println("GLContextNumber: "+ + GLContext.getNativeGLContextNumber()); + + glcvs.setVisible(true); + + if(c instanceof Frame) + { + Frame of = (Frame)c; + of.dispose(); + of=null; + + _cont.add(canvas); + _cont.doLayout(); + } else if(c instanceof Panel) + { + _cont=c; + Frame f = new Frame("EXTRA"); + f.add(glcvs); + f.pack(); + f.setVisible(true); + } + glcvs.start(); + + System.out.println("\nadded+started: "+glcvs); + System.out.println("Global GLAnimCanvas Render-Thread Number: "+ GLAnimCanvas.getGlobalThreadNumber()); + System.out.println("GLContextNumber: "+ + GLContext.getNativeGLContextNumber()); + } + return; + } + if( canvas!=null && comp.equals(buttonFps) ) { double fps = 0; diff --git a/gl4java/awt/GLAnimCanvas.java b/gl4java/awt/GLAnimCanvas.java index 77fd21f..6133e60 100644 --- a/gl4java/awt/GLAnimCanvas.java +++ b/gl4java/awt/GLAnimCanvas.java @@ -83,6 +83,13 @@ import java.lang.Math; * because a GL-Context can be shared by many threads, * but one thread can have just one GL-Context ! * + *

+ * + * Since GL4Java 2.5.2 and using a JVM >= 1.3 + * the multithreading support is stable ! + * + *

+ * * (comments welcome) * *

@@ -102,7 +109,7 @@ import java.lang.Math; ReInit - ReInitialisation after stop for setSuspended(false) * * - * @see GLCanvas + * @see gl4java.awt.GLCanvas * @version 2.0, 21. April 1999 * @author Sven Goethel * @@ -116,11 +123,18 @@ public class GLAnimCanvas extends GLCanvas * * A little GUI is supported ! * - * @see GLAnimCanvas#run + * @see gl4java.awt.GLAnimCanvas#run */ protected double FramesPerSec=20; protected long mSecPerFrame=0; + protected static int globalThreadNumber=0; + + public static int getGlobalThreadNumber() + { + return globalThreadNumber; + } + /** * the delays .. */ @@ -129,16 +143,16 @@ public class GLAnimCanvas extends GLCanvas /** * The thread for referencing Thread (Animation) * - * @see GLAnimCanvas#stop - * @see GLAnimCanvas#start - * @see GLAnimCanvas#run + * @see gl4java.awt.GLAnimCanvas#stop + * @see gl4java.awt.GLAnimCanvas#start + * @see gl4java.awt.GLAnimCanvas#run */ protected Thread killme = null; /** * Instead of using suspend (JAVA2) * - * @see GLAnimCanvas#run + * @see gl4java.awt.GLAnimCanvas#run */ protected boolean threadSuspended = false; @@ -151,7 +165,7 @@ public class GLAnimCanvas extends GLCanvas * * Constructor * - * @see GLCanvas#GLCanvas + * @see gl4java.awt.GLCanvas#GLCanvas * */ public GLAnimCanvas( int width, int height, @@ -169,7 +183,7 @@ public class GLAnimCanvas extends GLCanvas * * Uses the default GLFunc and GLUFunc implementation ! * - * @see GLCanvas#GLCanvas + * @see gl4java.awt.GLCanvas#GLCanvas * */ public GLAnimCanvas( int width, int height ) @@ -206,16 +220,24 @@ public class GLAnimCanvas extends GLCanvas * *

* + * You MUST encapsulate your OpenGL call's within: + *

+		- glj.gljMakeCurrent()
+			YOUR OpenGL commands here !
+		- glj.gljFree()
+	 * 
+ *

+ * * You should set shallWeRender here, * to signalize the animation-loop 'run' to supsend *

* To restart the thread, just call setSuspended(false) * - * @see GLAnimCanvas#shallWeRender - * @see GLAnimCanvas#run - * @see GLAnimCanvas#setSuspended - * @see GLCanvas#sDisplay - * @see GLCanvas#paint + * @see gl4java.awt.GLAnimCanvas#shallWeRender + * @see gl4java.awt.GLAnimCanvas#run + * @see gl4java.awt.GLAnimCanvas#setSuspended + * @see gl4java.awt.GLCanvas#sDisplay + * @see gl4java.awt.GLCanvas#paint */ public void display() { @@ -229,7 +251,7 @@ public class GLAnimCanvas extends GLCanvas return; } - if( glj.gljMakeCurrent(true) == false ) + if( glj.gljMakeCurrent() == false ) { if(glj.gljClassDebug) System.out.println("GLAnimCanvas problem in gljMakeCurrent() method"); @@ -248,7 +270,7 @@ public class GLAnimCanvas extends GLCanvas * ReInit should be overwritten by you, * to enter your re-initialisation within setSuspended(false) * - * @see GLAnimCanvas#setSuspended + * @see gl4java.awt.GLAnimCanvas#setSuspended */ public void ReInit() { @@ -271,8 +293,8 @@ public class GLAnimCanvas extends GLCanvas *

* * @param b if true, uses repaint (default), otherwise directly sDisplay - * @see GLCanvas#sDisplay - * @see GLAnimCanvas#setUseFpsSleep + * @see gl4java.awt.GLCanvas#sDisplay + * @see gl4java.awt.GLAnimCanvas#setUseFpsSleep */ public void setUseRepaint(boolean b) { @@ -288,8 +310,8 @@ public class GLAnimCanvas extends GLCanvas *

* * @param b if true, uses Fps sleeping, else not ! - * @see GLCanvas#sDisplay - * @see GLAnimCanvas#setUseRepaint + * @see gl4java.awt.GLCanvas#sDisplay + * @see gl4java.awt.GLAnimCanvas#setUseRepaint */ public void setUseFpsSleep(boolean b) { @@ -324,10 +346,30 @@ public class GLAnimCanvas extends GLCanvas public synchronized void stop() { killme = null; - threadSuspended=false; - notify(); + threadSuspended=false; + + notifyAll(); } + /** + * You should call this before releasing/dispose this Window ! + * Also you can overwrite this class, + * to dispose your own elements, e.g. a Frame etc. - + * but be shure that you call + * cvsDispose implementation call this one ! + * + * This function calls gljDestroy of GLContext ! + * + * @see gl4java.GLContext#gljDestroy + * @see gl4java.awt.GLCanvas#cvsDispose + * @see gl4java.awt.GLCanvas#doCleanup + */ + public void cvsDispose() + { + stop(); + super.cvsDispose(); + } + /** * Should be set in display, * whether to render or not while the animation loop @@ -335,10 +377,11 @@ public class GLAnimCanvas extends GLCanvas * If shallWeRender is false, * this thread will suspend ! * - * @see GLAnimCanvas#display - * @see GLAnimCanvas#run + * @see gl4java.awt.GLAnimCanvas#display + * @see gl4java.awt.GLAnimCanvas#run */ protected boolean shallWeRender = true; + protected boolean isRunning = false; private long _fDelay = 0; private long _fDelay_Frames = 10; @@ -349,14 +392,18 @@ public class GLAnimCanvas extends GLCanvas * The running loop for animations * which initiates the call of display * - * @see GLAnimCanvas#shallWeRender - * @see GLAnimCanvas#display - * @see GLAnimCanvas#diplay + * @see gl4java.awt.GLAnimCanvas#shallWeRender + * @see gl4java.awt.GLAnimCanvas#display */ public void run() { Thread thisThread = Thread.currentThread(); + isRunning = true; + + synchronized (this) { + globalThreadNumber++; + } while (killme==thisThread) { @@ -370,8 +417,7 @@ public class GLAnimCanvas extends GLCanvas else sDisplay(); } else { - // lets sleep ... - synchronized (this) { + synchronized (this) { threadSuspended=true; } } @@ -399,7 +445,9 @@ public class GLAnimCanvas extends GLCanvas } Thread.currentThread().sleep(dFpsMilli, 0 ); - } + } else { + Thread.yield(); + } if (threadSuspended) { stopFpsCounter(); @@ -411,6 +459,15 @@ public class GLAnimCanvas extends GLCanvas } catch (InterruptedException e) {} } + + if(glj!=null) + glj.gljFree(); // just to be sure .. + + synchronized (this) { + globalThreadNumber--; + } + + isRunning = false; } /** @@ -422,8 +479,8 @@ public class GLAnimCanvas extends GLCanvas * @param suspend if true the thread will be suspended, * if false, the thread will be (re)started * - * @see GLAnimCanvas#isAlive - * @see GLAnimCanvas#start + * @see gl4java.awt.GLAnimCanvas#isAlive + * @see gl4java.awt.GLAnimCanvas#start */ public void setSuspended(boolean suspend) { @@ -442,8 +499,8 @@ public class GLAnimCanvas extends GLCanvas * @param reInit if true the ReInit will be called additionally, * where the user can set additional initialisations * - * @see GLAnimCanvas#isAlive - * @see GLAnimCanvas#start + * @see gl4java.awt.GLAnimCanvas#isAlive + * @see gl4java.awt.GLAnimCanvas#start */ public synchronized void setSuspended(boolean suspend, boolean reInit) { @@ -461,17 +518,17 @@ public class GLAnimCanvas extends GLCanvas ReInit(); threadSuspended=false; - notify(); + notifyAll(); } } /** * is the thread alive, means is started and not died ? * - * @see GLAnimCanvas#run - * @see GLAnimCanvas#setSuspended - * @see GLAnimCanvas#start - * @see GLAnimCanvas#stop + * @see gl4java.awt.GLAnimCanvas#run + * @see gl4java.awt.GLAnimCanvas#setSuspended + * @see gl4java.awt.GLAnimCanvas#start + * @see gl4java.awt.GLAnimCanvas#stop */ public boolean isAlive() { @@ -483,10 +540,10 @@ public class GLAnimCanvas extends GLCanvas * is the thread suspended, means is started but waiting, * or not alive (ok :-| - but it is practical) * - * @see GLAnimCanvas#run - * @see GLAnimCanvas#setSuspended - * @see GLAnimCanvas#start - * @see GLAnimCanvas#stop + * @see gl4java.awt.GLAnimCanvas#run + * @see gl4java.awt.GLAnimCanvas#setSuspended + * @see gl4java.awt.GLAnimCanvas#start + * @see gl4java.awt.GLAnimCanvas#stop */ public boolean isSuspended() { @@ -507,14 +564,14 @@ public class GLAnimCanvas extends GLCanvas * this function is called automatically by * start and setSuspended * - * @see GLAnimCanvas#start - * @see GLAnimCanvas#setSuspended - * @see GLAnimCanvas#resetFpsCounter - * @see GLAnimCanvas#stopFpsCounter - * @see GLAnimCanvas#getFps - * @see GLAnimCanvas#getFpsDuration - * @see GLAnimCanvas#getFpsFrames - * @see GLAnimCanvas#setVerboseFps + * @see gl4java.awt.GLAnimCanvas#start + * @see gl4java.awt.GLAnimCanvas#setSuspended + * @see gl4java.awt.GLAnimCanvas#resetFpsCounter + * @see gl4java.awt.GLAnimCanvas#stopFpsCounter + * @see gl4java.awt.GLAnimCanvas#getFps + * @see gl4java.awt.GLAnimCanvas#getFpsDuration + * @see gl4java.awt.GLAnimCanvas#getFpsFrames + * @see gl4java.awt.GLAnimCanvas#setVerboseFps */ public void resetFpsCounter() { @@ -535,14 +592,14 @@ public class GLAnimCanvas extends GLCanvas * All data's are print out on System.out * if verboseFps is set ! * - * @see GLAnimCanvas#run - * @see GLAnimCanvas#shallWeRender - * @see GLAnimCanvas#resetFpsCounter - * @see GLAnimCanvas#stopFpsCounter - * @see GLAnimCanvas#getFps - * @see GLAnimCanvas#getFpsDuration - * @see GLAnimCanvas#getFpsFrames - * @see GLAnimCanvas#setVerboseFps + * @see gl4java.awt.GLAnimCanvas#run + * @see gl4java.awt.GLAnimCanvas#shallWeRender + * @see gl4java.awt.GLAnimCanvas#resetFpsCounter + * @see gl4java.awt.GLAnimCanvas#stopFpsCounter + * @see gl4java.awt.GLAnimCanvas#getFps + * @see gl4java.awt.GLAnimCanvas#getFpsDuration + * @see gl4java.awt.GLAnimCanvas#getFpsFrames + * @see gl4java.awt.GLAnimCanvas#setVerboseFps */ public void stopFpsCounter() { @@ -571,14 +628,14 @@ public class GLAnimCanvas extends GLCanvas *

* verboseFps is set to true by default ! * - * @see GLAnimCanvas#run - * @see GLAnimCanvas#shallWeRender - * @see GLAnimCanvas#resetFpsCounter - * @see GLAnimCanvas#stopFpsCounter - * @see GLAnimCanvas#getFps - * @see GLAnimCanvas#getFpsDuration - * @see GLAnimCanvas#getFpsFrames - * @see GLAnimCanvas#setVerboseFps + * @see gl4java.awt.GLAnimCanvas#run + * @see gl4java.awt.GLAnimCanvas#shallWeRender + * @see gl4java.awt.GLAnimCanvas#resetFpsCounter + * @see gl4java.awt.GLAnimCanvas#stopFpsCounter + * @see gl4java.awt.GLAnimCanvas#getFps + * @see gl4java.awt.GLAnimCanvas#getFpsDuration + * @see gl4java.awt.GLAnimCanvas#getFpsFrames + * @see gl4java.awt.GLAnimCanvas#setVerboseFps */ public void setVerboseFps(boolean v) { @@ -590,12 +647,12 @@ public class GLAnimCanvas extends GLCanvas *

* this data is avaiable after calling stopFpsCounter * - * @see GLAnimCanvas#resetFpsCounter - * @see GLAnimCanvas#stopFpsCounter - * @see GLAnimCanvas#getFps - * @see GLAnimCanvas#getFpsDuration - * @see GLAnimCanvas#getFpsFrames - * @see GLAnimCanvas#setVerboseFps + * @see gl4java.awt.GLAnimCanvas#resetFpsCounter + * @see gl4java.awt.GLAnimCanvas#stopFpsCounter + * @see gl4java.awt.GLAnimCanvas#getFps + * @see gl4java.awt.GLAnimCanvas#getFpsDuration + * @see gl4java.awt.GLAnimCanvas#getFpsFrames + * @see gl4java.awt.GLAnimCanvas#setVerboseFps */ public double getFps() { @@ -607,12 +664,12 @@ public class GLAnimCanvas extends GLCanvas *

* this data is avaiable after calling stopFpsCounter * - * @see GLAnimCanvas#resetFpsCounter - * @see GLAnimCanvas#stopFpsCounter - * @see GLAnimCanvas#getFps - * @see GLAnimCanvas#getFpsDuration - * @see GLAnimCanvas#getFpsFrames - * @see GLAnimCanvas#setVerboseFps + * @see gl4java.awt.GLAnimCanvas#resetFpsCounter + * @see gl4java.awt.GLAnimCanvas#stopFpsCounter + * @see gl4java.awt.GLAnimCanvas#getFps + * @see gl4java.awt.GLAnimCanvas#getFpsDuration + * @see gl4java.awt.GLAnimCanvas#getFpsFrames + * @see gl4java.awt.GLAnimCanvas#setVerboseFps */ public long getFpsDuration() { @@ -624,12 +681,12 @@ public class GLAnimCanvas extends GLCanvas *

* this data is avaiable after calling stopFpsCounter * - * @see GLAnimCanvas#resetFpsCounter - * @see GLAnimCanvas#stopFpsCounter - * @see GLAnimCanvas#getFps - * @see GLAnimCanvas#getFpsDuration - * @see GLAnimCanvas#getFpsFrames - * @see GLAnimCanvas#setVerboseFps + * @see gl4java.awt.GLAnimCanvas#resetFpsCounter + * @see gl4java.awt.GLAnimCanvas#stopFpsCounter + * @see gl4java.awt.GLAnimCanvas#getFps + * @see gl4java.awt.GLAnimCanvas#getFpsDuration + * @see gl4java.awt.GLAnimCanvas#getFpsFrames + * @see gl4java.awt.GLAnimCanvas#setVerboseFps */ public long getFpsFrames() { @@ -651,7 +708,7 @@ public class GLAnimCanvas extends GLCanvas /** * Just set the FramePerSecounds for Animation * - * @see GLAnimCanvas#getMaxFps + * @see gl4java.awt.GLAnimCanvas#getMaxFps */ public void setAnimateFps(double fps) { @@ -675,7 +732,7 @@ public class GLAnimCanvas extends GLCanvas * this value is avaiable after the thread is started * and the first frames are rendered ! * - * @see GLAnimCanvas#setAnimateFps + * @see gl4java.awt.GLAnimCanvas#setAnimateFps */ public double getMaxFps() { diff --git a/gl4java/awt/GLCanvas.java b/gl4java/awt/GLCanvas.java index 4a537f9..78775b6 100644 --- a/gl4java/awt/GLCanvas.java +++ b/gl4java/awt/GLCanvas.java @@ -62,7 +62,7 @@ import java.awt.event.*; * *

* - * @see GLAnimCanvas + * @see gl4java.awt.GLAnimCanvas * @version 2.0, 21. April 1999 * @author Sven Goethel * @@ -87,8 +87,8 @@ public class GLCanvas extends Canvas * This value is updated after a GLContext is created with the * original updated value of GLContext ! * - * @see GLCanvas#preInit - * @see GLCanvas#paint + * @see gl4java.awt.GLCanvas#preInit + * @see gl4java.awt.GLCanvas#paint */ protected boolean doubleBuffer = true; @@ -97,8 +97,8 @@ public class GLCanvas extends Canvas * This value is updated after a GLContext is created with the * original updated value of GLContext ! * - * @see GLCanvas#preInit - * @see GLCanvas#paint + * @see gl4java.awt.GLCanvas#preInit + * @see gl4java.awt.GLCanvas#paint */ protected int stencilBits = 0; @@ -114,8 +114,8 @@ public class GLCanvas extends Canvas * The output value, after the constructor returns, * it is the summary of all accumulation bits of all components ! * - * @see GLCanvas#preInit - * @see GLCanvas#paint + * @see gl4java.awt.GLCanvas#preInit + * @see gl4java.awt.GLCanvas#paint */ protected int accumSize = 0; @@ -124,8 +124,8 @@ public class GLCanvas extends Canvas * This value is updated after a GLContext is created with the * original updated value of GLContext ! * - * @see GLCanvas#preInit - * @see GLCanvas#paint + * @see gl4java.awt.GLCanvas#preInit + * @see gl4java.awt.GLCanvas#paint */ protected boolean stereoView = false; @@ -134,8 +134,8 @@ public class GLCanvas extends Canvas * This value is updated after a GLContext is created with the * original updated value of GLContext ! * - * @see GLCanvas#preInit - * @see GLCanvas#paint + * @see gl4java.awt.GLCanvas#preInit + * @see gl4java.awt.GLCanvas#paint */ protected boolean rgba = true; @@ -144,16 +144,16 @@ public class GLCanvas extends Canvas * This value is updated after a GLContext is created with the * original updated value of GLContext ! * - * @see GLCanvas#preInit - * @see GLCanvas#paint + * @see gl4java.awt.GLCanvas#preInit + * @see gl4java.awt.GLCanvas#paint */ protected boolean createOwnWindow = false; /** - * The context with witch display lists and textures will be shared. + * The context with wich display lists and textures will be shared. * - * @see GLCanvas#preInit - * @see GLCanvas#paint + * @see gl4java.awt.GLCanvas#preInit + * @see gl4java.awt.GLCanvas#paint */ protected GLContext sharedGLContext; @@ -240,7 +240,7 @@ public class GLCanvas extends Canvas * @param g the Graphics Context * @return void * - * @see GLCanvas#paint + * @see gl4java.awt.GLCanvas#paint */ public void update(Graphics g) { @@ -260,7 +260,7 @@ public class GLCanvas extends Canvas * * @return void * - * @see GLCanvas#paint + * @see gl4java.awt.GLCanvas#paint */ public final Window getTopLevelWindow() { return topLevelWindow; } @@ -283,11 +283,11 @@ public class GLCanvas extends Canvas * in your derivation. * * @see gl4java.GLContext#GLContext - * @see GLCanvas#cvsIsInit - * @see GLCanvas#sDisplay - * @see GLCanvas#display - * @see GLCanvas#preInit - * @see GLCanvas#init + * @see gl4java.awt.GLCanvas#cvsIsInit + * @see gl4java.awt.GLCanvas#sDisplay + * @see gl4java.awt.GLCanvas#display + * @see gl4java.awt.GLCanvas#preInit + * @see gl4java.awt.GLCanvas#init */ public synchronized final void paint( Graphics g ) { @@ -342,10 +342,6 @@ public class GLCanvas extends Canvas if(glj!=null && glj.gljIsInit()) cvsInitialized=true; } - /* - if( mustResize ) size = getSize(); - g.setClip(0, 0, size.width, size.height ) ; - */ sDisplay(); } @@ -358,12 +354,12 @@ public class GLCanvas extends Canvas * * @return void * - * @see GLCanvas#paint - * @see GLCanvas#doubleBuffer - * @see GLCanvas#stereoView - * @see GLCanvas#rgba - * @see GLCanvas#stencilBits - * @see GLCanvas#accumSize + * @see gl4java.awt.GLCanvas#paint + * @see gl4java.awt.GLCanvas#doubleBuffer + * @see gl4java.awt.GLCanvas#stereoView + * @see gl4java.awt.GLCanvas#rgba + * @see gl4java.awt.GLCanvas#stencilBits + * @see gl4java.awt.GLCanvas#accumSize */ public void preInit() { @@ -378,7 +374,7 @@ public class GLCanvas extends Canvas * * @return void * - * @see GLCanvas#paint + * @see gl4java.awt.GLCanvas#paint */ public void init() { @@ -393,7 +389,7 @@ public class GLCanvas extends Canvas * * @return void * - * @see GLCanvas#cvsDispose + * @see gl4java.awt.GLCanvas#cvsDispose */ public void doCleanup() { @@ -406,8 +402,8 @@ public class GLCanvas extends Canvas * * @return boolean * - * @see GLCanvas#paint - * @see GLCanvas#init + * @see gl4java.awt.GLCanvas#paint + * @see gl4java.awt.GLCanvas#init */ public boolean cvsIsInit() { @@ -433,8 +429,8 @@ public class GLCanvas extends Canvas * * @return void * - * @see GLCanvas#paint - * @see GLCanvas#display + * @see gl4java.awt.GLCanvas#paint + * @see gl4java.awt.GLCanvas#display */ public synchronized final void sDisplay() { @@ -447,7 +443,7 @@ public class GLCanvas extends Canvas if( mustResize ) { - if( (ok = glj.gljMakeCurrent()) == true ) + if( glj.gljMakeCurrent() == true ) { size = getSize(); glj.gljResize( size.width, size.height ) ; @@ -455,6 +451,7 @@ public class GLCanvas extends Canvas mustResize = false; invalidate(); repaint(100); + glj.gljFree(); } } if(ok) @@ -471,6 +468,15 @@ public class GLCanvas extends Canvas * (and sDisplay is called by paint !). * The derived-class (Your Subclass) will redefine this, to draw it's own... * + *

+ * + * You MUST encapsulate your OpenGL call's within: + *

+    	- glj.gljMakeCurrent()
+		YOUR OpenGL commands here !
+    	- glj.gljFree()
+     * 
+ * * BE SURE, if you want to call 'display' by yourself * (e.g. in the run method for animation) * YOU HAVE TO CALL sDisplay ! @@ -480,8 +486,10 @@ public class GLCanvas extends Canvas * * @return void * - * @see GLCanvas#sDisplay - * @see GLCanvas#paint + * @see gl4java.awt.GLCanvas#sDisplay + * @see gl4java.awt.GLCanvas#paint + * @see gl4java.GLContext#gljMakeCurrent + * @see gl4java.GLContext#gljSwap */ public void display() { @@ -508,8 +516,8 @@ public class GLCanvas extends Canvas * @param height the new height * @return void * - * @see GLCanvas#paint - * @see GLCanvas#sDisplay + * @see gl4java.awt.GLCanvas#paint + * @see gl4java.awt.GLCanvas#sDisplay */ public void reshape( int width, int height ) { @@ -533,8 +541,8 @@ public class GLCanvas extends Canvas * @param e the element, which is resized * @return void * - * @see GLCanvas#paint - * @see GLCanvas#reshape + * @see gl4java.awt.GLCanvas#paint + * @see gl4java.awt.GLCanvas#reshape */ public void componentResized(ComponentEvent e) { @@ -644,7 +652,7 @@ public class GLCanvas extends Canvas * This function calls gljDestroy of GLContext ! * * @see gl4java.GLContext#gljDestroy - * @see GLCanvas#doCleanup + * @see gl4java.awt.GLCanvas#doCleanup */ public void cvsDispose() { @@ -664,11 +672,13 @@ public class GLCanvas extends Canvas context, so it all works out fine. */ try { - glj.gljFree(); - doCleanup(); - //locks and free's GLContext glj.setEnabled(false); + + setVisible(false); + doCleanup(); + glj.gljDestroy(); + glj = null; needCvsDispose = false; } catch (Exception ex) diff --git a/gl4java/jau/awt/WinHandleAccess.java b/gl4java/jau/awt/WinHandleAccess.java index b6e8c87..1a491ce 100644 --- a/gl4java/jau/awt/WinHandleAccess.java +++ b/gl4java/jau/awt/WinHandleAccess.java @@ -14,8 +14,8 @@ import java.awt.Graphics; */ public interface WinHandleAccess { - public abstract int getWinHandle(Component component, Graphics g); + public abstract long getWinHandle(Component component, Graphics g); - public abstract int getWinDepth(Component component, Graphics g); + public abstract int getWinDepth(Component component, Graphics g); } diff --git a/gl4java/jau/awt/macintosh/MacHandleAccess.java b/gl4java/jau/awt/macintosh/MacHandleAccess.java index db1c3ef..853662d 100644 --- a/gl4java/jau/awt/macintosh/MacHandleAccess.java +++ b/gl4java/jau/awt/macintosh/MacHandleAccess.java @@ -29,8 +29,8 @@ public class MacHandleAccess implements gl4java.jau.awt.WinHandleAccess protected DrawingSurface ds; protected DrawingSurfaceInfo dsi; protected MacDrawingSurface mds; - protected int window, - depth; + protected long window; + protected int depth; protected void achieveData(java.awt.Component c, java.awt.Graphics g) @@ -55,7 +55,7 @@ public class MacHandleAccess implements gl4java.jau.awt.WinHandleAccess { dsi.lock(); - window = mds.getPort(); + window = (long) mds.getPort(); depth = c.getColorModel().getPixelSize(); dsi.unlock(); @@ -71,7 +71,7 @@ public class MacHandleAccess implements gl4java.jau.awt.WinHandleAccess * * gets some structure for windows, and drawable on Mac */ - public int getWinHandle(java.awt.Component c, java.awt.Graphics g) + public long getWinHandle(java.awt.Component c, java.awt.Graphics g) { achieveData(c, g); return window; diff --git a/gl4java/jau/awt/motif/X11HandleAccess.java b/gl4java/jau/awt/motif/X11HandleAccess.java index f07e111..8d6b27e 100644 --- a/gl4java/jau/awt/motif/X11HandleAccess.java +++ b/gl4java/jau/awt/motif/X11HandleAccess.java @@ -27,7 +27,8 @@ public class X11HandleAccess { protected DrawingSurfaceInfo dsi; protected X11DrawingSurface wds; - protected int window, depth; + protected long window; + protected int depth; protected void achieveData(java.awt.Component c, java.awt.Graphics g) { @@ -46,7 +47,7 @@ public class X11HandleAccess if(wds!=null) { dsi.lock(); - window = wds.getDrawable(); + window = (long) wds.getDrawable(); depth = wds.getDepth(); /* @@ -67,7 +68,7 @@ public class X11HandleAccess * * gets some structure for windows, and drawable on X11 */ - public int getWinHandle(java.awt.Component c, java.awt.Graphics g) + public long getWinHandle(java.awt.Component c, java.awt.Graphics g) { achieveData(c, g); return window; diff --git a/gl4java/jau/awt/windows/MSWin32HandleAccess.java b/gl4java/jau/awt/windows/MSWin32HandleAccess.java index 1dd4d93..76809f3 100644 --- a/gl4java/jau/awt/windows/MSWin32HandleAccess.java +++ b/gl4java/jau/awt/windows/MSWin32HandleAccess.java @@ -24,7 +24,8 @@ import com.ms.awt.GraphicsX; public class MSWin32HandleAccess implements gl4java.jau.awt.WinHandleAccess { - protected int window, depth; + protected long window; + protected int depth; /** * @dll.import("USER32",auto) @@ -33,7 +34,7 @@ public class MSWin32HandleAccess protected void achieveData(java.awt.Component c, java.awt.Graphics g) { - window = WindowFromDC(((GraphicsX)g).gdc.pGetDC()); + window = (long) WindowFromDC(((GraphicsX)g).gdc.pGetDC()); depth = c.getColorModel().getPixelSize(); } @@ -41,7 +42,7 @@ public class MSWin32HandleAccess * * get the window handle */ - public int getWinHandle(java.awt.Component c, java.awt.Graphics g) + public long getWinHandle(java.awt.Component c, java.awt.Graphics g) { achieveData(c, g); return window; diff --git a/gl4java/jau/awt/windows/Win32HandleAccess.java b/gl4java/jau/awt/windows/Win32HandleAccess.java index 38b5c93..d4a698f 100644 --- a/gl4java/jau/awt/windows/Win32HandleAccess.java +++ b/gl4java/jau/awt/windows/Win32HandleAccess.java @@ -28,7 +28,8 @@ public class Win32HandleAccess protected DrawingSurfaceInfo dsi; protected Win32DrawingSurface wds; - protected int window, depth; + protected long window; + protected int depth; protected void achieveData(java.awt.Component c, java.awt.Graphics g) { @@ -47,7 +48,7 @@ public class Win32HandleAccess if(wds!=null) { dsi.lock(); - window = wds.getHDC(); + window = (long) wds.getHDC(); depth = wds.getDepth(); /* System.out.println("wds ="+wds); @@ -65,7 +66,7 @@ public class Win32HandleAccess * * gets some structure for windows, and drawable on Win32 */ - public int getWinHandle(java.awt.Component c, java.awt.Graphics g) + public long getWinHandle(java.awt.Component c, java.awt.Graphics g) { achieveData(c, g); return window; diff --git a/gl4java/swing/GLAnimJPanel.java b/gl4java/swing/GLAnimJPanel.java index e9bdbdf..a7af76a 100644 --- a/gl4java/swing/GLAnimJPanel.java +++ b/gl4java/swing/GLAnimJPanel.java @@ -102,7 +102,7 @@ import java.lang.Math; ReInit - ReInitialisation after stop for setSuspended(false) * * - * @see GLCanvas + * @see gl4java.awt.GLCanvas * @version 2.0, 21. April 1999 * @author Sven Goethel * @@ -116,7 +116,7 @@ public class GLAnimJPanel extends GLJPanel * * A little GUI is supported ! * - * @see GLAnimJPanel#run + * @see gl4java.swing.GLAnimJPanel#run */ protected double FramesPerSec=20; protected long mSecPerFrame=0; @@ -129,16 +129,16 @@ public class GLAnimJPanel extends GLJPanel /** * The thread for referencing Thread (Animation) * - * @see GLAnimJPanel#stop - * @see GLAnimJPanel#start - * @see GLAnimJPanel#run + * @see gl4java.swing.GLAnimJPanel#stop + * @see gl4java.swing.GLAnimJPanel#start + * @see gl4java.swing.GLAnimJPanel#run */ protected Thread killme = null; /** * Instead of using suspend (JAVA2) * - * @see GLAnimJPanel#run + * @see gl4java.swing.GLAnimJPanel#run */ protected boolean threadSuspended = false; @@ -222,7 +222,7 @@ public class GLAnimJPanel extends GLJPanel * * Uses the default GLFunc and GLUFunc implementation ! * - * @see GLCanvas#GLCanvas + * @see gl4java.awt.GLCanvas#GLCanvas * */ public GLAnimJPanel( ) @@ -264,11 +264,11 @@ public class GLAnimJPanel extends GLJPanel *

* To restart the thread, just call setSuspended(false) * - * @see GLAnimJPanel#shallWeRender - * @see GLAnimJPanel#run - * @see GLAnimJPanel#setSuspended - * @see GLCanvas#sDisplay - * @see GLCanvas#paint + * @see gl4java.swing.GLAnimJPanel#shallWeRender + * @see gl4java.swing.GLAnimJPanel#run + * @see gl4java.swing.GLAnimJPanel#setSuspended + * @see gl4java.awt.GLAnimCanvas#sDisplay + * @see gl4java.awt.GLAnimCanvas#paint */ public void display() { @@ -282,7 +282,7 @@ public class GLAnimJPanel extends GLJPanel * ReInit should be overwritten by you, * to enter your re-initialisation within setSuspended(false) * - * @see GLAnimJPanel#setSuspended + * @see gl4java.swing.GLAnimJPanel#setSuspended */ public void ReInit() { @@ -305,8 +305,8 @@ public class GLAnimJPanel extends GLJPanel *

* * @param b if true, uses repaint (default), otherwise directly sDisplay - * @see GLCanvas#sDisplay - * @see GLAnimJPanel#setUseFpsSleep + * @see gl4java.awt.GLAnimCanvas#sDisplay + * @see gl4java.swing.GLAnimJPanel#setUseFpsSleep */ public void setUseRepaint(boolean b) { @@ -322,8 +322,8 @@ public class GLAnimJPanel extends GLJPanel *

* * @param b if true, uses Fps sleeping, else not ! - * @see GLCanvas#sDisplay - * @see GLAnimJPanel#setUseRepaint + * @see gl4java.awt.GLAnimCanvas#sDisplay + * @see gl4java.swing.GLAnimJPanel#setUseRepaint */ public void setUseFpsSleep(boolean b) { @@ -369,8 +369,8 @@ public class GLAnimJPanel extends GLJPanel * If shallWeRender is false, * this thread will suspend ! * - * @see GLAnimJPanel#display - * @see GLAnimJPanel#run + * @see gl4java.swing.GLAnimJPanel#display + * @see gl4java.swing.GLAnimJPanel#run */ protected boolean shallWeRender = true; @@ -383,9 +383,8 @@ public class GLAnimJPanel extends GLJPanel * The running loop for animations * which initiates the call of display * - * @see GLAnimJPanel#shallWeRender - * @see GLAnimJPanel#display - * @see GLAnimJPanel#diplay + * @see gl4java.swing.GLAnimJPanel#shallWeRender + * @see gl4java.swing.GLAnimJPanel#display */ public void run() { @@ -456,8 +455,8 @@ public class GLAnimJPanel extends GLJPanel * @param suspend if true the thread will be suspended, * if false, the thread will be (re)started * - * @see GLAnimJPanel#isAlive - * @see GLAnimJPanel#start + * @see gl4java.swing.GLAnimJPanel#isAlive + * @see gl4java.swing.GLAnimJPanel#start */ public void setSuspended(boolean suspend) { @@ -476,8 +475,8 @@ public class GLAnimJPanel extends GLJPanel * @param reInit if true the ReInit will be called additionally, * where the user can set additional initialisations * - * @see GLAnimJPanel#isAlive - * @see GLAnimJPanel#start + * @see gl4java.swing.GLAnimJPanel#isAlive + * @see gl4java.swing.GLAnimJPanel#start */ public synchronized void setSuspended(boolean suspend, boolean reInit) { @@ -502,10 +501,10 @@ public class GLAnimJPanel extends GLJPanel /** * is the thread alive, means is started and not died ? * - * @see GLAnimJPanel#run - * @see GLAnimJPanel#setSuspended - * @see GLAnimJPanel#start - * @see GLAnimJPanel#stop + * @see gl4java.swing.GLAnimJPanel#run + * @see gl4java.swing.GLAnimJPanel#setSuspended + * @see gl4java.swing.GLAnimJPanel#start + * @see gl4java.swing.GLAnimJPanel#stop */ public boolean isAlive() { @@ -517,10 +516,10 @@ public class GLAnimJPanel extends GLJPanel * is the thread suspended, means is started but waiting, * or not alive (ok :-| - but it is practical) * - * @see GLAnimJPanel#run - * @see GLAnimJPanel#setSuspended - * @see GLAnimJPanel#start - * @see GLAnimJPanel#stop + * @see gl4java.swing.GLAnimJPanel#run + * @see gl4java.swing.GLAnimJPanel#setSuspended + * @see gl4java.swing.GLAnimJPanel#start + * @see gl4java.swing.GLAnimJPanel#stop */ public boolean isSuspended() { @@ -541,14 +540,14 @@ public class GLAnimJPanel extends GLJPanel * this function is called automatically by * start and setSuspended * - * @see GLAnimJPanel#start - * @see GLAnimJPanel#setSuspended - * @see GLAnimJPanel#resetFpsCounter - * @see GLAnimJPanel#stopFpsCounter - * @see GLAnimJPanel#getFps - * @see GLAnimJPanel#getFpsDuration - * @see GLAnimJPanel#getFpsFrames - * @see GLAnimJPanel#setVerboseFps + * @see gl4java.swing.GLAnimJPanel#start + * @see gl4java.swing.GLAnimJPanel#setSuspended + * @see gl4java.swing.GLAnimJPanel#resetFpsCounter + * @see gl4java.swing.GLAnimJPanel#stopFpsCounter + * @see gl4java.swing.GLAnimJPanel#getFps + * @see gl4java.swing.GLAnimJPanel#getFpsDuration + * @see gl4java.swing.GLAnimJPanel#getFpsFrames + * @see gl4java.swing.GLAnimJPanel#setVerboseFps */ public void resetFpsCounter() { @@ -569,14 +568,14 @@ public class GLAnimJPanel extends GLJPanel * All data's are print out on System.out * if verboseFps is set ! * - * @see GLAnimJPanel#run - * @see GLAnimJPanel#shallWeRender - * @see GLAnimJPanel#resetFpsCounter - * @see GLAnimJPanel#stopFpsCounter - * @see GLAnimJPanel#getFps - * @see GLAnimJPanel#getFpsDuration - * @see GLAnimJPanel#getFpsFrames - * @see GLAnimJPanel#setVerboseFps + * @see gl4java.swing.GLAnimJPanel#run + * @see gl4java.swing.GLAnimJPanel#shallWeRender + * @see gl4java.swing.GLAnimJPanel#resetFpsCounter + * @see gl4java.swing.GLAnimJPanel#stopFpsCounter + * @see gl4java.swing.GLAnimJPanel#getFps + * @see gl4java.swing.GLAnimJPanel#getFpsDuration + * @see gl4java.swing.GLAnimJPanel#getFpsFrames + * @see gl4java.swing.GLAnimJPanel#setVerboseFps */ public void stopFpsCounter() { @@ -605,14 +604,14 @@ public class GLAnimJPanel extends GLJPanel *

* verboseFps is set to true by default ! * - * @see GLAnimJPanel#run - * @see GLAnimJPanel#shallWeRender - * @see GLAnimJPanel#resetFpsCounter - * @see GLAnimJPanel#stopFpsCounter - * @see GLAnimJPanel#getFps - * @see GLAnimJPanel#getFpsDuration - * @see GLAnimJPanel#getFpsFrames - * @see GLAnimJPanel#setVerboseFps + * @see gl4java.swing.GLAnimJPanel#run + * @see gl4java.swing.GLAnimJPanel#shallWeRender + * @see gl4java.swing.GLAnimJPanel#resetFpsCounter + * @see gl4java.swing.GLAnimJPanel#stopFpsCounter + * @see gl4java.swing.GLAnimJPanel#getFps + * @see gl4java.swing.GLAnimJPanel#getFpsDuration + * @see gl4java.swing.GLAnimJPanel#getFpsFrames + * @see gl4java.swing.GLAnimJPanel#setVerboseFps */ public void setVerboseFps(boolean v) { @@ -624,12 +623,12 @@ public class GLAnimJPanel extends GLJPanel *

* this data is avaiable after calling stopFpsCounter * - * @see GLAnimJPanel#resetFpsCounter - * @see GLAnimJPanel#stopFpsCounter - * @see GLAnimJPanel#getFps - * @see GLAnimJPanel#getFpsDuration - * @see GLAnimJPanel#getFpsFrames - * @see GLAnimJPanel#setVerboseFps + * @see gl4java.swing.GLAnimJPanel#resetFpsCounter + * @see gl4java.swing.GLAnimJPanel#stopFpsCounter + * @see gl4java.swing.GLAnimJPanel#getFps + * @see gl4java.swing.GLAnimJPanel#getFpsDuration + * @see gl4java.swing.GLAnimJPanel#getFpsFrames + * @see gl4java.swing.GLAnimJPanel#setVerboseFps */ public double getFps() { @@ -641,12 +640,12 @@ public class GLAnimJPanel extends GLJPanel *

* this data is avaiable after calling stopFpsCounter * - * @see GLAnimJPanel#resetFpsCounter - * @see GLAnimJPanel#stopFpsCounter - * @see GLAnimJPanel#getFps - * @see GLAnimJPanel#getFpsDuration - * @see GLAnimJPanel#getFpsFrames - * @see GLAnimJPanel#setVerboseFps + * @see gl4java.swing.GLAnimJPanel#resetFpsCounter + * @see gl4java.swing.GLAnimJPanel#stopFpsCounter + * @see gl4java.swing.GLAnimJPanel#getFps + * @see gl4java.swing.GLAnimJPanel#getFpsDuration + * @see gl4java.swing.GLAnimJPanel#getFpsFrames + * @see gl4java.swing.GLAnimJPanel#setVerboseFps */ public long getFpsDuration() { @@ -658,12 +657,12 @@ public class GLAnimJPanel extends GLJPanel *

* this data is avaiable after calling stopFpsCounter * - * @see GLAnimJPanel#resetFpsCounter - * @see GLAnimJPanel#stopFpsCounter - * @see GLAnimJPanel#getFps - * @see GLAnimJPanel#getFpsDuration - * @see GLAnimJPanel#getFpsFrames - * @see GLAnimJPanel#setVerboseFps + * @see gl4java.swing.GLAnimJPanel#resetFpsCounter + * @see gl4java.swing.GLAnimJPanel#stopFpsCounter + * @see gl4java.swing.GLAnimJPanel#getFps + * @see gl4java.swing.GLAnimJPanel#getFpsDuration + * @see gl4java.swing.GLAnimJPanel#getFpsFrames + * @see gl4java.swing.GLAnimJPanel#setVerboseFps */ public long getFpsFrames() { @@ -685,7 +684,7 @@ public class GLAnimJPanel extends GLJPanel /** * Just set the FramePerSecounds for Animation * - * @see GLAnimJPanel#getMaxFps + * @see gl4java.swing.GLAnimJPanel#getMaxFps */ public void setAnimateFps(double fps) { @@ -709,7 +708,7 @@ public class GLAnimJPanel extends GLJPanel * this value is avaiable after the thread is started * and the first frames are rendered ! * - * @see GLAnimJPanel#setAnimateFps + * @see gl4java.swing.GLAnimJPanel#setAnimateFps */ public double getMaxFps() { diff --git a/gl4java/swing/GLJPanel.java b/gl4java/swing/GLJPanel.java index 21beb39..1e23110 100644 --- a/gl4java/swing/GLJPanel.java +++ b/gl4java/swing/GLJPanel.java @@ -59,7 +59,9 @@ import javax.swing.*; * *

* - * @see GLAnimJPanel + * @see gl4java.swing.GLAnimJPanel + * @see gl4java.awt.GLCanvas + * * @version 2.0, 21. April 1999 * @author Sven Goethel * @@ -83,8 +85,8 @@ public class GLJPanel extends JPanel * This value is updated after a GLContext is created with the * original updated value of GLContext ! * - * @see GLJPanel#preInit - * @see GLJPanel#paint + * @see gl4java.swing.GLJPanel#preInit + * @see gl4java.swing.GLJPanel#paint */ protected int stencilBits = 0; @@ -93,8 +95,8 @@ public class GLJPanel extends JPanel * This value is updated after a GLContext is created with the * original updated value of GLContext ! * - * @see GLJPanel#preInit - * @see GLJPanel#paint + * @see gl4java.swing.GLJPanel#preInit + * @see gl4java.swing.GLJPanel#paint */ protected int accumSize = 0; @@ -103,8 +105,8 @@ public class GLJPanel extends JPanel * This value is updated after a GLContext is created with the * original updated value of GLContext ! * - * @see GLJPanel#preInit - * @see GLJPanel#paint + * @see gl4java.swing.GLJPanel#preInit + * @see gl4java.swing.GLJPanel#paint */ protected boolean stereoView = false; @@ -113,32 +115,32 @@ public class GLJPanel extends JPanel * This value is updated after a GLContext is created with the * original updated value of GLContext ! * - * @see GLJPanel#preInit - * @see GLJPanel#paint + * @see gl4java.swing.GLJPanel#preInit + * @see gl4java.swing.GLJPanel#paint */ protected boolean rgba = true; /** * The context with witch display lists and textures will be shared. * - * @see GLJPanel#preInit - * @see GLJPanel#paint + * @see gl4java.swing.GLJPanel#preInit + * @see gl4java.swing.GLJPanel#paint */ protected GLContext sharedGLContext; /** * The data to hold the offscreen pixels on the java side ! * - * @see GLJPanel#offImagePixels - * @see GLJPanel#paint + * @see gl4java.swing.GLJPanel#offImagePixels + * @see gl4java.swing.GLJPanel#paint */ protected BufferedImage offImage = null; /** * The data to hold the offscreen pixels on the GL side ! * - * @see GLJPanel#offImage - * @see GLJPanel#paint + * @see gl4java.swing.GLJPanel#offImage + * @see gl4java.swing.GLJPanel#paint */ protected byte[] offImagePixels = null; @@ -149,9 +151,9 @@ public class GLJPanel extends JPanel * the offscreen pixmap is used in this size, * not in the components-size (-> faster if smaller) * - * @see GLJPanel#paint - * @see GLJPanel#setOffScreenSize - * @see GLJPanel#getOffScreenSize + * @see gl4java.swing.GLJPanel#paint + * @see gl4java.swing.GLJPanel#setOffScreenSize + * @see gl4java.swing.GLJPanel#getOffScreenSize */ protected Dimension offScrnSize = null; protected boolean customOffScrnSize=false; @@ -269,7 +271,7 @@ public class GLJPanel extends JPanel * * @return void * - * @see GLJPanel#paint + * @see gl4java.swing.GLJPanel#paint */ public final Window getTopLevelWindow() { return topLevelWindow; } @@ -281,8 +283,8 @@ public class GLJPanel extends JPanel * the offscreen pixmap is used in this size, * not in the components-size (-> faster if smaller) * - * @see GLJPanel#offScrnSize - * @see GLJPanel#setOffScreenSize + * @see gl4java.swing.GLJPanel#offScrnSize + * @see gl4java.swing.GLJPanel#setOffScreenSize */ public Dimension getOffScreenSize() { return offScrnSize; } @@ -294,8 +296,8 @@ public class GLJPanel extends JPanel * the offscreen pixmap is used in this size, * not in the components-size (-> faster if smaller) * - * @see GLJPanel#offScrnSize - * @see GLJPanel#getOffScreenSize + * @see gl4java.swing.GLJPanel#offScrnSize + * @see gl4java.swing.GLJPanel#getOffScreenSize */ public void setOffScreenSize(Dimension size) { @@ -327,11 +329,11 @@ public class GLJPanel extends JPanel * in your derivation. * * @see gl4java.GLContext#GLContext - * @see GLJPanel#cvsIsInit - * @see GLJPanel#sDisplay - * @see GLJPanel#display - * @see GLJPanel#preInit - * @see GLJPanel#init + * @see gl4java.swing.GLJPanel#cvsIsInit + * @see gl4java.swing.GLJPanel#sDisplay + * @see gl4java.swing.GLJPanel#display + * @see gl4java.swing.GLJPanel#preInit + * @see gl4java.swing.GLJPanel#init */ public synchronized final void paintComponent(Graphics g) { @@ -430,8 +432,8 @@ public class GLJPanel extends JPanel * * @return void * - * @see GLJPanel#paint - * @see GLJPanel#display + * @see gl4java.swing.GLJPanel#paint + * @see gl4java.swing.GLJPanel#display */ public synchronized final void sDisplay() { @@ -562,8 +564,8 @@ public class GLJPanel extends JPanel * * @return void * - * @see GLJPanel#sDisplay - * @see GLJPanel#paint + * @see gl4java.swing.GLJPanel#sDisplay + * @see gl4java.swing.GLJPanel#paint */ public void display() { @@ -578,12 +580,11 @@ public class GLJPanel extends JPanel * * @return void * - * @see GLJPanel#paint - * @see GLJPanel#doubleBuffer - * @see GLJPanel#stereoView - * @see GLJPanel#rgba - * @see GLJPanel#stencilBits - * @see GLJPanel#accumSize + * @see gl4java.swing.GLJPanel#paint + * @see gl4java.swing.GLJPanel#stereoView + * @see gl4java.swing.GLJPanel#rgba + * @see gl4java.swing.GLJPanel#stencilBits + * @see gl4java.swing.GLJPanel#accumSize */ public void preInit() { @@ -598,7 +599,7 @@ public class GLJPanel extends JPanel * * @return void * - * @see GLJPanel#paint + * @see gl4java.swing.GLJPanel#paint */ public void init() { @@ -613,7 +614,7 @@ public class GLJPanel extends JPanel * * @return void * - * @see GLJPanel#cvsDispose + * @see gl4java.swing.GLJPanel#cvsDispose */ public void doCleanup() { @@ -626,8 +627,8 @@ public class GLJPanel extends JPanel * * @return boolean * - * @see GLJPanel#paint - * @see GLJPanel#init + * @see gl4java.swing.GLJPanel#paint + * @see gl4java.swing.GLJPanel#init */ public boolean cvsIsInit() { @@ -662,8 +663,8 @@ public class GLJPanel extends JPanel * @param height the new height * @return void * - * @see GLJPanel#paint - * @see GLJPanel#sDisplay + * @see gl4java.swing.GLJPanel#paint + * @see gl4java.swing.GLJPanel#sDisplay */ public void reshape( int width, int height ) { @@ -689,8 +690,8 @@ public class GLJPanel extends JPanel * @param e the element, which is resized * @return void * - * @see GLJPanel#paint - * @see GLJPanel#reshape + * @see gl4java.swing.GLJPanel#paint + * @see gl4java.swing.GLJPanel#reshape */ public void componentResized(ComponentEvent e) { @@ -807,7 +808,7 @@ public class GLJPanel extends JPanel * This function calls gljDestroy of GLContext ! * * @see gl4java.GLContext#gljDestroy - * @see GLJPanel#doCleanup + * @see gl4java.swing.GLJPanel#doCleanup */ public void cvsDispose() { diff --git a/gl4java/system/GljMSJDirect.java b/gl4java/system/GljMSJDirect.java index 125d5c0..ef5986c 100644 --- a/gl4java/system/GljMSJDirect.java +++ b/gl4java/system/GljMSJDirect.java @@ -43,7 +43,7 @@ public class GljMSJDirect extends Object */ private static native void OGLWindowMsgPumpJDirect(); - public static final int createOGLWindowNative(int hwndParent, + public static final long createOGLWindowNative(long hwndParent, int x, int y, int width, int height) @@ -52,26 +52,26 @@ public class GljMSJDirect extends Object /** * @dll.import("GL4JavaGljMSJDirect", auto) */ - private static native int createOGLWindowNativeJDirect(int hwndParent, + private static native long createOGLWindowNativeJDirect(long hwndParent, int x, int y, int width, int height); - public static final void destroyOGLWindowNative(int hdc) + public static final void destroyOGLWindowNative(long hdc) { destroyOGLWindowNativeJDirect(hdc); } /** * @dll.import("GL4JavaGljMSJDirect") */ - private static native void destroyOGLWindowNativeJDirect(int hdc); + private static native void destroyOGLWindowNativeJDirect(long hdc); - public static final void moveOGLWindowNative(int hdc, int x, int y, int width, int height) + public static final void moveOGLWindowNative(long hdc, int x, int y, int width, int height) { moveOGLWindowNativeJDirect(hdc, x, y, width, height); } /** * @dll.import("GL4JavaGljMSJDirect") */ - private static native void moveOGLWindowNativeJDirect(int hdc, int x, int y, int width, int height); + private static native void moveOGLWindowNativeJDirect(long hdc, int x, int y, int width, int height); } diff --git a/gl4java/utils/Test.java b/gl4java/utils/Test.java index addc706..a430de5 100644 --- a/gl4java/utils/Test.java +++ b/gl4java/utils/Test.java @@ -55,7 +55,7 @@ public class Test Dimension ps = glSAnimApplet.getPreferredSize(); f.setBounds(-100,-100,99,99); f.setVisible(true); - f.setVisible(false); + //f.setVisible(false); Insets i = f.getInsets(); f.setBounds(0,0, ps.width+i.left+i.right, diff --git a/gl4java/utils/glut/GLUTFuncLightImpl.java b/gl4java/utils/glut/GLUTFuncLightImpl.java index 0d75311..6f546aa 100644 --- a/gl4java/utils/glut/GLUTFuncLightImpl.java +++ b/gl4java/utils/glut/GLUTFuncLightImpl.java @@ -267,7 +267,7 @@ implements GLUTFunc, GLEnum, GLUEnum protected GLFunc gl = null; protected GLUFunc glu = null; - protected int quadObj=0; + protected long quadObj=0; protected final void initQuadObj() { -- cgit v1.2.3