diff options
Diffstat (limited to 'src/jogl/classes')
12 files changed, 201 insertions, 81 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java index 9a86f7d08..3f7028d56 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java @@ -40,9 +40,14 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.opengl.*; -import com.jogamp.opengl.impl.*; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLProfile; + import com.jogamp.nativewindow.impl.ProxySurface; +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR; public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { private long hwnd, hdc; diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java index 5ac937be8..f50b1a716 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java @@ -40,10 +40,19 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.opengl.*; -import javax.media.nativewindow.*; -import com.jogamp.opengl.impl.*; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; + import com.jogamp.nativewindow.impl.ProxySurface; +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.opengl.impl.GLContextShareSet; + public class WindowsExternalWGLContext extends WindowsWGLContext { private boolean firstMakeCurrent = true; diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java index ec0bd7c7a..8f41db365 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java @@ -40,10 +40,17 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.nativewindow.*; -import javax.media.opengl.*; -import com.jogamp.opengl.impl.*; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; + import com.jogamp.nativewindow.impl.ProxySurface; +import com.jogamp.nativewindow.impl.windows.GDI; public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java index f58d2f4bc..8bb781a45 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java @@ -40,9 +40,16 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.opengl.*; -import javax.media.nativewindow.*; -import com.jogamp.opengl.impl.*; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.SurfaceChangeable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; + +import com.jogamp.nativewindow.impl.windows.BITMAPINFO; +import com.jogamp.nativewindow.impl.windows.BITMAPINFOHEADER; +import com.jogamp.nativewindow.impl.windows.GDI; public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { private long origbitmap; diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java index 0198f334c..a5631aded 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -40,12 +40,20 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.opengl.*; -import javax.media.nativewindow.*; -import com.jogamp.opengl.impl.*; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.SurfaceChangeable; +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; +import javax.media.opengl.GLPbuffer; +import javax.media.opengl.GLProfile; + +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR; public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { - private long cachedParentHdc; private WGLExt cachedWGLExt; // cached WGLExt instance from parent GLCanvas, // needed to destroy pbuffer private long buffer; // pbuffer handle @@ -270,8 +278,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { // Set up instance variables buffer = tmpBuffer; ((SurfaceChangeable)ns).setSurfaceHandle(tmpHdc); - cachedWGLExt = wglExt; - cachedParentHdc = parentHdc; + cachedWGLExt = wglExt; // Re-query chosen pixel format { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java index 7be597dcc..529fda2c9 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java @@ -40,13 +40,23 @@ package com.jogamp.opengl.impl.windows.wgl; -import java.nio.*; -import java.util.*; -import javax.media.opengl.*; -import javax.media.nativewindow.*; -import com.jogamp.opengl.impl.*; +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLException; + import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.opengl.impl.GLContextImpl; +import com.jogamp.opengl.impl.GLContextShareSet; +import com.jogamp.opengl.impl.GLDrawableImpl; + public class WindowsWGLContext extends GLContextImpl { private static final Map/*<String, String>*/ functionNameMap; @@ -86,7 +96,7 @@ public class WindowsWGLContext extends GLContextImpl { wglGetExtensionsStringEXTAvailable=false; wglMakeContextCurrentInitialized=false; wglMakeContextCurrentAvailable=false; - // no inner state wglExt=null; + // no inner state _wglExt=null; wglExtProcAddressTable=null; } @@ -102,7 +112,7 @@ public class WindowsWGLContext extends GLContextImpl { } public boolean wglMakeContextCurrent(long hDrawDC, long hReadDC, long ctx) { - WGLExt wglExt = getWGLExt(); + WGLExt _wglExt = getWGLExt(); if (!wglMakeContextCurrentInitialized) { wglMakeContextCurrentAvailable = isFunctionAvailable("wglMakeContextCurrent"); wglMakeContextCurrentInitialized = true; @@ -111,7 +121,7 @@ public class WindowsWGLContext extends GLContextImpl { } } if(wglMakeContextCurrentAvailable) { - return wglExt.wglMakeContextCurrent(hDrawDC, hReadDC, ctx); + return _wglExt.wglMakeContextCurrent(hDrawDC, hReadDC, ctx); } return WGL.wglMakeCurrent(hDrawDC, ctx); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java index 984708f52..bbbd93435 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java @@ -40,23 +40,23 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.nativewindow.*; -import javax.media.opengl.*; -import com.jogamp.opengl.impl.*; -import java.security.*; +import java.security.AccessController; +import javax.media.nativewindow.NativeSurface; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; + +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.opengl.impl.Debug; +import com.jogamp.opengl.impl.GLDrawableImpl; +import com.jogamp.opengl.impl.GLDynamicLookupHelper; + public abstract class WindowsWGLDrawable extends GLDrawableImpl { - private static final int MAX_SET_PIXEL_FORMAT_FAIL_COUNT = 5; private static final boolean PROFILING = Debug.isPropertyDefined("jogl.debug.GLDrawable.profiling", true, AccessController.getContext()); private static final int PROFILING_TICKS = 200; - private int profilingLockSurfaceTicks; - private long profilingLockSurfaceTime; - private int profilingUnlockSurfaceTicks; - private long profilingUnlockSurfaceTime; private int profilingSwapBuffersTicks; private long profilingSwapBuffersTime; - public WindowsWGLDrawable(GLDrawableFactory factory, NativeSurface comp, boolean realized) { super(factory, comp, realized); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java index 64dd0eb46..462079913 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java @@ -40,19 +40,39 @@ package com.jogamp.opengl.impl.windows.wgl; -import java.nio.*; -import java.util.*; -import javax.media.nativewindow.*; -import javax.media.opengl.*; +import java.nio.Buffer; +import java.nio.ShortBuffer; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.windows.WindowsGraphicsDevice; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; + import com.jogamp.common.JogampRuntimeException; -import com.jogamp.common.util.*; -import com.jogamp.opengl.impl.*; +import com.jogamp.common.util.ReflectionUtil; import com.jogamp.nativewindow.impl.ProxySurface; -import javax.media.nativewindow.windows.WindowsGraphicsDevice; +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.opengl.impl.Debug; +import com.jogamp.opengl.impl.DesktopGLDynamicLookupHelper; +import com.jogamp.opengl.impl.GLDrawableFactoryImpl; +import com.jogamp.opengl.impl.GLDrawableImpl; +import com.jogamp.opengl.impl.GLDynamicLookupHelper; public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { - private static final boolean VERBOSE = Debug.verbose(); - private static final DesktopGLDynamicLookupHelper windowsWGLDynamicLookupHelper; static { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 619034da4..6c006577e 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -33,9 +33,22 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.nativewindow.*; -import javax.media.opengl.*; -import com.jogamp.opengl.impl.*; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsConfiguration; +import javax.media.nativewindow.NativeSurface; +import javax.media.opengl.DefaultGLCapabilitiesChooser; +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; +import javax.media.opengl.GLPbuffer; +import javax.media.opengl.GLProfile; + +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR; +import com.jogamp.opengl.impl.GLContextImpl; public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable { // Keep this under the same debug flag as the drawable factory for convenience diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index 372630446..1d8f14d94 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -33,12 +33,24 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.nativewindow.*; -import javax.media.nativewindow.windows.*; -import com.jogamp.nativewindow.impl.*; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.CapabilitiesChooser; +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; -import javax.media.opengl.*; -import com.jogamp.opengl.impl.*; +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR; /** Subclass of GraphicsConfigurationFactory used when non-AWT tookits are used on Windows platforms. Toolkits will likely need to delegate diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index f6dce1c9c..ab23e18f8 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -97,10 +97,21 @@ public abstract class GLDrawableFactory { protected static ArrayList/*<GLDrawableFactoryImpl>*/ glDrawableFactories = new ArrayList(); + // Shutdown hook mechanism for the factory + private static boolean factoryShutdownHookRegistered = false; + private static Thread factoryShutdownHook = null; + /** * Instantiate singleton factories if available, EGLES1, EGLES2 and the OS native ones. */ static { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + registerFactoryShutdownHook(); + return null; + } + }); + nativeOSType = NativeWindowFactory.getNativeWindowType(true); GLDrawableFactory tmp = null; @@ -151,15 +162,38 @@ public abstract class GLDrawableFactory { eglFactory = tmp; } - private AbstractGraphicsDevice defaultSharedDevice = null; + private static synchronized void registerFactoryShutdownHook() { + if (factoryShutdownHookRegistered) { + return; + } + factoryShutdownHook = new Thread(new Runnable() { + public void run() { + GLDrawableFactory.shutdownImpl(); + } + }); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + Runtime.getRuntime().addShutdownHook(factoryShutdownHook); + return null; + } + }); + factoryShutdownHookRegistered = true; + } - protected GLDrawableFactory() { - synchronized(glDrawableFactories) { - glDrawableFactories.add(this); + private static synchronized void unregisterFactoryShutdownHook() { + if (!factoryShutdownHookRegistered) { + return; } + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + Runtime.getRuntime().removeShutdownHook(factoryShutdownHook); + return null; + } + }); + factoryShutdownHookRegistered = false; } - protected static void shutdown() { + private static void shutdownImpl() { synchronized(glDrawableFactories) { for(int i=0; i<glDrawableFactories.size(); i++) { GLDrawableFactory factory = (GLDrawableFactory) glDrawableFactories.get(i); @@ -169,6 +203,24 @@ public abstract class GLDrawableFactory { } } + protected static void shutdown() { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + unregisterFactoryShutdownHook(); + return null; + } + }); + shutdownImpl(); + } + + private AbstractGraphicsDevice defaultSharedDevice = null; + + protected GLDrawableFactory() { + synchronized(glDrawableFactories) { + glDrawableFactories.add(this); + } + } + protected abstract void shutdownInstance(); /** diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 878c4024e..02252ac33 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -103,7 +103,6 @@ public class GLProfile { // since this skips checking further access AccessController.doPrivileged(new PrivilegedAction() { public Object run() { - registerFactoryShutdownHook(); initProfilesForDefaultDevices(firstUIActionOnProcess); return null; } @@ -122,8 +121,9 @@ public class GLProfile { /** * Manual shutdown method, may be called after your last JOGL use * within the running JVM.<br> - * This method is called via the JVM shutdown hook.<br> * It releases all temporary created resources, ie issues {@link javax.media.opengl.GLDrawableFactory#shutdown()}.<br> + * The shutdown implementation is called via the JVM shutdown hook, if not manually invoked here.<br> + * Invoke <code>shutdown()</code> manually is recommended, due to the unreliable JVM state within the shutdown hook.<br> */ public static synchronized void shutdown() { if(initialized) { @@ -1065,10 +1065,6 @@ public class GLProfile { static boolean initialized = false; - // Shutdown hook mechanism for the factory - private static boolean factoryShutdownHookRegistered = false; - private static Thread factoryShutdownHook = null; - /** * Tries the profiles implementation and native libraries. * Throws an GLException if no profile could be found at all. @@ -1299,24 +1295,6 @@ public class GLProfile { return defaultEGLDevice; } - private static synchronized void registerFactoryShutdownHook() { - if (factoryShutdownHookRegistered) { - return; - } - factoryShutdownHook = new Thread(new Runnable() { - public void run() { - GLDrawableFactory.shutdown(); - } - }); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - Runtime.getRuntime().addShutdownHook(factoryShutdownHook); - return null; - } - }); - factoryShutdownHookRegistered = true; - } - private static void validateInitialization() { if(!initialized) { synchronized(GLProfile.class) { |