diff options
4 files changed, 40 insertions, 29 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index deb187372..9aa6ce3cc 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -49,6 +49,7 @@ import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.UpstreamSurfaceHook; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -187,8 +188,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { throw new IllegalArgumentException("Passed NativeSurface must implement MutableSurface for offscreen: "+target); } if( chosenCaps.isFBO() && isFBOAvailable ) { - // need to hook-up a native dummy surface since source may not have - final ProxySurface dummySurface = createDummySurfaceImpl(adevice, false, chosenCaps, (GLCapabilitiesImmutable)config.getRequestedCapabilities(), null, 64, 64); + // need to hook-up a native dummy surface since source may not have & use minimum GLCapabilities for it w/ same profile + final ProxySurface dummySurface = createDummySurfaceImpl(adevice, false, new GLCapabilities(chosenCaps.getGLProfile()), (GLCapabilitiesImmutable)config.getRequestedCapabilities(), null, 64, 64); dummySurface.setUpstreamSurfaceHook(new DelegatedUpstreamSurfaceHookWithSurfaceSize(dummySurface.getUpstreamSurfaceHook(), target)); result = createFBODrawableImpl(dummySurface, chosenCaps, 0); } else { @@ -299,8 +300,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if( capsChosen.isFBO() ) { device.lock(); try { - final ProxySurface dummySurface = createDummySurfaceImpl(device, true, capsChosen, capsRequested, null, width, height); - final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); + // Use minimum GLCapabilities for the dummy surface w/ same profile + final ProxySurface dummySurface = createDummySurfaceImpl(device, true, new GLCapabilities(capsChosen.getGLProfile()), capsRequested, null, width, height); + final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); return new GLFBODrawableImpl.ResizeableImpl(this, dummyDrawable, dummySurface, capsChosen, 0); } finally { device.unlock(); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index 311690f1d..13960ecdd 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -54,13 +54,15 @@ import javax.media.opengl.GLProfile; public abstract class GLDrawableImpl implements GLDrawable { protected static final boolean DEBUG = Debug.debug("GLDrawable"); - protected GLDrawableImpl(GLDrawableFactory factory, - NativeSurface comp, - boolean realized) { + protected GLDrawableImpl(GLDrawableFactory factory, NativeSurface comp, boolean realized) { + this(factory, comp, (GLCapabilitiesImmutable) comp.getGraphicsConfiguration().getRequestedCapabilities(), realized); + } + + protected GLDrawableImpl(GLDrawableFactory factory, NativeSurface comp, GLCapabilitiesImmutable requestedCapabilities, boolean realized) { this.factory = factory; this.surface = comp; this.realized = realized; - this.requestedCapabilities = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getRequestedCapabilities(); + this.requestedCapabilities = requestedCapabilities; } /** diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index 2620fb1c7..0a8a55ff3 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -38,6 +38,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { protected static final boolean DEBUG = GLDrawableImpl.DEBUG || Debug.debug("FBObject"); private final GLDrawableImpl parent; + private GLCapabilitiesImmutable origParentChosenCaps; private boolean initialized; private int texUnit; @@ -58,20 +59,20 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { public void swapBuffers(boolean doubleBuffered); } + /** + * @param factory + * @param parent + * @param surface + * @param fboCaps the requested FBO capabilities + * @param textureUnit + */ protected GLFBODrawableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, NativeSurface surface, GLCapabilitiesImmutable fboCaps, int textureUnit) { - super(factory, surface, false); + super(factory, surface, fboCaps, false); this.initialized = false; - // Replace the chosen caps of dummy-surface w/ it's clone and copied values of orig FBO caps request. - // The dummy-surface has already been configured, hence value replace is OK - // and due to cloning, the native GLCapability portion is being preserved. - final MutableGraphicsConfiguration msConfig = (MutableGraphicsConfiguration) surface.getGraphicsConfiguration(); - final GLCapabilities fboCapsNative = (GLCapabilities) msConfig.getChosenCapabilities().cloneMutable(); - fboCapsNative.copyFrom(fboCaps); - msConfig.setChosenCapabilities(fboCapsNative); - this.parent = parent; + this.origParentChosenCaps = (GLCapabilitiesImmutable) getChosenGLCapabilities(); // just to avoid null, will be reset at initialize(..) this.texUnit = textureUnit; this.samples = fboCaps.getNumSamples(); @@ -81,8 +82,13 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { this.swapBufferContext = null; } - private final void initialize(boolean realize, GL gl) { + private final void initialize(boolean realize, GL gl) { + final MutableGraphicsConfiguration msConfig = (MutableGraphicsConfiguration) surface.getGraphicsConfiguration(); if(realize) { + origParentChosenCaps = (GLCapabilitiesImmutable) msConfig.getChosenCapabilities(); + final GLCapabilities chosenFBOCaps = (GLCapabilities) origParentChosenCaps.cloneMutable(); + chosenFBOCaps.copyFrom(getRequestedGLCapabilities()); + final int maxSamples = gl.getMaxRenderbufferSamples(); { final int newSamples = samples <= maxSamples ? samples : maxSamples; @@ -92,11 +98,10 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { samples = newSamples; } - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); final int fbosN; if(samples > 0) { fbosN = 1; - } else if( caps.getDoubleBuffered() ) { + } else if( chosenFBOCaps.getDoubleBuffered() ) { fbosN = bufferCount; } else { fbosN = 1; @@ -113,11 +118,11 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { throw new InternalError("Sample number mismatch: "+samples+", fbos["+i+"] "+fbos[i]); } if(samples > 0) { - fbos[i].attachColorbuffer(gl, 0, caps.getAlphaBits()>0); + fbos[i].attachColorbuffer(gl, 0, chosenFBOCaps.getAlphaBits()>0); } else { - fbos[i].attachTexture2D(gl, 0, caps.getAlphaBits()>0); + fbos[i].attachTexture2D(gl, 0, chosenFBOCaps.getAlphaBits()>0); } - if( caps.getStencilBits() > 0 ) { + if( chosenFBOCaps.getStencilBits() > 0 ) { fbos[i].attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, 24); } else { fbos[i].attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); @@ -125,9 +130,9 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { } fbos[fboIFront].resetSamplingSink(gl); fboBound = false; - final GLCapabilities fboCapsNative = (GLCapabilities) surface.getGraphicsConfiguration().getChosenCapabilities(); - fbos[0].formatToGLCapabilities(fboCapsNative); - fboCapsNative.setDoubleBuffered( fboCapsNative.getDoubleBuffered() || samples > 0 ); + fbos[0].formatToGLCapabilities(chosenFBOCaps); + chosenFBOCaps.setDoubleBuffered( chosenFBOCaps.getDoubleBuffered() || samples > 0 ); + msConfig.setChosenCapabilities(chosenFBOCaps); initialized = true; } else { @@ -139,6 +144,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { fbos=null; fboBound = false; pendingFBOReset = -1; + msConfig.setChosenCapabilities(origParentChosenCaps); } if(DEBUG) { System.err.println("GLFBODrawableImpl.initialize("+realize+"): "+this); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java index 1f5ac9b8a..51f9cc411 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java @@ -98,8 +98,9 @@ public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase { // Check caps of GLDrawable after realization final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities(); - System.out.println("Chosen GL Caps(1): "+chosenGLCaps); System.out.println("Chosen GL CTX (1): "+glad.getContext().getGLVersion()); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + System.out.println("Chosen GL Caps(2): "+glad.getNativeSurface().getGraphicsConfiguration().getChosenCapabilities()); Assert.assertNotNull(chosenGLCaps); Assert.assertTrue(chosenGLCaps.getGreenBits()>5); @@ -161,7 +162,7 @@ public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase { if(null != f) { System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); } - } + } @Test public void testGL2OffScreenAutoDblBuf() throws InterruptedException { @@ -188,7 +189,7 @@ public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase { reqGLCaps.setFBO(true); reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); - } + } @Test public void testGL2OffScreenFBOStencil() throws InterruptedException { |