diff options
author | Kevin Rushforth <[email protected]> | 2004-10-20 16:41:33 +0000 |
---|---|---|
committer | Kevin Rushforth <[email protected]> | 2004-10-20 16:41:33 +0000 |
commit | a736c7431516159a3db499f7bb13a4a6235af1cb (patch) | |
tree | 075a35f69494a0788a2008c79387aae41385235d /src/classes/share | |
parent | 14b52db7ab4c4be2bd39ff944cec056c291f999a (diff) |
FIxed 4 problems with off-screen rendering:
1) modified Canvas3D.setOffScreenBuffer to accept "null", allowing users to reclaim pbuffer resources.
2) added cleanup code to destroy dummy window and class in a couple of places where we were getting an error return
3) fixed a bug caused by not properly keeping track of whether a speficic pixel format supports pbuffers.
4) only return HW accelerated pixel formats from getBestConfiguration
The first fix applies to all platforms. The last 3 are Windows only.
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@57 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes/share')
-rw-r--r-- | src/classes/share/javax/media/j3d/Canvas3D.java | 42 | ||||
-rw-r--r-- | src/classes/share/javax/media/j3d/GraphicsConfigTemplate3D.java | 33 |
2 files changed, 58 insertions, 17 deletions
diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java index 50ee073..5f351ce 100644 --- a/src/classes/share/javax/media/j3d/Canvas3D.java +++ b/src/classes/share/javax/media/j3d/Canvas3D.java @@ -1768,8 +1768,7 @@ public class Canvas3D extends Canvas { * @since Java 3D 1.2 */ public void setOffScreenBuffer(ImageComponent2D buffer) { - ImageComponent2DRetained bufferRetained = - (ImageComponent2DRetained)buffer.retained; + int width, height; if (!offScreen) throw new IllegalStateException(J3dI18N.getString("Canvas3D1")); @@ -1777,21 +1776,32 @@ public class Canvas3D extends Canvas { if (offScreenRendering) throw new RestrictedAccessException(J3dI18N.getString("Canvas3D2")); - if (bufferRetained.byReference && - !(bufferRetained.bImage[0] instanceof BufferedImage)) { + if (buffer != null) { + ImageComponent2DRetained bufferRetained = + (ImageComponent2DRetained)buffer.retained; - throw new IllegalArgumentException(J3dI18N.getString("Canvas3D15")); - } + if (bufferRetained.byReference && + !(bufferRetained.bImage[0] instanceof BufferedImage)) { + + throw new IllegalArgumentException(J3dI18N.getString("Canvas3D15")); + } - if (bufferRetained.format == ImageComponent.FORMAT_CHANNEL8) { - throw new IllegalArgumentException(J3dI18N.getString("Canvas3D16")); + if (bufferRetained.format == ImageComponent.FORMAT_CHANNEL8) { + throw new IllegalArgumentException(J3dI18N.getString("Canvas3D16")); + } + + width = bufferRetained.width; + height = bufferRetained.height; + } + else { + width = height = 0; } // TODO: illegalSharing - if ((offScreenCanvasSize.width != bufferRetained.width) || - (offScreenCanvasSize.height != bufferRetained.height)) { - + if ((offScreenCanvasSize.width != width) || + (offScreenCanvasSize.height != height)) { + if (window != 0) { // Fix for Issue 18. // Will do destroyOffScreenBuffer in the Renderer thread. @@ -1800,15 +1810,16 @@ public class Canvas3D extends Canvas { } // set the canvas dimension according to the buffer dimension - offScreenCanvasSize.setSize(bufferRetained.width, - bufferRetained.height); + offScreenCanvasSize.setSize(width, height); this.setSize(offScreenCanvasSize); - VirtualUniverse.mc.sendCreateOffScreenBuffer(this); + if (width > 0 && height > 0) { + VirtualUniverse.mc.sendCreateOffScreenBuffer(this); + } ctx = 0; } - if (ctx != 0) { + else if (ctx != 0) { removeCtx(false); } @@ -1817,7 +1828,6 @@ public class Canvas3D extends Canvas { synchronized(dirtyMaskLock) { cvDirtyMask |= Canvas3D.MOVED_OR_RESIZED_DIRTY; } - } diff --git a/src/classes/share/javax/media/j3d/GraphicsConfigTemplate3D.java b/src/classes/share/javax/media/j3d/GraphicsConfigTemplate3D.java index 8799c1a..2b423fa 100644 --- a/src/classes/share/javax/media/j3d/GraphicsConfigTemplate3D.java +++ b/src/classes/share/javax/media/j3d/GraphicsConfigTemplate3D.java @@ -160,7 +160,7 @@ public class GraphicsConfigTemplate3D extends GraphicsConfigTemplate { if (value < 0) return; - depthSize = value; + depthSize = value; } /** @@ -369,4 +369,35 @@ public class GraphicsConfigTemplate3D extends GraphicsConfigTemplate { } } } + + + // Return a string representing the value, one of: + // REQUIRED, PREFERRED, or UNNECESSARY + private static final String enumStr(int val) { + switch (val) { + case REQUIRED: + return "REQUIRED"; + case PREFERRED: + return "PREFERRED"; + case UNNECESSARY: + return "UNNECESSARY"; + } + + return "UNDEFINED"; + } + + /** + * Returns a string representation of this object. + * @return a string representation of this object. + */ + public String toString() { + return + "redSize : " + redSize + ", " + + "greenSize : " + greenSize + ", " + + "blueSize : " + blueSize + ", " + + "depthSize : " + depthSize + ", " + + "doubleBuffer : " + enumStr(doubleBuffer) + ", " + + "sceneAntialiasing : " + enumStr(sceneAntialiasing) + ", " + + "stereo : " + enumStr(stereo); + } } |