From 32790c376583beccd030eecd7c56cbe66d380172 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 20 Apr 2010 11:46:26 +0200 Subject: JOGL GL4 preperation (cont): - All available OpenGL versions (native/platform) are verified at GLProfile initialization and can be queried .. A mapping of major,compat -> major,minor,options is created. - Removal of temp context creation, when creating a context. This was necessary to query general availability of ARB_create_context. Due to the shared context of X11GLXDrawableFactory and WindowsWGLDrawableFactory, this is no more necessary. Due to the version mapping, the ARB_create_context paramters are known. - NativeWindow X11Lib: Added X11ErrorHandler, throwing a RuntimeException. Necessary to catch BadMatch .. etc X11 errors, eg for glXCreateContextAttribsARB Hence all X11 calls are covered now. - X11DummyGLXDrawable needs to use an own Window, otherwise GLn n>2 fails - Flattening the desktop GL* implementation, all use GL4bcImpl, which reduces the footprint dramatically. - GL*Impl.isGL*() (desktop) utilizes the GLContext.isGL*(), hence the results reflect the actual native context version. - GLContextImpl makeCurrent/create: Added workflow documentation, clarified code, defined abstract methods to have a protocol. - Removed moved files (from here to gluegen), see gluegen a01cb3d59715a41153380f1977ec75263b762dc6 - NativeLibLoader -> JNILibLoader - Fixed Exception Handling (as in gluegen bce53b52c8638729750c4286dbc04cb14329fd34), ie removed empty catch Throwable .. - GLContext.setSwapInterval(): Nop in offscreen case, otherwise X11IOError (NVIDIA Bug) Test: Tests - Junit - demos.gears.Gears - demos.jrefract.JRefract Platforms - Linux 64/32 ATI/NVidia - MacOsX - Windows (virtualbox 3.1.6, offscreen failed) TODO/BUGS: - FIXME ATI GLn n>2 with AWT, can't make context current, works well on NVIDIA though - FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available! - Add GL 3.3 to GL3/gl3ext.h - Add GL 4.0 to GL3/gl3ext.h and fix the GL3/GL4 seperation - Rename jogl.gl2.jar -> jogl.gldesktop.jar (as done with it's native lib already) --- src/newt/classes/com/jogamp/newt/NewtFactory.java | 2 +- src/newt/classes/com/jogamp/newt/Window.java | 5 +- .../com/jogamp/newt/impl/NEWTJNILibLoader.java | 62 ++++++++++++++++++++++ .../com/jogamp/newt/impl/NativeLibLoader.java | 62 ---------------------- .../classes/com/jogamp/newt/intel/gdl/Display.java | 2 +- .../classes/com/jogamp/newt/macosx/MacDisplay.java | 2 +- .../jogamp/newt/opengl/broadcom/egl/Display.java | 2 +- .../com/jogamp/newt/opengl/kd/KDDisplay.java | 2 +- .../classes/com/jogamp/newt/util/MainThread.java | 6 +-- .../com/jogamp/newt/windows/WindowsDisplay.java | 2 +- .../classes/com/jogamp/newt/x11/X11Display.java | 2 +- 11 files changed, 74 insertions(+), 75 deletions(-) create mode 100644 src/newt/classes/com/jogamp/newt/impl/NEWTJNILibLoader.java delete mode 100644 src/newt/classes/com/jogamp/newt/impl/NativeLibLoader.java (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 2a696aa07..2d5c10c52 100755 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -36,7 +36,7 @@ package com.jogamp.newt; import javax.media.nativewindow.*; import java.util.ArrayList; import java.util.Iterator; -import com.jogamp.nativewindow.impl.jvm.JVMUtil; +import com.jogamp.common.jvm.JVMUtil; public abstract class NewtFactory { // Work-around for initialization order problems on Mac OS X diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 8f09ae364..5123ab19f 100755 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -36,8 +36,8 @@ package com.jogamp.newt; import com.jogamp.newt.impl.Debug; import com.jogamp.newt.util.EDTUtil; +import com.jogamp.common.util.*; import javax.media.nativewindow.*; -import com.jogamp.nativewindow.impl.NWReflection; import java.util.ArrayList; import java.util.Iterator; @@ -127,7 +127,7 @@ public abstract class Window implements NativeWindow if ( argsChecked < cstrArguments.length ) { throw new NativeWindowException("WindowClass "+windowClass+" constructor mismatch at argument #"+argsChecked+"; Constructor: "+getTypeStrList(cstrArgumentTypes)+", arguments: "+getArgsStrList(cstrArguments)); } - Window window = (Window) NWReflection.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ; + Window window = (Window) ReflectionUtil.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ; window.invalidate(); window.screen = screen; window.setUndecorated(undecorated); @@ -144,7 +144,6 @@ public abstract class Window implements NativeWindow } return window; } catch (Throwable t) { - t.printStackTrace(); throw new NativeWindowException(t); } } diff --git a/src/newt/classes/com/jogamp/newt/impl/NEWTJNILibLoader.java b/src/newt/classes/com/jogamp/newt/impl/NEWTJNILibLoader.java new file mode 100644 index 000000000..a4d234fd5 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/impl/NEWTJNILibLoader.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.jogamp.newt.impl; + +// FIXME: refactor Java SE dependencies +//import java.awt.Toolkit; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.HashSet; +import com.jogamp.common.jvm.JNILibLoaderBase; + +public class NEWTJNILibLoader extends JNILibLoaderBase { + + public static void loadNEWT() { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + loadLibrary("newt", null, true); + return null; + } + }); + } + +} diff --git a/src/newt/classes/com/jogamp/newt/impl/NativeLibLoader.java b/src/newt/classes/com/jogamp/newt/impl/NativeLibLoader.java deleted file mode 100644 index 52e4c0dc3..000000000 --- a/src/newt/classes/com/jogamp/newt/impl/NativeLibLoader.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package com.jogamp.newt.impl; - -// FIXME: refactor Java SE dependencies -//import java.awt.Toolkit; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.HashSet; -import com.jogamp.nativewindow.impl.NativeLibLoaderBase; - -public class NativeLibLoader extends NativeLibLoaderBase { - - public static void loadNEWT() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - loadLibrary("newt", null, true); - return null; - } - }); - } - -} diff --git a/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java b/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java index eb93943ee..a3e5501c4 100644 --- a/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java +++ b/src/newt/classes/com/jogamp/newt/intel/gdl/Display.java @@ -40,7 +40,7 @@ public class Display extends com.jogamp.newt.Display { static int initCounter = 0; static { - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); if (!Screen.initIDs()) { throw new NativeWindowException("Failed to initialize GDL Screen jmethodIDs"); diff --git a/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java b/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java index 2f86125f8..0b5297685 100755 --- a/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java +++ b/src/newt/classes/com/jogamp/newt/macosx/MacDisplay.java @@ -41,7 +41,7 @@ import com.jogamp.newt.util.MainThread; public class MacDisplay extends Display { static { - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); if(!initNSApplication()) { throw new NativeWindowException("Failed to initialize native Application hook"); diff --git a/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java index a375181ac..999a407ec 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java +++ b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java @@ -41,7 +41,7 @@ import javax.media.nativewindow.egl.*; public class Display extends com.jogamp.newt.Display { static { - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); if (!Window.initIDs()) { throw new NativeWindowException("Failed to initialize BCEGL Window jmethodIDs"); diff --git a/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java b/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java index b09568237..6a28f992b 100755 --- a/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java +++ b/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java @@ -42,7 +42,7 @@ import javax.media.nativewindow.egl.*; public class KDDisplay extends Display { static { - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); if (!KDWindow.initIDs()) { throw new NativeWindowException("Failed to initialize KDWindow jmethodIDs"); diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java index 6cd4f8c69..daa09edce 100644 --- a/src/newt/classes/com/jogamp/newt/util/MainThread.java +++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java @@ -43,10 +43,10 @@ import java.security.*; import javax.media.nativewindow.*; +import com.jogamp.common.util.*; import com.jogamp.newt.*; import com.jogamp.newt.impl.*; import com.jogamp.newt.macosx.MacDisplay; -import com.jogamp.nativewindow.impl.NWReflection; /** * NEWT Utility class MainThread

@@ -116,7 +116,7 @@ public class MainThread { // start user app .. try { - Class mainClass = NWReflection.getClass(mainClassName, true); + Class mainClass = ReflectionUtil.getClass(mainClassName, true); if(null==mainClass) { throw new RuntimeException(new ClassNotFoundException("MainThread couldn't find main class "+mainClassName)); } @@ -159,7 +159,7 @@ public class MainThread { System.arraycopy(args, 1, mainClassArgs, 0, args.length-1); } - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); shouldStop = false; tasks = new ArrayList(); diff --git a/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java b/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java index 05cab1a0a..281022901 100755 --- a/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java +++ b/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java @@ -45,7 +45,7 @@ public class WindowsDisplay extends Display { private static long hInstance; static { - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); if (!WindowsWindow.initIDs()) { throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs"); diff --git a/src/newt/classes/com/jogamp/newt/x11/X11Display.java b/src/newt/classes/com/jogamp/newt/x11/X11Display.java index 5fd6d9640..c8faefbf1 100755 --- a/src/newt/classes/com/jogamp/newt/x11/X11Display.java +++ b/src/newt/classes/com/jogamp/newt/x11/X11Display.java @@ -41,7 +41,7 @@ import com.jogamp.nativewindow.impl.x11.X11Util; public class X11Display extends Display { static { - NativeLibLoader.loadNEWT(); + NEWTJNILibLoader.loadNEWT(); if (!initIDs()) { throw new NativeWindowException("Failed to initialize X11Display jmethodIDs"); -- cgit v1.2.3