aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-11-12 16:15:54 +0100
committerSven Gothel <[email protected]>2011-11-12 16:15:54 +0100
commit8a16d590fe2c739badbabe4906cbe9d60b20e2b9 (patch)
tree57d7c0794437d2025aae7c29b340af952b5043bb /src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
parent33aaa037e31ec7d411f4acaeea63a383037f027d (diff)
OS X Layered View Part8: Generalize OffscreenLayerSurface ; Use local JAWT instance ; Applet's on OS X are working
Generalize OffscreenLayerSurface - Using new OffscreenLayerSurface allows using this functionality in a clean manner, ie. no 'dirty' usage of MacOSXJAWTWindow in a JOGL GL class. - 'Promoting' OffscreenLayerSurface functionality to JAWTWindow and it's handling to GLDrawableFactoryImpl::createGLDrawable(). - Move MacOSXCGLDrawableFactory's "MacOSXJAWTWindow getLayeredSurfaceHost(NativeSurface surface)" to NativeWindowFactory "OffscreenLayerSurface getOffscreenLayerSurface(NativeSurface surface, boolean ifEnabled)" Use local JAWT instance - Only w/ a local JAWT instance per JAWTWindow it is possible to switch between offscreen-layer and onscreen. We also have to determing offscreen-layer lazy at surface lock, since only at that time we have knowledge whether it's an Applet or not. +++ ContextUpdater: Use local pthread mutex, add DEBUG output JAWTWindow/NewtCanvasAWT: Adding methods to request offscreen-layer-surface (if supported), besides 'if applet' this may trigger the new functionality. +++ Applet's on OS X are working: - OS X 10.6.4 - Safari: - Hangs for a while at start .. whole screen freezes .. approx. 10s - Sometimes crashes when Applet stops - after all our resources are released! - Keyboard input isn't assigned sometimes. - Otherwise .. works well, incl. offscreen/onscreen parenting - Firefox 8.0: - Hangs for a while at start .. whole screen freezes .. approx. 10s - Sometimes crashes when Applet stops - after all our resources are released! - Keyboard input is never assigned. - Otherwise .. works well, incl. offscreen/onscreen parenting - OS X 10.7 - Safari: - Sometimes crashes when Applet stops - after all our resources are released! - Keyboard input isn't assigned sometimes. - Otherwise .. works well, incl. offscreen/onscreen parenting - Firefox 8.0: - Sometimes crashes when Applet stops - after all our resources are released! - Keyboard input is never assigned. - Otherwise .. works well, incl. offscreen/onscreen parenting
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java60
1 files changed, 48 insertions, 12 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
index 704f71457..4f0b11789 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
@@ -40,9 +40,26 @@
package jogamp.opengl;
-import java.nio.*;
-import javax.media.nativewindow.*;
-import javax.media.opengl.*;
+import java.nio.Buffer;
+
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.OffscreenLayerSurface;
+import javax.media.nativewindow.ProxySurface;
+import javax.media.nativewindow.SurfaceChangeable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+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 javax.media.opengl.Threading;
+
+import jogamp.nativewindow.MutableGraphicsConfiguration;
import com.jogamp.common.util.VersionNumber;
@@ -103,24 +120,43 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
+ final MutableGraphicsConfiguration config = (MutableGraphicsConfiguration) target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
AbstractGraphicsDevice adevice = config.getScreen().getDevice();
GLDrawable result = null;
adevice.lock();
try {
- if(caps.isOnscreen()) {
- if(DEBUG) {
- System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable: "+target);
+ if(chosenCaps.isOnscreen()) {
+ // onscreen
+ final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(target, true);
+ if(null == ols) {
+ // traditional onscreen
+ if(DEBUG) {
+ System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable: "+target);
+ }
+ result = createOnscreenDrawableImpl(target);
+ } else {
+ // layered surface -> offscreen/PBuffer
+ final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable();
+ chosenCapsMod.setOnscreen(false);
+ chosenCapsMod.setPBuffer(canCreateGLPbuffer(adevice));
+ config.setChosenCapabilities(chosenCapsMod);
+ if(DEBUG) {
+ System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable -> Offscreen-Layer: "+target);
+ }
+ if( ! ( target instanceof SurfaceChangeable ) ) {
+ throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen layered surface: "+target);
+ }
+ result = createOffscreenDrawableImpl(target);
}
- result = createOnscreenDrawableImpl(target);
} else {
+ // offscreen
+ if(DEBUG) {
+ System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable (PBuffer: "+chosenCaps.isPBuffer()+"): "+target);
+ }
if( ! ( target instanceof SurfaceChangeable ) ) {
throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen: "+target);
}
- if(DEBUG) {
- System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable (PBuffer: "+caps.isPBuffer()+"): "+target);
- }
result = createOffscreenDrawableImpl(target);
}
} finally {