summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-10-05 18:46:16 +0200
committerSven Gothel <[email protected]>2012-10-05 18:46:16 +0200
commitbab6160df764871f6fa4db040362976f028d015b (patch)
tree5b0cd475d496b883e77fb4ae1f4b7137e49ef74d /src
parented7d5f2e3fc696d47b10c8d62a071643bf385588 (diff)
Refine ed7d5f2e3fc696d47b10c8d62a071643bf385588, set and restore FBO caps @ setRealized(true/false) already, refine at initialize(true)
Allowing to validate the on-/offscreen state after setRealized(true). Adding comment in GLFBODrawable.
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLFBODrawable.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java19
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java53
3 files changed, 48 insertions, 28 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java
index 45fd3b686..079d9af5c 100644
--- a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java
@@ -39,7 +39,9 @@ import com.jogamp.opengl.FBObject.TextureAttachment;
*
* <p>
* A {@link GLFBODrawable} is uninitialized until a {@link GLContext} is bound
- * and made current the first time.
+ * and made current the first time, hence only then it's capabilities <i>fully</i> reflect expectations,
+ * i.e. color, depth, stencil and MSAA bits will be <i>valid</i> only after the first {@link GLContext#makeCurrent() makeCurrent()} call.
+ * On-/offscreen bits are <i>valid</i> after {@link #setRealized(boolean) setRealized(true)}.
* </p>
*
* <p>
diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
index 0a8a55ff3..f14c7e5e7 100644
--- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
@@ -83,11 +83,8 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
}
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 GLCapabilities chosenFBOCaps = (GLCapabilities) getChosenGLCapabilities(); // cloned at setRealized(true)
final int maxSamples = gl.getMaxRenderbufferSamples();
{
@@ -132,7 +129,6 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
fboBound = false;
fbos[0].formatToGLCapabilities(chosenFBOCaps);
chosenFBOCaps.setDoubleBuffered( chosenFBOCaps.getDoubleBuffered() || samples > 0 );
- msConfig.setChosenCapabilities(chosenFBOCaps);
initialized = true;
} else {
@@ -144,7 +140,6 @@ 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);
@@ -281,7 +276,17 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
@Override
protected final void setRealizedImpl() {
- parent.setRealized(realized);
+ final MutableGraphicsConfiguration msConfig = (MutableGraphicsConfiguration) surface.getGraphicsConfiguration();
+ if(realized) {
+ parent.setRealized(true);
+ origParentChosenCaps = (GLCapabilitiesImmutable) msConfig.getChosenCapabilities();
+ final GLCapabilities chosenFBOCaps = (GLCapabilities) origParentChosenCaps.cloneMutable();
+ chosenFBOCaps.copyFrom(getRequestedGLCapabilities());
+ msConfig.setChosenCapabilities(chosenFBOCaps);
+ } else {
+ msConfig.setChosenCapabilities(origParentChosenCaps);
+ parent.setRealized(false);
+ }
}
@Override
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java
index 829739caa..d9e9b2bf3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java
@@ -119,34 +119,47 @@ public class TestGLAutoDrawableDelegateOnOffscrnCapsNEWT extends UITestCase {
System.out.println("Window Caps PostGL : "+window.getGraphicsConfiguration().getChosenCapabilities());
System.out.println("Drawable Post-GL(1): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName());
-
- // Check caps of GLDrawable after realization
- final GLCapabilitiesImmutable chosenGLCaps = drawable.getChosenGLCapabilities();
- System.out.println("Chosen GL Caps(1): "+chosenGLCaps);
- Assert.assertNotNull(chosenGLCaps);
- Assert.assertTrue(chosenGLCaps.getGreenBits()>5);
- Assert.assertTrue(chosenGLCaps.getBlueBits()>5);
- Assert.assertTrue(chosenGLCaps.getRedBits()>5);
- Assert.assertTrue(chosenGLCaps.getDepthBits()>4);
- Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen());
- Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO());
- Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer());
- Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap());
- /** Single/Double buffer cannot be checked since result may vary ..
- if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) {
- // dbl buffer may be disabled w/ offscreen pbuffer and bitmap
- Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered());
- } */
- GLContext context = drawable.createContext(null);
+ // Note: FBO Drawable realization happens at 1st context.makeCurrent(),
+ // and hence only then it's caps can _fully_ reflect expectations,
+ // i.e. depth, stencil and MSAA will be valid only after makeCurrent(),
+ // where on-/offscreen state after setRealized(true)
+ // See GLFBODrawable API doc in this regard!
+
+
+ final GLCapabilitiesImmutable chosenGLCaps01 = drawable.getChosenGLCapabilities();
+ System.out.println("Chosen GL Caps(1): "+chosenGLCaps01);
+ Assert.assertNotNull(chosenGLCaps01);
+ Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps01.isOnscreen());
+ Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps01.isFBO());
+ Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps01.isPBuffer());
+ Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps01.isBitmap());
+
+ final GLContext context = drawable.createContext(null);
Assert.assertNotNull(context);
int res = context.makeCurrent();
Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res);
context.release();
- System.out.println("Chosen GL Caps(2): "+drawable.getChosenGLCapabilities());
+ // Check caps of GLDrawable after realization
+ final GLCapabilitiesImmutable chosenGLCaps02 = drawable.getChosenGLCapabilities();
+ System.out.println("Chosen GL Caps(2): "+chosenGLCaps02);
System.out.println("Chosen GL CTX (2): "+context.getGLVersion());
System.out.println("Drawable Post-GL(2): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName());
+ Assert.assertNotNull(chosenGLCaps02);
+ Assert.assertTrue(chosenGLCaps02.getGreenBits()>5);
+ Assert.assertTrue(chosenGLCaps02.getBlueBits()>5);
+ Assert.assertTrue(chosenGLCaps02.getRedBits()>5);
+ Assert.assertTrue(chosenGLCaps02.getDepthBits()>4);
+ Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps02.isOnscreen());
+ Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps02.isFBO());
+ Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps02.isPBuffer());
+ Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps02.isBitmap());
+ /** Single/Double buffer cannot be checked since result may vary ..
+ if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) {
+ // dbl buffer may be disabled w/ offscreen pbuffer and bitmap
+ Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered());
+ } */
final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false, null) {
@Override