diff options
author | Sven Gothel <[email protected]> | 2014-07-10 01:11:00 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-10 01:11:00 +0200 |
commit | ec2d94ca26ddab8ec67135ebc5f2d0a43f6a4c25 (patch) | |
tree | e405f17400b8d52ffe38347d226ca9927ac4f3ec | |
parent | efa5f1110725d41b7ea58010fe34b2a8aacd185b (diff) |
Bug 1031: Remove Deprecated Classes and Methods (JOGL)
Removed Deprecated Class:
- com/jogamp/opengl/util/TGAWriter.java
- Use TextureIO w/ .tga suffix
- com/jogamp/opengl/util/awt/Screenshot.java
- Use:
- com.jogamp.opengl.util.GLReadBufferUtil, or
- com.jogamp.opengl.util.awt.AWTGLReadBufferUtil
The latter for reading into AWT BufferedImage
See: TestBug461FBOSupersamplingSwingAWT, TestBug605FlippedImageAWT
- javax/media/opengl/GLPbuffer.java
- Use:
caps.setPBuffer(true);
final GLAutoDrawable pbuffer = GLDrawableFactory.getFactory( caps.getGLProfile() ).createOffscreenAutoDrawable(null, caps, null, 512, 512);
- See: TestPBufferDeadlockAWT, ..
Removed Deprecated Methods:
- Constructor of AWT-GLCanvas, SWT-GLCanvas, AWT-GLJPanel
with argument 'final GLContext shareWith'
See GLSharedContextSetter, i.e. glCanvas.setSharedContext(..) !
- GLDrawableFactory.createOffscreenAutoDrawable(..)
with argument 'final GLContext shareWith'
See GLSharedContextSetter, i.e. offscreenAutoDrawable.setSharedContext(..) !
- GLDrawableFactory.createGLPbuffer(..),
see above!
- com.jogamp.opengl.util.av.AudioSink 'enqueueData(AudioDataFrame audioDataFrame)',
use 'enqueueData(int, ByteBuffer, int)'
- GLSharedContextSetter.areAllGLEventListenerInitialized(),
migrated to GLAutoDrawable !
- GLBase's
- glGetBoundBuffer(int), use getBoundBuffer(int)
- glGetBufferSize(int), use getBufferStorage(int).getSize()
- glIsVBOArrayBound(), use isVBOArrayBound()
- glIsVBOElementArrayBound(), use isVBOElementArrayBound()
- NEWT MouseEvent.BUTTON_NUMBER, use BUTTON_COUNT
37 files changed, 137 insertions, 1314 deletions
diff --git a/make/config/jogl/gl-if-CustomJavaCode-es3.java b/make/config/jogl/gl-if-CustomJavaCode-es3.java index 3f976d514..88c557f11 100644 --- a/make/config/jogl/gl-if-CustomJavaCode-es3.java +++ b/make/config/jogl/gl-if-CustomJavaCode-es3.java @@ -8,11 +8,7 @@ public static final long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFL ; /** Part of <code>GL_ARB_shader_image_load_store</code> */ public static final int GL_ALL_BARRIER_BITS = 0xFFFFFFFF ; -/** @deprecated Avoid original GL API namespace conflict. Use {@link #isPBOPackBound()} */ -public boolean glIsPBOPackBound(); public boolean isPBOPackBound(); -/** @deprecated Avoid original GL API namespace conflict. Use {@link #isPBOUnpackBound()} */ -public boolean glIsPBOUnpackBound(); public boolean isPBOUnpackBound(); diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java index f0246355e..a2ca12960 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-common.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java @@ -5,37 +5,21 @@ private final GLProfile glProfile; @Override - public final int glGetBoundBuffer(int target) { - return getBoundBuffer(target); - } - @Override public final int getBoundBuffer(int target) { return bufferStateTracker.getBoundBufferObject(target, this); } @Override - public final long glGetBufferSize(int bufferName) { - return bufferObjectTracker.getBufferSize(bufferName); - } - @Override public final GLBufferStorage getBufferStorage(int bufferName) { return bufferObjectTracker.getBufferStorage(bufferName); } @Override - public final boolean glIsVBOArrayBound() { - return isVBOArrayBound(); - } - @Override public final boolean isVBOArrayBound() { return checkArrayVBOBound(false); } @Override - public final boolean glIsVBOElementArrayBound() { - return isVBOElementArrayBound(); - } - @Override public final boolean isVBOElementArrayBound() { return checkElementVBOBound(false); } diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index f0adb5328..a8b5f8320 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -426,19 +426,11 @@ private final boolean checkPackPBOBound(boolean throwException) { } @Override -public final boolean glIsPBOPackBound() { - return isPBOPackBound(); -} -@Override public final boolean isPBOPackBound() { return checkPackPBOBound(false); } @Override -public final boolean glIsPBOUnpackBound() { - return isPBOUnpackBound(); -} -@Override public final boolean isPBOUnpackBound() { return checkUnpackPBOBound(false); } diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java index a5c0d1998..42adca4b1 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java @@ -329,19 +329,11 @@ private final boolean checkPackPBOBound(boolean throwException) { } @Override -public final boolean glIsPBOPackBound() { - return isPBOPackBound(); -} -@Override public final boolean isPBOPackBound() { return checkPackPBOBound(false); } @Override -public final boolean glIsPBOUnpackBound() { - return isPBOUnpackBound(); -} -@Override public final boolean isPBOUnpackBound() { return checkUnpackPBOBound(false); } diff --git a/make/config/jogl/glu-CustomJavaCode-base.java b/make/config/jogl/glu-CustomJavaCode-base.java index 606583acf..e8047d9d7 100644 --- a/make/config/jogl/glu-CustomJavaCode-base.java +++ b/make/config/jogl/glu-CustomJavaCode-base.java @@ -131,10 +131,6 @@ public GLU() project = new ProjectFloat(); } -/** @deprecated No more used, NOP */ -public void destroy() { -} - public static final GL getCurrentGL() throws GLException { GLContext curContext = GLContext.getCurrent(); if (curContext == null) { diff --git a/make/config/jogl/glu-CustomJavaCode-gl2.java b/make/config/jogl/glu-CustomJavaCode-gl2.java index b416d53f9..d7ba58de4 100644 --- a/make/config/jogl/glu-CustomJavaCode-gl2.java +++ b/make/config/jogl/glu-CustomJavaCode-gl2.java @@ -38,13 +38,6 @@ public GLUgl2() project = new ProjectDouble(); } -/** @deprecated No more used, NOP */ -@Override -public void destroy() { - super.destroy(); -} - - //---------------------------------------------------------------------- // Utility routines // diff --git a/make/config/jogl/glu-CustomJavaCode-gl2es1.java b/make/config/jogl/glu-CustomJavaCode-gl2es1.java index ad242be21..41a7e5b9b 100644 --- a/make/config/jogl/glu-CustomJavaCode-gl2es1.java +++ b/make/config/jogl/glu-CustomJavaCode-gl2es1.java @@ -40,12 +40,6 @@ public GLUgl2es1() super(); } -/** @deprecated No more used, NOP */ -@Override -public void destroy() { - super.destroy(); -} - //---------------------------------------------------------------------- // Utility routines // diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 86d09e480..629816e50 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -372,7 +372,7 @@ function testawtswt() { # # Stereo # -testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $* # # HiDPI @@ -382,7 +382,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $* -#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo $* +testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo $* #testawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtCanvasAWTDemo $* #testawt com.jogamp.opengl.test.junit.jogl.awt.ManualHiDPIBufferedImage01AWT $* @@ -709,7 +709,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT #testnoawt com.jogamp.opengl.test.junit.newt.DemoCreateAndDisposeOnCloseNEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index c94d21369..e58d8c64a 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -297,40 +297,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS } /** - * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser, GLContext)} - * on the SWT thread. - * - * @param parent - * Required (non-null) parent Composite. - * @param style - * Optional SWT style bit-field. The {@link SWT#NO_BACKGROUND} bit is set before passing this up to the - * Canvas constructor, so OpenGL handles the background. - * @param caps - * Optional GLCapabilities. If not provided, the default capabilities for the default GLProfile for the - * graphics device determined by the parent Composite are used. Note that the GLCapabilities that are - * actually used may differ based on the capabilities of the graphics device. - * @param chooser - * Optional GLCapabilitiesChooser to customize the selection of the used GLCapabilities based on the - * requested GLCapabilities, and the available capabilities of the graphics device. - * @param shareWith - * Optional GLContext to share state (textures, vbos, shaders, etc.) with. - * @return a new instance - * @deprecated Use {@link #create(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser)} - * and set shared GLContext via {@link #setSharedContext(GLContext)} or {@link #setSharedAutoDrawable(GLAutoDrawable)}. - */ - public static GLCanvas create(final Composite parent, final int style, final GLCapabilitiesImmutable caps, - final GLCapabilitiesChooser chooser, final GLContext shareWith) { - final GLCanvas[] res = new GLCanvas[] { null }; - parent.getDisplay().syncExec(new Runnable() { - @Override - public void run() { - res[0] = new GLCanvas( parent, style, caps, chooser, shareWith ); - } - }); - return res[0]; - } - - /** * Creates a new SWT GLCanvas. * * @param parent @@ -348,31 +314,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS */ public GLCanvas(final Composite parent, final int style, final GLCapabilitiesImmutable capsReqUser, final GLCapabilitiesChooser capsChooser) { - this(parent, style, capsReqUser, capsChooser, null); - } - - /** - * Creates a new SWT GLCanvas. - * - * @param parent - * Required (non-null) parent Composite. - * @param style - * Optional SWT style bit-field. The {@link SWT#NO_BACKGROUND} bit is set before passing this up to the - * Canvas constructor, so OpenGL handles the background. - * @param capsReqUser - * Optional GLCapabilities. If not provided, the default capabilities for the default GLProfile for the - * graphics device determined by the parent Composite are used. Note that the GLCapabilities that are - * actually used may differ based on the capabilities of the graphics device. - * @param capsChooser - * Optional GLCapabilitiesChooser to customize the selection of the used GLCapabilities based on the - * requested GLCapabilities, and the available capabilities of the graphics device. - * @param shareWith - * Optional GLContext to share state (textures, vbos, shaders, etc.) with. - * @deprecated Use {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser)} - * and set shared GLContext via {@link #setSharedContext(GLContext)} or {@link #setSharedAutoDrawable(GLAutoDrawable)}. - */ - public GLCanvas(final Composite parent, final int style, GLCapabilitiesImmutable capsReqUser, - final GLCapabilitiesChooser capsChooser, final GLContext shareWith) { /* NO_BACKGROUND required to avoid clearing bg in native SWT widget (we do this in the GL display) */ super(parent, style | SWT.NO_BACKGROUND); @@ -399,16 +340,13 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS screen = SWTAccessor.getScreen(swtDevice, -1 /* default */); } - /* Select default GLCapabilities if none was provided, otherwise clone provided caps to ensure safety */ + /* Select default GLCapabilities if none was provided, otherwise use cloned provided caps */ if(null == capsReqUser) { - capsReqUser = new GLCapabilities(GLProfile.getDefault(screen.getDevice())); + this.capsRequested = new GLCapabilities(GLProfile.getDefault(screen.getDevice())); + } else { + this.capsRequested = (GLCapabilitiesImmutable) capsReqUser.cloneMutable(); } - - this.capsRequested = capsReqUser; this.capsChooser = capsChooser; - if( null != shareWith ) { - helper.setSharedContext(null, shareWith); - } // post create .. when ready gdkWindow = 0; diff --git a/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java b/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java deleted file mode 100644 index 6e31c78a0..000000000 --- a/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - */ - -package com.jogamp.opengl.util; - -import java.io.*; -import java.nio.*; -import java.nio.channels.*; - -/** - * Utility class which helps take fast screenshots of OpenGL rendering - * results into Targa-format files. Used by the {@link com.jogamp.opengl.util.awt.Screenshot} - * class; can also be used in conjunction with the {@link com.jogamp.opengl.util.gl2.TileRenderer} class. - */ -public class TGAWriter { - - private static final int TARGA_HEADER_SIZE = 18; - - private FileChannel ch; - private ByteBuffer buf; - - /** Constructor for the TGAWriter. */ - public TGAWriter() { - } - - /** - * Opens the specified Targa file for writing, overwriting any - * existing file, and sets up the header of the file expecting the - * data to be filled in before closing it. - * - * @param file the file to write containing the screenshot - * @param width the width of the current drawable - * @param height the height of the current drawable - * @param alpha whether the alpha channel should be saved. If true, - * requires GL_EXT_abgr extension to be present. - * - * @throws IOException if an I/O error occurred while writing the - * file - */ - public void open(final File file, - final int width, - final int height, - final boolean alpha) throws IOException { - final RandomAccessFile out = new RandomAccessFile(file, "rw"); - ch = out.getChannel(); - final int pixelSize = (alpha ? 32 : 24); - final int numChannels = (alpha ? 4 : 3); - - final int fileLength = TARGA_HEADER_SIZE + width * height * numChannels; - out.setLength(fileLength); - final MappedByteBuffer image = ch.map(FileChannel.MapMode.READ_WRITE, 0, fileLength); - - // write the TARGA header - image.put(0, (byte) 0).put(1, (byte) 0); - image.put(2, (byte) 2); // uncompressed type - image.put(12, (byte) (width & 0xFF)); // width - image.put(13, (byte) (width >> 8)); // width - image.put(14, (byte) (height & 0xFF)); // height - image.put(15, (byte) (height >> 8)); // height - image.put(16, (byte) pixelSize); // pixel size - - // go to image data position - image.position(TARGA_HEADER_SIZE); - // jogl needs a sliced buffer - buf = image.slice(); - } - - /** - * Returns the ByteBuffer corresponding to the data for the image. - * This must be filled in with data in either BGR or BGRA format - * depending on whether an alpha channel was specified during - * open(). - */ - public ByteBuffer getImageData() { - return buf; - } - - public void close() throws IOException { - // close the file channel - ch.close(); - buf = null; - } -} diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java index 6d875fcf5..fd6172e13 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java @@ -423,20 +423,6 @@ public interface AudioSink { public int getFreeFrameCount(); /** - * Enqueue the remaining bytes of the given {@link AudioDataFrame}'s direct ByteBuffer to this sink. - * <p> - * The data must comply with the chosen {@link AudioFormat} as returned by {@link #initSink(AudioFormat)}. - * </p> - * <p> - * {@link #init(AudioFormat, float, int, int, int)} must be called first. - * </p> - * @returns the enqueued internal {@link AudioFrame}, which may differ from the input <code>audioDataFrame</code>. - * @deprecated User shall use {@link #enqueueData(int, ByteBuffer, int)}, which allows implementation - * to reuse specialized {@link AudioFrame} instances. - */ - public AudioFrame enqueueData(AudioDataFrame audioDataFrame); - - /** * Enqueue <code>byteCount</code> bytes of the remaining bytes of the given NIO {@link ByteBuffer} to this sink. * <p> * The data must comply with the chosen {@link AudioFormat} as returned by {@link #initSink(AudioFormat)}. diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java index 06e3ccda5..b75ad3b17 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java @@ -50,6 +50,9 @@ public class AWTGLReadBufferUtil extends GLReadBufferUtil { super(new AWTGLPixelBuffer.AWTGLPixelBufferProvider( glp.isGL2ES3() /* allowRowStride */ ), alpha, false); } + /** + * Returns the {@link AWTGLPixelBuffer}, as filled by previous call to {@link #readPixels(GL, int, int, int, int, boolean)}. + */ public AWTGLPixelBuffer getAWTGLPixelBuffer() { return (AWTGLPixelBuffer)this.getPixelBuffer(); } /** diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java b/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java deleted file mode 100644 index ac208044b..000000000 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - */ - -package com.jogamp.opengl.util.awt; - -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferByte; -import java.io.File; -import java.io.IOException; -import java.nio.ByteBuffer; - -import javax.imageio.ImageIO; -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GL2GL3; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLException; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.opengl.GLExtensions; -import com.jogamp.opengl.util.GLPixelStorageModes; -import com.jogamp.opengl.util.TGAWriter; - -/** - * Utilities for taking screenshots of OpenGL applications. - * @deprecated Please consider using {@link com.jogamp.opengl.util.GLReadBufferUtil}, - * which is AWT independent and does not require a CPU based vertical image flip - * in case drawable {@link GLDrawable#isGLOriented() is in OpenGL orientation}. - * Further more you may use {@link AWTGLReadBufferUtil} to read out - * the framebuffer into a BufferedImage for further AWT processing. - */ -public class Screenshot { - private Screenshot() {} - - /** - * Takes a fast screenshot of the current OpenGL drawable to a Targa - * file. Requires the OpenGL context for the desired drawable to be - * current. Takes the screenshot from the last assigned read buffer, - * or the OpenGL default read buffer if none has been specified by - * the user (GL_FRONT for single-buffered configurations and GL_BACK - * for double-buffered configurations). This is the fastest - * mechanism for taking a screenshot of an application. Contributed - * by Carsten Weisse of Bytonic Software (http://bytonic.de/). <p> - * - * No alpha channel is written with this variant. - * - * @param file the file to write containing the screenshot - * @param width the width of the current drawable - * @param height the height of the current drawable - * - * @throws GLException if an OpenGL context was not current or - * another OpenGL-related error occurred - * @throws IOException if an I/O error occurred while writing the - * file - */ - public static void writeToTargaFile(final File file, - final int width, - final int height) throws GLException, IOException { - writeToTargaFile(file, width, height, false); - } - - /** - * Takes a fast screenshot of the current OpenGL drawable to a Targa - * file. Requires the OpenGL context for the desired drawable to be - * current. Takes the screenshot from the last assigned read buffer, - * or the OpenGL default read buffer if none has been specified by - * the user (GL_FRONT for single-buffered configurations and GL_BACK - * for double-buffered configurations). This is the fastest - * mechanism for taking a screenshot of an application. Contributed - * by Carsten Weisse of Bytonic Software (http://bytonic.de/). - * - * @param file the file to write containing the screenshot - * @param width the width of the current drawable - * @param height the height of the current drawable - * @param alpha whether the alpha channel should be saved. If true, - * requires GL_EXT_abgr extension to be present. - * - * @throws GLException if an OpenGL context was not current or - * another OpenGL-related error occurred - * @throws IOException if an I/O error occurred while writing the - * file - */ - public static void writeToTargaFile(final File file, - final int width, - final int height, - final boolean alpha) throws GLException, IOException { - writeToTargaFile(file, 0, 0, width, height, alpha); - } - - /** - * Takes a fast screenshot of the current OpenGL drawable to a Targa - * file. Requires the OpenGL context for the desired drawable to be - * current. Takes the screenshot from the last assigned read buffer, - * or the OpenGL default read buffer if none has been specified by - * the user (GL_FRONT for single-buffered configurations and GL_BACK - * for double-buffered configurations). This is the fastest - * mechanism for taking a screenshot of an application. Contributed - * by Carsten Weisse of Bytonic Software (http://bytonic.de/). - * - * @param file the file to write containing the screenshot - * @param x the starting x coordinate of the screenshot, measured from the lower-left - * @param y the starting y coordinate of the screenshot, measured from the lower-left - * @param width the width of the desired screenshot area - * @param height the height of the desired screenshot area - * @param alpha whether the alpha channel should be saved. If true, - * requires GL_EXT_abgr extension to be present. - * - * @throws GLException if an OpenGL context was not current or - * another OpenGL-related error occurred - * @throws IOException if an I/O error occurred while writing the - * file - */ - public static void writeToTargaFile(final File file, - final int x, - final int y, - final int width, - final int height, - final boolean alpha) throws GLException, IOException { - if (alpha) { - checkExtABGR(); - } - - final TGAWriter writer = new TGAWriter(); - writer.open(file, width, height, alpha); - final ByteBuffer bgr = writer.getImageData(); - - final GL gl = GLContext.getCurrentGL(); - - // Set up pixel storage modes - final GLPixelStorageModes psm = new GLPixelStorageModes(); - psm.setPackAlignment(gl, 1); - - final int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2GL3.GL_BGR); - - // read the BGR values into the image buffer - gl.glReadPixels(x, y, width, height, readbackType, - GL.GL_UNSIGNED_BYTE, bgr); - - // Restore pixel storage modes - psm.restore(gl); - - // close the file - writer.close(); - } - - /** - * Takes a screenshot of the current OpenGL drawable to a - * BufferedImage. Requires the OpenGL context for the desired - * drawable to be current. Takes the screenshot from the last - * assigned read buffer, or the OpenGL default read buffer if none - * has been specified by the user (GL_FRONT for single-buffered - * configurations and GL_BACK for double-buffered configurations). - * Note that the scanlines of the resulting image are flipped - * vertically in order to correctly match the OpenGL contents, which - * takes time and is therefore not as fast as the Targa screenshot - * function. <P> - * - * No alpha channel is read back with this variant. - * - * @param width the width of the current drawable - * @param height the height of the current drawable - * - * @throws GLException if an OpenGL context was not current or - * another OpenGL-related error occurred - */ - public static BufferedImage readToBufferedImage(final int width, - final int height) throws GLException { - return readToBufferedImage(width, height, false); - } - - /** - * Takes a screenshot of the current OpenGL drawable to a - * BufferedImage. Requires the OpenGL context for the desired - * drawable to be current. Takes the screenshot from the last - * assigned read buffer, or the OpenGL default read buffer if none - * has been specified by the user (GL_FRONT for single-buffered - * configurations and GL_BACK for double-buffered configurations). - * Note that the scanlines of the resulting image are flipped - * vertically in order to correctly match the OpenGL contents, which - * takes time and is therefore not as fast as the Targa screenshot - * function. - * - * @param width the width of the current drawable - * @param height the height of the current drawable - * @param alpha whether the alpha channel should be read back. If - * true, requires GL_EXT_abgr extension to be present. - * - * @throws GLException if an OpenGL context was not current or - * another OpenGL-related error occurred - */ - public static BufferedImage readToBufferedImage(final int width, - final int height, - final boolean alpha) throws GLException { - return readToBufferedImage(0, 0, width, height, alpha); - } - - /** - * Takes a screenshot of the current OpenGL drawable to a - * BufferedImage. Requires the OpenGL context for the desired - * drawable to be current. Takes the screenshot from the last - * assigned read buffer, or the OpenGL default read buffer if none - * has been specified by the user (GL_FRONT for single-buffered - * configurations and GL_BACK for double-buffered configurations). - * Note that the scanlines of the resulting image are flipped - * vertically in order to correctly match the OpenGL contents, which - * takes time and is therefore not as fast as the Targa screenshot - * function. - * - * @param x the starting x coordinate of the screenshot, measured from the lower-left - * @param y the starting y coordinate of the screenshot, measured from the lower-left - * @param width the width of the desired screenshot area - * @param height the height of the desired screenshot area - * @param alpha whether the alpha channel should be read back. If - * true, requires GL_EXT_abgr extension to be present. - * - * @throws GLException if an OpenGL context was not current or - * another OpenGL-related error occurred - */ - public static BufferedImage readToBufferedImage(final int x, - final int y, - final int width, - final int height, - final boolean alpha) throws GLException { - final int bufImgType = (alpha ? BufferedImage.TYPE_4BYTE_ABGR : BufferedImage.TYPE_3BYTE_BGR); - final int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2GL3.GL_BGR); - - if (alpha) { - checkExtABGR(); - } - - // Allocate necessary storage - final BufferedImage image = new BufferedImage(width, height, bufImgType); - - final GLContext glc = GLContext.getCurrent(); - final GL gl = glc.getGL(); - - // Set up pixel storage modes - final GLPixelStorageModes psm = new GLPixelStorageModes(); - psm.setPackAlignment(gl, 1); - - // read the BGR values into the image - gl.glReadPixels(x, y, width, height, readbackType, - GL.GL_UNSIGNED_BYTE, - ByteBuffer.wrap(((DataBufferByte) image.getRaster().getDataBuffer()).getData())); - - // Restore pixel storage modes - psm.restore(gl); - - if( glc.getGLDrawable().isGLOriented() ) { - // Must flip BufferedImage vertically for correct results - ImageUtil.flipImageVertically(image); - } - return image; - } - - /** - * Takes a screenshot of the current OpenGL drawable to the - * specified file on disk using the ImageIO package. Requires the - * OpenGL context for the desired drawable to be current. Takes the - * screenshot from the last assigned read buffer, or the OpenGL - * default read buffer if none has been specified by the user - * (GL_FRONT for single-buffered configurations and GL_BACK for - * double-buffered configurations). This is not the fastest - * mechanism for taking a screenshot but may be more convenient than - * others for getting images for consumption by other packages. The - * file format is inferred from the suffix of the given file. <P> - * - * No alpha channel is saved with this variant. - * - * @param file the file to write containing the screenshot - * @param width the width of the current drawable - * @param height the height of the current drawable - * - * @throws GLException if an OpenGL context was not current or - * another OpenGL-related error occurred - * - * @throws IOException if an I/O error occurred or if the file could - * not be written to disk due to the requested file format being - * unsupported by ImageIO - */ - public static void writeToFile(final File file, - final int width, - final int height) throws IOException, GLException { - writeToFile(file, width, height, false); - } - - /** - * Takes a screenshot of the current OpenGL drawable to the - * specified file on disk using the ImageIO package. Requires the - * OpenGL context for the desired drawable to be current. Takes the - * screenshot from the last assigned read buffer, or the OpenGL - * default read buffer if none has been specified by the user - * (GL_FRONT for single-buffered configurations and GL_BACK for - * double-buffered configurations). This is not the fastest - * mechanism for taking a screenshot but may be more convenient than - * others for getting images for consumption by other packages. The - * file format is inferred from the suffix of the given file. <P> - * - * Note that some file formats, in particular JPEG, can not handle - * an alpha channel properly. If the "alpha" argument is specified - * as true for such a file format it will be silently ignored. - * - * @param file the file to write containing the screenshot - * @param width the width of the current drawable - * @param height the height of the current drawable - * @param alpha whether an alpha channel should be saved. If true, - * requires GL_EXT_abgr extension to be present. - * - * @throws GLException if an OpenGL context was not current or - * another OpenGL-related error occurred - * - * @throws IOException if an I/O error occurred or if the file could - * not be written to disk due to the requested file format being - * unsupported by ImageIO - */ - public static void writeToFile(final File file, - final int width, - final int height, - final boolean alpha) throws IOException, GLException { - writeToFile(file, 0, 0, width, height, alpha); - } - - /** - * Takes a screenshot of the current OpenGL drawable to the - * specified file on disk using the ImageIO package. Requires the - * OpenGL context for the desired drawable to be current. Takes the - * screenshot from the last assigned read buffer, or the OpenGL - * default read buffer if none has been specified by the user - * (GL_FRONT for single-buffered configurations and GL_BACK for - * double-buffered configurations). This is not the fastest - * mechanism for taking a screenshot but may be more convenient than - * others for getting images for consumption by other packages. The - * file format is inferred from the suffix of the given file. <P> - * - * Note that some file formats, in particular JPEG, can not handle - * an alpha channel properly. If the "alpha" argument is specified - * as true for such a file format it will be silently ignored. - * - * @param file the file to write containing the screenshot - * @param x the starting x coordinate of the screenshot, measured from the lower-left - * @param y the starting y coordinate of the screenshot, measured from the lower-left - * @param width the width of the current drawable - * @param height the height of the current drawable - * @param alpha whether an alpha channel should be saved. If true, - * requires GL_EXT_abgr extension to be present. - * - * @throws GLException if an OpenGL context was not current or - * another OpenGL-related error occurred - * - * @throws IOException if an I/O error occurred or if the file could - * not be written to disk due to the requested file format being - * unsupported by ImageIO - */ - public static void writeToFile(final File file, - final int x, - final int y, - final int width, - final int height, - boolean alpha) throws IOException, GLException { - final String fileSuffix = IOUtil.getFileSuffix(file); - if (alpha && (fileSuffix.equals("jpg") || fileSuffix.equals("jpeg"))) { - // JPEGs can't deal properly with alpha channels - alpha = false; - } - - final BufferedImage image = readToBufferedImage(x, y, width, height, alpha); - if (!ImageIO.write(image, fileSuffix, file)) { - throw new IOException("Unsupported file format " + fileSuffix); - } - } - - private static void checkExtABGR() { - final GL gl = GLContext.getCurrentGL(); - - if (!gl.isExtensionAvailable(GLExtensions.EXT_abgr)) { - throw new IllegalArgumentException("Saving alpha channel requires GL_EXT_abgr"); - } - } -} diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index bf8fe65ac..377dce190 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -199,6 +199,11 @@ public interface GLAutoDrawable extends GLDrawable { public int getGLEventListenerCount(); /** + * Returns true if all added {@link GLEventListener} are initialized, otherwise false. + */ + boolean areAllGLEventListenerInitialized(); + + /** * Returns the {@link GLEventListener} at the given index of this drawable queue. * @param index Position of the listener to be returned. * Should be within (0 <= index && index < size()). diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index c808399b8..48455c525 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -505,10 +505,6 @@ public interface GLBase { public void glDepthRange(double zNear, double zFar); /** - * @deprecated Avoid original GL API namespace conflict. Use {@link #getBoundBuffer(int)} - */ - public int glGetBoundBuffer(int target); - /** * @param target a GL buffer (VBO) target as used in {@link GL#glBindBuffer(int, int)}, ie {@link GL#GL_ELEMENT_ARRAY_BUFFER}, {@link GL#GL_ARRAY_BUFFER}, .. * @return the GL buffer name bound to a target via {@link GL#glBindBuffer(int, int)} or 0 if unbound. * @see #getBufferStorage(int) @@ -516,10 +512,6 @@ public interface GLBase { public int getBoundBuffer(int target); /** - * @deprecated Use {@link #getBufferStorage(int)}. - */ - public long glGetBufferSize(int bufferName); - /** * @param bufferName a GL buffer name, generated with e.g. {@link GL#glGenBuffers(int, int[], int)} and used in {@link GL#glBindBuffer(int, int)}, {@link GL#glBufferData(int, long, java.nio.Buffer, int)} or {@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)}. * @return the size of the given GL buffer storage, see {@link GLBufferStorage} * @see #getBoundBuffer(int) @@ -580,19 +572,11 @@ public interface GLBase { public GLBufferStorage mapBufferRange(final int target, final long offset, final long length, final int access) throws GLException; /** - * @deprecated Avoid original GL API namespace conflict. Use {@link #isVBOArrayBound()} - */ - public boolean glIsVBOArrayBound(); - /** * @return true if a VBO is bound to {@link GL#GL_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false */ public boolean isVBOArrayBound(); /** - * @deprecated Avoid original GL API namespace conflict. Use {@link #isVBOElementArrayBound()} - */ - public boolean glIsVBOElementArrayBound(); - /** * @return true if a VBO is bound to {@link GL#GL_ELEMENT_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false */ public boolean isVBOElementArrayBound(); diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 6e7caf8f8..82808a3cb 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -59,10 +59,10 @@ import javax.media.nativewindow.UpstreamSurfaceHook; import jogamp.opengl.Debug; -/** <P> Provides a virtual machine- and operating system-independent - mechanism for creating {@link GLDrawable}s. </P> - - <P> The {@link javax.media.opengl.GLCapabilities} objects passed +/** <p> Provides a virtual machine- and operating system-independent + mechanism for creating {@link GLDrawable}s. + </p> + <p> The {@link javax.media.opengl.GLCapabilities} objects passed in to the various factory methods are used as a hint for the properties of the returned drawable. The default capabilities selection algorithm (equivalent to passing in a null {@link @@ -72,9 +72,10 @@ import jogamp.opengl.Debug; GLCapabilitiesChooser} which can select from the available pixel formats. The GLCapabilitiesChooser mechanism may not be supported by all implementations or on all platforms, in which case any - passed GLCapabilitiesChooser will be ignored. </P> + passed GLCapabilitiesChooser will be ignored. + </p> - <P> Because of the multithreaded nature of the Java platform's + <p> Because of the multithreaded nature of the Java platform's Abstract Window Toolkit, it is typically not possible to immediately reject a given {@link GLCapabilities} as being unsupportable by either returning <code>null</code> from the creation routines or @@ -83,14 +84,15 @@ import jogamp.opengl.Debug; implementation will cause a {@link GLException} to be raised during the first repaint of the {@link javax.media.opengl.awt.GLCanvas} or {@link javax.media.opengl.awt.GLJPanel} if the capabilities can not be met.<br> - {@link javax.media.opengl.GLPbuffer} are always - created immediately and their creation will fail with a - {@link javax.media.opengl.GLException} if errors occur. </P> + {@link GLOffscreenAutoDrawable} are created lazily, + see {@link #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) createOffscreenAutoDrawable(..)}. + </p> - <P> The concrete GLDrawableFactory subclass instantiated by {@link + <p> The concrete GLDrawableFactory subclass instantiated by {@link #getFactory getFactory} can be changed by setting the system property <code>opengl.factory.class.name</code> to the - fully-qualified name of the desired class. </P> + fully-qualified name of the desired class. + </p> */ public abstract class GLDrawableFactory { @@ -474,57 +476,11 @@ public abstract class GLDrawableFactory { * incl it's offscreen {@link NativeSurface} with the given capabilites and dimensions. * <p> * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized} - * and it's {@link GLContext} assigned but not yet made current. - * </p> - * <p> - * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e. - * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} <code> == true</code>, - * it is auto-configured. Auto configuration will set {@link GLCapabilitiesImmutable caps} to offscreen - * and FBO <i>or</i> Pbuffer, whichever is available in that order. - * </p> - * <p> - * A FBO based auto drawable, {@link GLOffscreenAutoDrawable.FBO}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()} - * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true. - * </p> - * <p> - * A Pbuffer based auto drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()} - * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true. - * </p> - * <p> - * If neither FBO nor Pbuffer is available, - * a simple pixmap/bitmap auto drawable is created, which is unlikely to be hardware accelerated. - * </p> - * <p> - * The resulting {@link GLOffscreenAutoDrawable} has it's own independent device instance using <code>device</code> details. - * </p> - * - * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be <code>null</code> for the platform's default device. - * @param caps the requested GLCapabilties - * @param chooser the custom chooser, may be null for default - * @param width the requested offscreen width - * @param height the requested offscreen height - * @return the created and initialized offscreen {@link GLOffscreenAutoDrawable} instance - * - * @throws GLException if any window system-specific errors caused - * the creation of the Offscreen to fail. - * - * @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) - * @deprecated Use {@link #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) - */ - public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, - GLCapabilitiesImmutable caps, - GLCapabilitiesChooser chooser, - int width, int height, - GLContext shareWith) throws GLException; - - /** - * Creates a {@link GLDrawable#isRealized() realized} {@link GLOffscreenAutoDrawable} - * incl it's offscreen {@link NativeSurface} with the given capabilites and dimensions. - * <p> - * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized} * <i>without</i> an assigned {@link GLContext}, hence not initialized completely.<br> + * * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)} * <i>or</i> it will be created <i>lazily</i> at the 1st {@link GLAutoDrawable#display() display()} method call.<br> + * * <i>Lazy</i> {@link GLContext} creation will take a shared {@link GLContext} into account * which has been set {@link GLOffscreenAutoDrawable#setSharedContext(GLContext) directly} * or {@link GLOffscreenAutoDrawable#setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}. @@ -716,38 +672,6 @@ public abstract class GLDrawableFactory { */ public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device, GLProfile glp); - /** - * Creates a GLPbuffer {@link GLAutoDrawable} with the given capabilites and dimensions. - * <p> - * The GLPbuffer drawable is realized and initialized eagerly. - * </p> - * - * See the note in the overview documentation in {@link GLSharedContextSetter} and on - * <a href="../../../spec-overview.html#SHARING">context sharing</a>. - * - * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device. - * @param capabilities the requested capabilities - * @param chooser the custom chooser, may be null for default - * @param initialWidth initial width of pbuffer - * @param initialHeight initial height of pbuffer - * @param shareWith a shared GLContext this GLPbuffer shall use - * - * @return the created and initialized {@link GLPbuffer} instance - * - * @throws GLException if any window system-specific errors caused - * the creation of the GLPbuffer to fail. - * - * @deprecated {@link GLPbuffer} is deprecated, use {@link #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext)} - */ - public abstract GLPbuffer createGLPbuffer(AbstractGraphicsDevice device, - GLCapabilitiesImmutable capabilities, - GLCapabilitiesChooser chooser, - int initialWidth, - int initialHeight, - GLContext shareWith) - throws GLException; - - //---------------------------------------------------------------------- // Methods for interacting with third-party OpenGL libraries diff --git a/src/jogl/classes/javax/media/opengl/GLPbuffer.java b/src/jogl/classes/javax/media/opengl/GLPbuffer.java deleted file mode 100644 index f36a4bf29..000000000 --- a/src/jogl/classes/javax/media/opengl/GLPbuffer.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package javax.media.opengl; - -/** Provides offscreen rendering support via pbuffers. The principal - addition of this interface is a {@link #destroy} method to - deallocate the pbuffer and its associated resources. It also - contains experimental methods for accessing the pbuffer's contents - as a texture map and enabling rendering to floating-point frame - buffers. These methods are not guaranteed to be supported on all - platforms and may be deprecated in a future release. - - @deprecated Use {@link GLOffscreenAutoDrawable} w/ {@link GLCapabilities#setFBO(boolean)} - via {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext) GLDrawableFactory.createOffscreenAutoDrawable(..)}. - */ -public interface GLPbuffer extends GLAutoDrawable { - /** Destroys the native resources associated with this pbuffer. It - is not valid to call display() or any other routines on this - pbuffer after it has been destroyed. Before destroying the - pbuffer, the application must destroy any additional OpenGL - contexts which have been created for the pbuffer via {@link - #createContext}. */ - @Override - public void destroy(); -} diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java index 2ea4e4cd6..11ed648c2 100644 --- a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java +++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java @@ -99,12 +99,6 @@ package javax.media.opengl; */ public interface GLSharedContextSetter extends GLAutoDrawable { /** - * Returns true if all {@link GLEventListener} are initialized, otherwise false. - * @deprecated Promote method to {@link GLAutoDrawable} - */ - boolean areAllGLEventListenerInitialized(); - - /** * Specifies an {@link GLContext OpenGL context}, which shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. * <p> * Since the {@link GLDrawable drawable} and {@link GLContext context} is created diff --git a/src/jogl/classes/javax/media/opengl/Threading.java b/src/jogl/classes/javax/media/opengl/Threading.java index 3ee233303..6c64cbe31 100644 --- a/src/jogl/classes/javax/media/opengl/Threading.java +++ b/src/jogl/classes/javax/media/opengl/Threading.java @@ -129,8 +129,8 @@ public class Threading { consequences and are prepared to enforce some amount of threading restrictions in their applications. Disabling single-threading, for example, may have unintended consequences - on GLAutoDrawable implementations such as GLCanvas, GLJPanel and - GLPbuffer. Currently there is no supported way to re-enable it + on GLAutoDrawable implementations such as GLCanvas and GLJPanel. + Currently there is no supported way to re-enable it once disabled, partly to discourage careless use of this method. This method should be called as early as possible in an application. */ diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index ec834e02f..2d5e12429 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -155,6 +155,11 @@ import jogamp.opengl.awt.AWTTilePainter; * <ul> * <li><pre>sun.awt.noerasebackground=true</pre></li> * </ul> + * + * <a name="contextSharing"><h5>OpenGL Context Sharing</h5></a> + * To share a {@link GLContext} see the following note in the documentation overview: + * <a href="../../../spec-overview.html#SHARING">context sharing</a> + * as well as {@link GLSharedContextSetter}. */ @SuppressWarnings("serial") @@ -200,6 +205,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing /** Creates a new GLCanvas component with a default set of OpenGL capabilities, using the default OpenGL capabilities selection mechanism, on the default screen device. + <p> + See details about <a href="#contextSharing">OpenGL context sharing</a>. + </p> * @throws GLException if no default profile is available for the default desktop device. */ public GLCanvas() throws GLException { @@ -209,27 +217,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing /** Creates a new GLCanvas component with the requested set of OpenGL capabilities, using the default OpenGL capabilities selection mechanism, on the default screen device. + <p> + See details about <a href="#contextSharing">OpenGL context sharing</a>. + </p> * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. * @see GLCanvas#GLCanvas(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, javax.media.opengl.GLContext, java.awt.GraphicsDevice) */ public GLCanvas(final GLCapabilitiesImmutable capsReqUser) throws GLException { - this(capsReqUser, null, null, null); - } - - /** Creates a new GLCanvas component with the requested set of - OpenGL capabilities, using the default OpenGL capabilities - selection mechanism, on the default screen device. - * This constructor variant also supports using a shared GLContext. - * - * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. - * @see GLCanvas#GLCanvas(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, javax.media.opengl.GLContext, java.awt.GraphicsDevice) - * @deprecated Use {@link #GLCanvas(GLCapabilitiesImmutable)} - * and set shared GLContext via {@link #setSharedContext(GLContext)} or {@link #setSharedAutoDrawable(GLAutoDrawable)}. - */ - public GLCanvas(final GLCapabilitiesImmutable capsReqUser, final GLContext shareWith) - throws GLException - { - this(capsReqUser, null, shareWith, null); + this(capsReqUser, null, null); } /** Creates a new GLCanvas component. The passed GLCapabilities @@ -242,6 +237,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing which to create the GLCanvas; the GLDrawableFactory uses the default screen device of the local GraphicsEnvironment if null is passed for this argument. + <p> + See details about <a href="#contextSharing">OpenGL context sharing</a>. + </p> * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. */ public GLCanvas(final GLCapabilitiesImmutable capsReqUser, @@ -249,34 +247,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final GraphicsDevice device) throws GLException { - this(capsReqUser, chooser, null, device); - } - - /** Creates a new GLCanvas component. The passed GLCapabilities - specifies the OpenGL capabilities for the component; if null, a - default set of capabilities is used. The GLCapabilitiesChooser - specifies the algorithm for selecting one of the available - GLCapabilities for the component; a DefaultGLCapabilitesChooser - is used if null is passed for this argument. The passed - GLContext specifies an OpenGL context with which to share - textures, display lists and other OpenGL state, and may be null - if sharing is not desired. See the note in the overview - documentation on <a - href="../../../spec-overview.html#SHARING">context - sharing</a>. The passed GraphicsDevice indicates the screen on - which to create the GLCanvas; the GLDrawableFactory uses the - default screen device of the local GraphicsEnvironment if null - is passed for this argument. - * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. - * @deprecated Use {@link #GLCanvas(GLCapabilitiesImmutable, GLCapabilitiesChooser, GraphicsDevice)} - * and set shared GLContext via {@link #setSharedContext(GLContext)} or {@link #setSharedAutoDrawable(GLAutoDrawable)}. - */ - public GLCanvas(GLCapabilitiesImmutable capsReqUser, - final GLCapabilitiesChooser chooser, - final GLContext shareWith, - GraphicsDevice device) - throws GLException - { /* * Determination of the native window is made in 'super.addNotify()', * which creates the native peer using AWT's GraphicsConfiguration. @@ -287,29 +257,28 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing super(); if(null==capsReqUser) { - capsReqUser = new GLCapabilities(GLProfile.getDefault(GLProfile.getDefaultDevice())); + this.capsReqUser = new GLCapabilities(GLProfile.getDefault(GLProfile.getDefaultDevice())); } else { // don't allow the user to change data - capsReqUser = (GLCapabilitiesImmutable) capsReqUser.cloneMutable(); + this.capsReqUser = (GLCapabilitiesImmutable) capsReqUser.cloneMutable(); } - if(!capsReqUser.isOnscreen()) { + if( !this.capsReqUser.isOnscreen() ) { setShallUseOffscreenLayer(true); // trigger offscreen layer - if supported } if(null==device) { final GraphicsConfiguration gc = super.getGraphicsConfiguration(); if(null!=gc) { - device = gc.getDevice(); + this.device = gc.getDevice(); + } else { + this.device = null; } + } else { + this.device = device; } // instantiation will be issued in addNotify() - this.capsReqUser = capsReqUser; this.chooser = chooser; - if( null != shareWith ) { - helper.setSharedContext(null, shareWith); - } - this.device = device; this.addHierarchyListener(hierarchyListener); this.isShowing = isShowing(); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index eca99c6c0..549b6e96f 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -170,6 +170,10 @@ import com.jogamp.opengl.util.texture.TextureState; It is recommended to reset those states to default when leaving the {@link GLEventListener#display(GLAutoDrawable)} method! We may change this behavior in the future, i.e. preserve all influencing states. </p> + <a name="contextSharing"><h5>OpenGL Context Sharing</h5></a> + To share a {@link GLContext} see the following note in the documentation overview: + <a href="../../../spec-overview.html#SHARING">context sharing</a> + as well as {@link GLSharedContextSetter}. */ @SuppressWarnings("serial") @@ -298,6 +302,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing /** Creates a new GLJPanel component with a default set of OpenGL capabilities and using the default OpenGL capabilities selection mechanism. + <p> + See details about <a href="#contextSharing">OpenGL context sharing</a>. + </p> * @throws GLException if no default profile is available for the default desktop device. */ public GLJPanel() throws GLException { @@ -307,10 +314,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing /** Creates a new GLJPanel component with the requested set of OpenGL capabilities, using the default OpenGL capabilities selection mechanism. + <p> + See details about <a href="#contextSharing">OpenGL context sharing</a>. + </p> * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. */ public GLJPanel(final GLCapabilitiesImmutable userCapsRequest) throws GLException { - this(userCapsRequest, null, null); + this(userCapsRequest, null); } /** Creates a new GLJPanel component. The passed GLCapabilities @@ -319,34 +329,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing specifies the algorithm for selecting one of the available GLCapabilities for the component; a DefaultGLCapabilitesChooser is used if null is passed for this argument. + <p> + See details about <a href="#contextSharing">OpenGL context sharing</a>. + </p> * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. */ public GLJPanel(final GLCapabilitiesImmutable userCapsRequest, final GLCapabilitiesChooser chooser) throws GLException { - this(userCapsRequest, chooser, null); - } - - /** Creates a new GLJPanel component. The passed GLCapabilities - specifies the OpenGL capabilities for the component; if null, a - default set of capabilities is used. The GLCapabilitiesChooser - specifies the algorithm for selecting one of the available - GLCapabilities for the component; a DefaultGLCapabilitesChooser - is used if null is passed for this argument. The passed - GLContext specifies an OpenGL context with which to share - textures, display lists and other OpenGL state, and may be null - if sharing is not desired. See the note in the overview documentation on - <a href="../../../spec-overview.html#SHARING">context sharing</a>. - <P> - Note: Sharing cannot be enabled using J2D OpenGL FBO sharing, - since J2D GL Context must be shared and we can only share one context. - * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. - * @deprecated Use {@link #GLJPanel(GLCapabilitiesImmutable, GLCapabilitiesChooser)} - * and set shared GLContext via {@link #setSharedContext(GLContext)} or {@link #setSharedAutoDrawable(GLAutoDrawable)}. - */ - public GLJPanel(final GLCapabilitiesImmutable userCapsRequest, final GLCapabilitiesChooser chooser, final GLContext shareWith) - throws GLException - { super(); // Works around problems on many vendors' cards; we don't need a @@ -366,9 +356,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing this.chooser = chooser; helper = new GLDrawableHelper(); - if( null != shareWith ) { - helper.setSharedContext(null, shareWith); - } autoSwapBufferMode = helper.getAutoSwapBufferMode(); this.setFocusable(true); // allow keyboard input! diff --git a/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java index 34857586d..7e49b3464 100644 --- a/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java +++ b/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java @@ -491,18 +491,6 @@ public class GLBufferObjectTracker { return res; } - public synchronized final long getBufferSize(final int bufferName) { - final GLBufferStorageImpl store = (GLBufferStorageImpl)bufferName2StorageMap.get(bufferName); - if ( null == store ) { - if (DEBUG) { - System.err.printf("%s: %s.getBufferSize(): Buffer %d not tracked%n", warning, msgClazzName, bufferName); - Thread.dumpStack(); - } - return 0; - } - return store.getSize(); - } - public synchronized final GLBufferStorage getBufferStorage(final int bufferName) { return (GLBufferStorageImpl)bufferName2StorageMap.get(bufferName); } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index ff4e9314f..c175243ae 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -2093,13 +2093,6 @@ public abstract class GLContextImpl extends GLContext { return contextFQN; } - /** Indicates which floating-point pbuffer implementation is in - use. Returns one of GLPbuffer.APPLE_FLOAT, GLPbuffer.ATI_FLOAT, - or GLPbuffer.NV_FLOAT. */ - public int getFloatingPointMode() throws GLException { - throw new GLException("Not supported on non-pbuffer contexts"); - } - @Override public int getDefaultPixelDataType() { evalPixelDataType(); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 1aca29d0a..0b119b50d 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -59,7 +59,6 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLFBODrawable; import javax.media.opengl.GLOffscreenAutoDrawable; -import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; import com.jogamp.nativewindow.MutableGraphicsConfiguration; @@ -74,7 +73,6 @@ import com.jogamp.opengl.GLRendererQuirks; Independent Bitmaps on Windows, pixmaps on X11). Direct access to these GLDrawables is not supplied directly to end users, though they may be instantiated by the GLJPanel implementation. */ -@SuppressWarnings("deprecation") public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { protected static final boolean DEBUG = GLDrawableFactory.DEBUG; // allow package access @@ -251,37 +249,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { @Override public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device, GLProfile glp); - @Override - public final GLPbuffer createGLPbuffer(final AbstractGraphicsDevice deviceReq, - final GLCapabilitiesImmutable capsRequested, - final GLCapabilitiesChooser chooser, - final int width, - final int height, - final GLContext shareWith) { - if(width<=0 || height<=0) { - throw new GLException("initial size must be positive (were (" + width + " x " + height + "))"); - } - final AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); - if(null == device) { - throw new GLException("No shared device for requested: "+deviceReq); - } - if ( !canCreateGLPbuffer(device, capsRequested.getGLProfile()) ) { - throw new GLException("Pbuffer not available with device: "+device); - } - - final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(capsRequested); - final GLDrawableImpl drawable = createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, - new UpstreamSurfaceHookMutableSize(width, height) ) ); - final GLContextImpl ctx; - if(null != drawable) { - drawable.setRealized(true); - ctx = (GLContextImpl) drawable.createContext(shareWith); - } else { - ctx = null; - } - return new GLPbufferImpl( drawable, ctx); - } - //--------------------------------------------------------------------------- // // Offscreen GLDrawable construction @@ -300,21 +267,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { public final GLOffscreenAutoDrawable createOffscreenAutoDrawable(final AbstractGraphicsDevice deviceReq, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser, - final int width, final int height, - final GLContext shareWith) { - final GLDrawable drawable = createOffscreenDrawable( deviceReq, capsRequested, chooser, width, height ); - drawable.setRealized(true); - final GLContext context = drawable.createContext(shareWith); - if(drawable instanceof GLFBODrawableImpl) { - return new GLOffscreenAutoDrawableImpl.FBOImpl( (GLFBODrawableImpl)drawable, context, null, null ); - } - return new GLOffscreenAutoDrawableImpl( drawable, context, null, null); - } - - @Override - public final GLOffscreenAutoDrawable createOffscreenAutoDrawable(final AbstractGraphicsDevice deviceReq, - final GLCapabilitiesImmutable capsRequested, - final GLCapabilitiesChooser chooser, final int width, final int height) { final GLDrawable drawable = createOffscreenDrawable( deviceReq, capsRequested, chooser, width, height ); drawable.setRealized(true); diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java deleted file mode 100644 index ac5487961..000000000 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package jogamp.opengl; - -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLException; -import javax.media.opengl.GLPbuffer; - -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; - -@SuppressWarnings("deprecation") -public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { - - public GLPbufferImpl(final GLDrawableImpl pbufferDrawable, final GLContextImpl pbufferContext) { - super(pbufferDrawable, pbufferContext, true); // drawable := pbufferDrawable, context := pbufferContext - } - - // - // pbuffer specifics - // - - // - // GLDrawable delegation - // - - @Override - public final void swapBuffers() throws GLException { - defaultSwapBuffers(); - } - - // - // GLAutoDrawable completion - // - private final RecursiveLock lock = LockFactory.createRecursiveLock(); // instance wide lock - - @Override - protected final RecursiveLock getLock() { return lock; } - - @Override - public final Object getUpstreamWidget() { - return null; - } - - @Override - public void destroy() { - defaultDestroy(); - } - - @Override - public GLDrawableFactory getFactory() { - return drawable.getFactory(); - } - - @Override - public final void display() { - final RecursiveLock _lock = lock; - _lock.lock(); // sync: context/drawable could been recreated/destroyed while animating - try { - if( null != context ) { - helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction); - } - } finally { - _lock.unlock(); - } - } -} diff --git a/src/jogl/classes/jogamp/opengl/MemoryObject.java b/src/jogl/classes/jogamp/opengl/MemoryObject.java deleted file mode 100644 index 942d62b9e..000000000 --- a/src/jogl/classes/jogamp/opengl/MemoryObject.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.opengl; - -import java.nio.ByteBuffer; -import java.util.HashMap; - -import javax.media.opengl.GLBufferStorage; - -import com.jogamp.common.util.HashUtil; - -/** - * @deprecated No more used for GL buffer storage tracking, see {@link GLBufferStorage} and {@link GLBufferObjectTracker}. - */ -public class MemoryObject { - private final long addr; - private final long size; - private final int hash; - private ByteBuffer buffer=null; - public MemoryObject(final long addr, final long size) { - this.addr = addr; - this.size = size; - this.hash = HashUtil.getAddrSizeHash32_EqualDist(addr, size); - } - - public void setBuffer(final ByteBuffer buffer) { - this.buffer = buffer; - } - - public ByteBuffer getBuffer() { - return this.buffer; - } - - /** - * @return the 32bit hash value generated via {@link HashUtil#getAddrSizeHash32_EqualDist(long, long)}. - */ - @Override - public int hashCode() { - return hash; - } - - @Override - public String toString() { - return "MemoryObject[addr 0x"+Long.toHexString(addr)+", size 0x"+Long.toHexString(size)+", hash32: 0x"+Integer.toHexString(hash)+"]"; - } - - /** - * Ignores the optional attached <code>ByteBuffer</code> intentionally.<br> - * - * @return true of reference is equal or <code>obj</code> is of type <code>MemoryObject</code> - * and <code>addr</code> and <code>size</code> is equal.<br> - */ - public boolean equals(final Object obj) { - if(this == obj) { return true; } - if(obj instanceof MemoryObject) { - final MemoryObject m = (MemoryObject) obj; - return addr == m.addr && size == m.size ; - } - return false; - } - - /** - * @param map the identity HashMap, MemoryObject to MemoryObject - * @param obj0 the MemoryObject - * @return either the already mapped MemoryObject - not changing the map, or the newly mapped one. - */ - public static MemoryObject getOrAddSafe(final HashMap<MemoryObject,MemoryObject> map, final MemoryObject obj0) { - final MemoryObject obj1 = map.get(obj0); // get identity (fast) - if(null == obj1) { - map.put(obj0, obj0); - return obj0; - } else { - return obj1; - } - } - -}
\ No newline at end of file diff --git a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java index 330c4f044..003b9148e 100644 --- a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java +++ b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java @@ -673,11 +673,6 @@ public class ALAudioSink implements AudioSink { } @Override - public final AudioFrame enqueueData(final AudioDataFrame audioDataFrame) { - return enqueueData(audioDataFrame.getPTS(), audioDataFrame.getData(), audioDataFrame.getByteSize()); - } - - @Override public final AudioFrame enqueueData(final int pts, final ByteBuffer bytes, final int byteCount) { if( !initialized || null == chosenFormat ) { return null; diff --git a/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java b/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java index a24e77b7d..117be5489 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java +++ b/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java @@ -186,28 +186,22 @@ public class JavaSoundAudioSink implements AudioSink { } @Override - public AudioFrame enqueueData(final AudioDataFrame audioDataFrame) { - int byteSize = audioDataFrame.getByteSize(); - final ByteBuffer byteBuffer = audioDataFrame.getData(); - final byte[] bytes = new byte[byteSize]; + public AudioFrame enqueueData(final int pts, final ByteBuffer byteBuffer, final int byteCount) { + final byte[] bytes = new byte[byteCount]; final int p = byteBuffer.position(); - byteBuffer.get(bytes, 0, byteSize); + byteBuffer.get(bytes, 0, byteCount); byteBuffer.position(p); int written = 0; int len; - while (byteSize > 0) { - len = auline.write(bytes, written, byteSize); - byteSize -= len; + int bytesLeft = byteCount; + while (bytesLeft > 0) { + len = auline.write(bytes, written, byteCount); + bytesLeft -= len; written += len; } playImpl(); - return audioDataFrame; - } - - @Override - public AudioFrame enqueueData(final int pts, final ByteBuffer bytes, final int byteCount) { - return enqueueData(new AudioDataFrame(pts, chosenFormat.getBytesDuration(byteCount), bytes, byteCount)); + return new AudioDataFrame(pts, chosenFormat.getBytesDuration(byteCount), byteBuffer, byteCount); } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java b/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java index 3aa9d7ab6..7e27f17c3 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java @@ -171,11 +171,6 @@ public class NullAudioSink implements AudioSink { } @Override - public AudioFrame enqueueData(final AudioDataFrame audioDataFrame) { - return enqueueData(audioDataFrame.getPTS(), audioDataFrame.getData(), audioDataFrame.getByteSize()); - } - - @Override public AudioFrame enqueueData(final int pts, final ByteBuffer bytes, final int byteCount) { if( !initialized || null == chosenFormat ) { return null; diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index cf2d4c0d9..2d68c5788 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -154,12 +154,6 @@ public class MouseEvent extends InputEvent /** Maximum number of buttons, value <code>16</code> */ public static final short BUTTON_COUNT = 16; - /** - * Maximum number of buttons, value <code>16</code>. - * @deprecated Use {@link #BUTTON_COUNT} .. semantics. - */ - public static final short BUTTON_NUMBER = 16; - /** Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods). */ public static final float[] getRotationXYZ(final float rotationXorY, final int mods) { final float[] rotationXYZ = new float[] { 0f, 0f, 0f }; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java index 1e938c200..b3a0de845 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java @@ -39,8 +39,6 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLProfile; -import jogamp.opengl.GLDrawableFactoryImpl; - import org.junit.Test; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @@ -50,33 +48,11 @@ public class TestGLExtensionQueryOffscreen { public static void main(final String[] args) { final TestGLExtensionQueryOffscreen instance = new TestGLExtensionQueryOffscreen(); - instance.testJogl2ExtensionCheck1(); - instance.testJogl2ExtensionCheck2(); - } - - /** - * @deprecated This test uses a non public API in jogamp.opengl.* and hence is not recommended - */ - @Test - public void testJogl2ExtensionCheck1() { - final GLDrawableFactoryImpl factory = (GLDrawableFactoryImpl) GLDrawableFactory.getDesktopFactory(); - final GLContext sharedContext = factory.getOrCreateSharedContext(null); - sharedContext.makeCurrent(); - String extensions; - try { - extensions = sharedContext.getGL().glGetString(GL.GL_EXTENSIONS); - } finally { - sharedContext.release(); - } - final String[] tabExtensions = extensions.split(" "); - final SortedSet<String> setExtensions = new TreeSet<String>(); - Collections.addAll(setExtensions, tabExtensions); - System.out.println("SharedContext: "+sharedContext); - System.out.println("SharedContext: "+setExtensions); + instance.testJogl2ExtensionCheck(); } @Test - public void testJogl2ExtensionCheck2() { + public void testJogl2ExtensionCheck() { final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); final GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java index f91e34c12..a0e846d7d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java @@ -1,6 +1,7 @@ package com.jogamp.opengl.test.junit.jogl.acore; import jogamp.nativewindow.x11.X11Util; + import org.junit.Assert; import org.junit.Test; import org.junit.FixMethodOrder; @@ -10,22 +11,21 @@ import com.jogamp.newt.opengl.GLWindow; import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.DefaultGLCapabilitiesChooser; +import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLOffscreenAutoDrawable; -import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; /** - * Tests the closing the device of GLWindow and GLPBuffer in JOGL + * Tests the closing the device of GLWindow and off-screen GLAutoDrawable using FBO and PBuffer in JOGL */ -@SuppressWarnings("deprecation") @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestNEWTCloseX11DisplayBug565 { @Test - public void testX11WindowMemoryLeak() throws Exception { + public void test01X11WindowMemoryLeak() throws Exception { GLProfile.initSingleton(); // ensure shared resource runner is done try { for ( int j = 0; j < 10; j++ ) { @@ -64,7 +64,7 @@ public class TestNEWTCloseX11DisplayBug565 { @Test - public void testX11WindowMemoryLeakGLPbuffer() throws Exception { + public void test02X11WindowMemoryLeakPBufferAutoDrawable() throws Exception { GLProfile.initSingleton(); // ensure shared resource runner is done try { for ( int j = 0; j < 10; j++ ) { @@ -75,17 +75,9 @@ public class TestNEWTCloseX11DisplayBug565 { open0 = 0; } final GLProfile glp = GLProfile.getDefault( ); - final GLCapabilitiesImmutable caps = new GLCapabilities( glp ); - - - final GLPbuffer buffer = GLDrawableFactory.getFactory( glp ).createGLPbuffer( - null, - caps, - new DefaultGLCapabilitiesChooser(), - 256, - 256, - null - ); + final GLCapabilities caps = new GLCapabilities( glp ); + caps.setPBuffer(true); + final GLAutoDrawable buffer = GLDrawableFactory.getFactory( glp ).createOffscreenAutoDrawable(null, caps, null, 256, 256); buffer.display(); buffer.destroy(); @@ -106,7 +98,7 @@ public class TestNEWTCloseX11DisplayBug565 { } @Test - public void testX11WindowMemoryLeakFBOAutoDrawable() throws Exception { + public void test03X11WindowMemoryLeakFBOAutoDrawable() throws Exception { GLProfile.initSingleton(); // ensure shared resource runner is done try { for ( int j = 0; j < 10; j++ ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java index 7138513d5..ec377662f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java @@ -30,10 +30,9 @@ package com.jogamp.opengl.test.junit.jogl.acore; import java.awt.EventQueue; import java.lang.reflect.InvocationTargetException; -import javax.media.opengl.DefaultGLCapabilitiesChooser; +import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; import jogamp.nativewindow.jawt.JAWTUtil; @@ -47,7 +46,6 @@ import org.junit.runners.MethodSorters; import com.jogamp.common.util.RunnableTask; import com.jogamp.opengl.test.junit.util.UITestCase; -@SuppressWarnings("deprecation") @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestPBufferDeadlockAWT extends UITestCase { static GLProfile glp; @@ -62,12 +60,8 @@ public class TestPBufferDeadlockAWT extends UITestCase { } protected void runTestGL( final GLCapabilities caps ) throws InterruptedException, InvocationTargetException { - final GLPbuffer pbuffer = GLDrawableFactory.getFactory( GLProfile.getGL2ES2() ).createGLPbuffer( - null, - caps, new DefaultGLCapabilitiesChooser(), - 512, 512, - null - ); + caps.setPBuffer(true); + final GLAutoDrawable pbuffer = GLDrawableFactory.getFactory( caps.getGLProfile() ).createOffscreenAutoDrawable(null, caps, null, 512, 512); final boolean[] done = {false}; final Runnable pbufferCreationAction = new Runnable() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java index 19c96af14..c85c7467f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java @@ -57,7 +57,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil; /** - * Tests for bug 461, a failure of GLDrawableFactory.createGLPbuffer() on Windows + * Tests for bug 461, a failure of GLDrawableFactory.createOffscreenAutoDrawable(..) on Windows * when the stencil buffer is turned on. * * @author Wade Walker (from code sample provided by Owen Dimond) @@ -97,7 +97,6 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL /* @Override */ public void display(final GLAutoDrawable drawable) { render(offScreenBuffer); - // BufferedImage outputImage = com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(200, 200, false); final BufferedImage outputImage = awtGLReadBufferUtil.readPixelsToBufferedImage(drawable.getGL(), 0, 0, 200, 200, true /* awtOrientation */); Assert.assertNotNull(outputImage); final ImageIcon imageIcon = new ImageIcon(outputImage); @@ -145,14 +144,13 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL final GLDrawableFactory fac = GLDrawableFactory.getFactory(glp); Assert.assertNotNull(fac); - Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice(), glp) ); - final GLCapabilities glCap = new GLCapabilities(glp); Assert.assertNotNull(glCap); // COMMENTING OUT THIS LINE FIXES THE ISSUE. // Setting this in JOGL1 works. Thus this is a JOGL2 issue. glCap.setSampleBuffers(true); + glCap.setNumSamples(4); // Without line below, there is an error on Windows. // glCap.setDoubleBuffered(false); // implicit double buffer -> MSAA + FBO diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java index 1e0f8fe4a..85bf2ceb3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java @@ -30,7 +30,6 @@ package com.jogamp.opengl.test.junit.jogl.awt; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; - import java.awt.image.BufferedImage; import java.lang.reflect.InvocationTargetException; @@ -40,7 +39,7 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLPbuffer; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLProfile; import javax.swing.ImageIcon; import javax.swing.JFrame; @@ -52,18 +51,19 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil; /** - * Tests for bug 461, a failure of GLDrawableFactory.createGLPbuffer() on Windows + * Tests for bug 461, a failure of PBuffer GLDrawableFactory.createOffscreenAutoDrawable(..) on Windows * when the stencil buffer is turned on. * - * @author Wade Walker (from code sample provided by Owen Dimond) + * @author Wade Walker (from code sample provided by Owen Dimond), et al. */ -@SuppressWarnings("deprecation") @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implements GLEventListener { JFrame jframe; - GLPbuffer offScreenBuffer; + GLOffscreenAutoDrawable offScreenBuffer; + AWTGLReadBufferUtil screenshot; private void render(final GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); @@ -83,6 +83,7 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement /* @Override */ public void init(final GLAutoDrawable drawable) { + screenshot = new AWTGLReadBufferUtil(drawable.getGLProfile(), false); } /* @Override */ @@ -92,7 +93,7 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement /* @Override */ public void display(final GLAutoDrawable drawable) { render(offScreenBuffer); - final BufferedImage outputImage = com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(200, 200, false); + final BufferedImage outputImage = screenshot.readPixelsToBufferedImage(drawable.getGL(), 0, 0, 200, 200, true /* awtOrientation */); Assert.assertNotNull(outputImage); final ImageIcon imageIcon = new ImageIcon(outputImage); final JLabel imageLabel = new JLabel(imageIcon); @@ -101,6 +102,7 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement /* @Override */ public void dispose(final GLAutoDrawable drawable) { + screenshot.dispose(drawable.getGL()); try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -113,7 +115,23 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement } @Test - public void testOffscreenSupersampling() throws InterruptedException, InvocationTargetException { + public void test01DefaultOffscreenSupersampling() throws InterruptedException, InvocationTargetException { + final GLProfile glp = GLProfile.get(GLProfile.GL2); + Assert.assertNotNull(glp); + final GLCapabilities glCap = new GLCapabilities(glp); + test(glCap); + } + + @Test + public void test02PBufferOffscreenSupersampling() throws InterruptedException, InvocationTargetException { + final GLProfile glp = GLProfile.get(GLProfile.GL2); + Assert.assertNotNull(glp); + final GLCapabilities glCap = new GLCapabilities(glp); + glCap.setPBuffer(true); + test(glCap); + } + + void test(final GLCapabilities glCap) throws InterruptedException, InvocationTargetException { jframe = new JFrame("Offscreen Supersampling"); Assert.assertNotNull(jframe); jframe.setSize( 300, 300); @@ -123,20 +141,13 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement } }); - final GLProfile glp = GLProfile.get(GLProfile.GL2); - Assert.assertNotNull(glp); - - final GLDrawableFactory fac = GLDrawableFactory.getFactory(glp); + final GLDrawableFactory fac = GLDrawableFactory.getFactory(glCap.getGLProfile()); Assert.assertNotNull(fac); - Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice(), glp) ); - - final GLCapabilities glCap = new GLCapabilities(glp); - Assert.assertNotNull(glCap); - // COMMENTING OUT THIS LINE FIXES THE ISSUE. // Setting this in JOGL1 works. Thus this is a JOGL2 issue. glCap.setSampleBuffers(true); + glCap.setNumSamples(4); // Without line below, there is an error on Windows. glCap.setDoubleBuffered(false); @@ -144,7 +155,7 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement glCap.setStencilBits(1); //makes a new buffer - offScreenBuffer = fac.createGLPbuffer(GLProfile.getDefaultDevice(), glCap, null, 200, 200, null); + offScreenBuffer = fac.createOffscreenAutoDrawable(null, glCap, null, 200, 200); Assert.assertNotNull(offScreenBuffer); offScreenBuffer.addGLEventListener(this); offScreenBuffer.display(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java index a42564dbc..c1b29b371 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java @@ -28,7 +28,6 @@ package com.jogamp.opengl.test.junit.jogl.caps; import java.io.File; -import java.io.IOException; import javax.media.opengl.GL; import javax.media.opengl.GL2; @@ -41,7 +40,7 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import javax.media.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.opengl.util.awt.Screenshot; +import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil; import com.jogamp.opengl.util.texture.TextureIO; import java.awt.image.BufferedImage; @@ -56,6 +55,8 @@ import com.jogamp.opengl.test.junit.util.UITestCase; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestBug605FlippedImageAWT extends UITestCase { class FlippedImageTest implements GLEventListener { + AWTGLReadBufferUtil screenshot; + public void display(final GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); @@ -87,34 +88,35 @@ public class TestBug605FlippedImageAWT extends UITestCase { final int height = drawable.getSurfaceHeight(); final String fname = getSnapshotFilename(0, null, caps, width, height, false, TextureIO.PNG, null); + final BufferedImage image; try { - Screenshot.writeToFile(new File(fname), width, height, false); + image = screenshot.readPixelsToBufferedImage(gl, 0, 0, width, height, true /* awtOrientation */); + screenshot.write(new File(fname)); } catch (final GLException e) { throw e; - } catch (final IOException e) { - throw new GLException(e); } - testFlipped(width, height); + testFlipped(image, width, height); } public void init(final GLAutoDrawable drawable) { final GL gl = drawable.getGL(); System.err.println("GL_RENDERER: "+gl.glGetString(GL.GL_RENDERER)); System.err.println("GL_VERSION: "+gl.glGetString(GL.GL_VERSION)); + screenshot = new AWTGLReadBufferUtil(drawable.getGLProfile(), false); } public void reshape(final GLAutoDrawable glDrawable, final int x, final int y, final int w, final int h) {} public void displayChanged(final GLAutoDrawable drawable, final boolean modeChanged, final boolean deviceChanged) {} - public void dispose(final GLAutoDrawable drawable) {} + public void dispose(final GLAutoDrawable drawable) { + screenshot.dispose(drawable.getGL()); + } } static final int green = 0x0000ff00; // above static final int red = 0x00ff0000; // below - private void testFlipped(final int width, final int height) { + private void testFlipped(final BufferedImage image, final int width, final int height) { // Default origin 0/0 is lower left corner, so is the memory layout // However AWT origin 0/0 is upper left corner - final BufferedImage image = Screenshot.readToBufferedImage(width, height); - final int below = image.getRGB(0, height-1) & 0x00ffffff; System.err.println("below: 0x"+Integer.toHexString(below)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java index 32e0be3e1..96db8e564 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java @@ -32,6 +32,7 @@ import com.jogamp.opengl.util.glsl.ShaderState; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLBufferStorage; import javax.media.opengl.GLDrawable; import org.junit.Assert; @@ -55,7 +56,8 @@ public class GLSLMiscHelper { Assert.assertEquals(data.enabled()?GL.GL_TRUE:GL.GL_FALSE, qi[0]); gl.glGetVertexAttribiv(data.getLocation(), GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, qi, 0); Assert.assertEquals(data.getVBOName(), qi[0]); - Assert.assertEquals(data.getSizeInBytes(), gl.glGetBufferSize(data.getVBOName())); + final GLBufferStorage glStore = gl.getBufferStorage(data.getVBOName()); + Assert.assertEquals("GLBufferStorage size mismatch, storage "+glStore, data.getSizeInBytes(), null != glStore ? glStore.getSize() : -1); } public static void pause(final long ms) throws InterruptedException { |