summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java5
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java13
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java18
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java9
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java10
5 files changed, 40 insertions, 15 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
index 897d3fcaf..34bb8704a 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
@@ -143,9 +143,10 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
// layered surface -> Offscreen/[FBO|PBuffer]
final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable();
chosenCapsMod.setOnscreen(false);
- if( isFBOAvailable ) {
+ /* if( isFBOAvailable ) { // FIXME JAU: FBO n/a yet
chosenCapsMod.setFBO(true);
- } else if(canCreateGLPbuffer(adevice)) {
+ } else */
+ if( canCreateGLPbuffer(adevice) ) {
chosenCapsMod.setPBuffer(true);
} else {
chosenCapsMod.setFBO(false);
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index cb79e1560..82525cfde 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -444,9 +444,10 @@ public abstract class MacOSXCGLContext extends GLContextImpl
throw new RuntimeException("Anonymous drawable instance's handle not of type NSView: "+drawable.getClass().getName()+", "+drawable);
}
}
- final NativeSurface surface = drawable.getNativeSurface();
+ final NativeSurface surface = drawable.getNativeSurface();
final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration();
final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true);
+
boolean allowIncompleteView = null != backingLayerHost;
if( !allowIncompleteView && surface instanceof ProxySurface ) {
allowIncompleteView = 0 != ( ProxySurface.INVISIBLE_WINDOW & ((ProxySurface)surface).getImplBitfield() ) ;
@@ -519,10 +520,10 @@ public abstract class MacOSXCGLContext extends GLContextImpl
texWidth = drawable.getWidth();
texHeight = drawable.getHeight();
}
- nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, drawable.getHandle(), fixedCaps.isBackgroundOpaque(), texWidth, texHeight);
if(0>=texWidth || 0>=texHeight || !drawable.isRealized()) {
throw new GLException("Drawable not realized yet or invalid texture size, texSize "+texWidth+"x"+texHeight+", "+drawable);
}
+ nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, drawable.getHandle(), fixedCaps.isBackgroundOpaque(), texWidth, texHeight);
if (DEBUG) {
System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer)+", texSize "+texWidth+"x"+texHeight+", "+drawable);
}
@@ -545,11 +546,11 @@ public abstract class MacOSXCGLContext extends GLContextImpl
System.err.println("NS destroy nsOpenGLLayer "+toHexString(nsOpenGLLayer));
}
final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(surface, true);
- if(null == ols) {
- throw new InternalError("XXX: "+ols);
+ if(null != ols && ols.isSurfaceLayerAttached()) {
+ // still having a valid OLS attached to surface (parent OLS could have been removed)
+ ols.detachSurfaceLayer();
}
- CGL.releaseNSOpenGLLayer(nsOpenGLLayer);
- ols.detachSurfaceLayer(nsOpenGLLayer);
+ CGL.releaseNSOpenGLLayer(nsOpenGLLayer);
CGL.deletePixelFormat(nsOpenGLLayerPFmt);
nsOpenGLLayerPFmt = 0;
nsOpenGLLayer = 0;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index cffe495f7..d4b927cf1 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -81,6 +81,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
protected long drawable;
protected Rectangle bounds;
protected Insets insets;
+ private long offscreenSurfaceLayer;
private long drawable_old;
@@ -106,6 +107,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
invalidate();
this.component = windowObject;
this.isApplet = false;
+ this.offscreenSurfaceLayer = 0;
}
@Override
@@ -196,6 +198,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
System.err.println("JAWTWindow.attachSurfaceHandle(): 0x"+Long.toHexString(layerHandle) + ", bounds "+bounds);
}
attachSurfaceLayerImpl(layerHandle);
+ offscreenSurfaceLayer = layerHandle;
} finally {
unlockSurface();
}
@@ -206,25 +209,34 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
* {@inheritDoc}
*/
@Override
- public final void detachSurfaceLayer(final long layerHandle) throws NativeWindowException {
+ public final void detachSurfaceLayer() throws NativeWindowException {
if( !isOffscreenLayerSurfaceEnabled() ) {
throw new java.lang.UnsupportedOperationException("Not an offscreen layer surface");
}
+ if( 0 == offscreenSurfaceLayer) {
+ throw new NativeWindowException("No offscreen layer attached: "+this);
+ }
int lockRes = lockSurface();
if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
throw new NativeWindowException("Could not lock (offscreen layer): "+this);
}
try {
if(DEBUG) {
- System.err.println("JAWTWindow.detachSurfaceHandle(): 0x"+Long.toHexString(layerHandle));
+ System.err.println("JAWTWindow.detachSurfaceHandle(): 0x"+Long.toHexString(offscreenSurfaceLayer));
}
- detachSurfaceLayerImpl(layerHandle);
+ detachSurfaceLayerImpl(offscreenSurfaceLayer);
+ offscreenSurfaceLayer = 0;
} finally {
unlockSurface();
}
}
protected abstract void detachSurfaceLayerImpl(final long layerHandle);
+ @Override
+ public final boolean isSurfaceLayerAttached() {
+ return 0 != offscreenSurfaceLayer;
+ }
+
//
// SurfaceUpdateListener
//
diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java
index dd36509ba..f7dbc6c27 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java
@@ -42,7 +42,12 @@ public interface OffscreenLayerSurface {
* Detaches a previously attached offscreen layer from this offscreen layer surface.
* @see #attachSurfaceLayer(long)
* @see #isOffscreenLayerSurfaceEnabled()
- * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
+ * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
+ * or no surface layer is attached.
*/
- public void detachSurfaceLayer(final long layerHandle) throws NativeWindowException;
+ public void detachSurfaceLayer() throws NativeWindowException;
+
+ /** Returns true if a surface layer is attached, otherwise false. */
+ public boolean isSurfaceLayerAttached();
+
}
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 9af4a02ae..cd0e9aab6 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -42,7 +42,9 @@ import java.security.PrivilegedAction;
import java.util.Set;
import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.OffscreenLayerOption;
+import javax.media.nativewindow.OffscreenLayerSurface;
import javax.media.nativewindow.WindowClosingProtocol;
import javax.swing.MenuSelectionManager;
@@ -368,6 +370,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
if(DEBUG) {
System.err.println("NewtCanvasAWT.removeNotify: "+newtChild+", from "+cont);
}
+ final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true);
+ if(null != ols && ols.isSurfaceLayerAttached()) {
+ ols.detachSurfaceLayer();
+ }
reparentWindow(false, cont);
super.removeNotify();
}
@@ -413,7 +419,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
// since this it is completely covered by the newtChild (z-order).
setFocusable(true);
} else {
- configureNewtChild(false);
+ configureNewtChild(false);
newtChild.setVisible(false);
newtChild.reparentWindow(null);
if(null != jawtWindow) {
@@ -445,7 +451,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
NewtFactoryAWT.destroyNativeWindow(jawtWindow);
jawtWindow=null;
}
- newtChild.setVisible(false);
+ newtChild.setVisible(false);
newtChild.reparentWindow(null);
newtChild.destroy();
newtChild=null;