diff options
Diffstat (limited to 'src')
57 files changed, 343 insertions, 1587 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 169266152..ff764d849 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -589,6 +589,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } @Override + public boolean isGLOriented() { + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.isGLOriented() : true; + } + + @Override public void addGLEventListener(final GLEventListener listener) { helper.addGLEventListener(listener); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java index b8709f31c..1345d29bd 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java @@ -111,11 +111,15 @@ public class GLReadBufferUtil { * * @param gl the current GL context object. It's read drawable is being used as the pixel source. * @param drawable the drawable to read from - * @param flip weather to flip the data vertically or not + * @param mustFlipVertically indicates weather to flip the data vertically or not. + * The context's drawable {@link GLDrawable#isGLOriented()} state + * is taken into account. + * Vertical flipping is propagated to TextureData + * and handled in a efficient manner there (TextureCoordinates and TextureIO writer). * * @see #GLReadBufferUtil(boolean, boolean) */ - public boolean readPixels(GL gl, boolean flip) { + public boolean readPixels(GL gl, boolean mustFlipVertically) { final int glerr0 = gl.glGetError(); if(GL.GL_NO_ERROR != glerr0) { System.err.println("Info: GLReadBufferUtil.readPixels: pre-exisiting GL error 0x"+Integer.toHexString(glerr0)); @@ -124,6 +128,13 @@ public class GLReadBufferUtil { final int textureInternalFormat, textureDataFormat, textureDataType; final int[] glImplColorReadVals = new int[] { 0, 0 }; + final boolean flipVertically; + if( drawable.isGLOriented() ) { + flipVertically = mustFlipVertically; + } else { + flipVertically = !mustFlipVertically; + } + if(gl.isGL2GL3() && 3 == components) { textureInternalFormat=GL.GL_RGB; textureDataFormat=GL.GL_RGB; @@ -158,7 +169,7 @@ public class GLReadBufferUtil { textureDataFormat, textureDataType, false, false, - flip, + flipVertically, readPixelBuffer, null /* Flusher */); newData = true; diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java b/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java index 0022d5c2d..0eab65380 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java @@ -1,5 +1,6 @@ /* * 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 @@ -43,17 +44,24 @@ 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 javax.media.opengl.glu.gl2.GLUgl2; 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. */ - +/** + * 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}. + */ public class Screenshot { private Screenshot() {} @@ -149,17 +157,17 @@ public class Screenshot { writer.open(file, width, height, alpha); ByteBuffer bgr = writer.getImageData(); - GL2 gl = GLUgl2.getCurrentGL2(); + GL gl = GLContext.getCurrentGL(); // Set up pixel storage modes GLPixelStorageModes psm = new GLPixelStorageModes(); psm.setPackAlignment(gl, 1); - int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2.GL_BGR); + 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, - GL2.GL_UNSIGNED_BYTE, bgr); + GL.GL_UNSIGNED_BYTE, bgr); // Restore pixel storage modes psm.restore(gl); @@ -247,7 +255,7 @@ public class Screenshot { int height, boolean alpha) throws GLException { int bufImgType = (alpha ? BufferedImage.TYPE_4BYTE_ABGR : BufferedImage.TYPE_3BYTE_BGR); - int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2.GL_BGR); + int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2GL3.GL_BGR); if (alpha) { checkExtABGR(); @@ -256,7 +264,8 @@ public class Screenshot { // Allocate necessary storage BufferedImage image = new BufferedImage(width, height, bufImgType); - GL2 gl = GLUgl2.getCurrentGL2(); + GLContext glc = GLContext.getCurrent(); + GL gl = glc.getGL(); // Set up pixel storage modes GLPixelStorageModes psm = new GLPixelStorageModes(); @@ -264,14 +273,16 @@ public class Screenshot { // read the BGR values into the image gl.glReadPixels(x, y, width, height, readbackType, - GL2.GL_UNSIGNED_BYTE, + GL.GL_UNSIGNED_BYTE, ByteBuffer.wrap(((DataBufferByte) image.getRaster().getDataBuffer()).getData())); // Restore pixel storage modes psm.restore(gl); - // Must flip BufferedImage vertically for correct results - ImageUtil.flipImageVertically(image); + if( glc.getGLDrawable().isGLOriented() ) { + // Must flip BufferedImage vertically for correct results + ImageUtil.flipImageVertically(image); + } return image; } @@ -392,7 +403,8 @@ public class Screenshot { } private static void checkExtABGR() { - GL2 gl = GLUgl2.getCurrentGL2(); + 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/com/jogamp/opengl/util/texture/TextureIO.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java index 0b0af5625..14ceb6421 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java @@ -1408,7 +1408,7 @@ public class TextureIO { buf.rewind(); PNGImage image = PNGImage.createFromData(data.getWidth(), data.getHeight(), -1f, -1f, - bytesPerPixel, reversedChannels, buf); + bytesPerPixel, reversedChannels, !data.getMustFlipVertically(), buf); image.write(file, true); return true; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java index 847451b41..b4b00e744 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java @@ -53,20 +53,39 @@ import com.jogamp.common.util.IOUtil; public class PNGImage { private static final boolean DEBUG = Debug.debug("PNGImage"); - /** Creates a PNGImage from data supplied by the end user. Shares - data with the passed ByteBuffer. Assumes the data is already in - the correct byte order for writing to disk, i.e., LUMINANCE, RGB or RGBA bottom-to-top (OpenGL coord). */ + /** + * Creates a PNGImage from data supplied by the end user. Shares + * data with the passed ByteBuffer. Assumes the data is already in + * the correct byte order for writing to disk, i.e., LUMINANCE, RGB or RGBA. + * Orientation is <i>bottom-to-top</i> (OpenGL coord. default) + * or <i>top-to-bottom</i> depending on <code>isGLOriented</code>. + * + * @param width + * @param height + * @param dpiX + * @param dpiY + * @param bytesPerPixel + * @param reversedChannels + * @param isGLOriented see {@link #isGLOriented()}. + * @param data + * @return + */ public static PNGImage createFromData(int width, int height, double dpiX, double dpiY, - int bytesPerPixel, boolean reversedChannels, ByteBuffer data) { - return new PNGImage(width, height, dpiX, dpiY, bytesPerPixel, reversedChannels, data); + int bytesPerPixel, boolean reversedChannels, boolean isGLOriented, ByteBuffer data) { + return new PNGImage(width, height, dpiX, dpiY, bytesPerPixel, reversedChannels, isGLOriented, data); } - /** Reads a PNG image from the specified InputStream. */ + /** + * Reads a PNG image from the specified InputStream. + * <p> + * Implicitly flip image to GL orientation, see {@link #isGLOriented()}. + * </p> + */ public static PNGImage read(InputStream in) throws IOException { return new PNGImage(in); } - /** Reverse read and store, implicitly flip image to GL coords. */ + /** Reverse read and store, implicitly flip image to GL orientation, see {@link #isGLOriented()}. */ private static final int getPixelRGBA8(ByteBuffer d, int dOff, int[] scanline, int lineOff, boolean hasAlpha) { if(hasAlpha) { d.put(dOff--, (byte)scanline[lineOff + 3]); // A @@ -76,27 +95,28 @@ public class PNGImage { d.put(dOff--, (byte)scanline[lineOff ]); // R return dOff; } - /** Reverse read and store, implicitly flip image from GL coords. Handle reversed channels (BGR[A])*/ - private static int setPixelRGBA8(ImageLine line, int lineOff, ByteBuffer d, int dOff, boolean hasAlpha, boolean reversedChannels) { - if(reversedChannels) { - line.scanline[lineOff ] = d.get(dOff--); // R, A - line.scanline[lineOff + 1] = d.get(dOff--); // G, B - line.scanline[lineOff + 2] = d.get(dOff--); // B, G + + /** Reverse write and store, implicitly flip image from current orientation, see {@link #isGLOriented()}. Handle reversed channels (BGR[A]). */ + private int setPixelRGBA8(ImageLine line, int lineOff, ByteBuffer d, int dOff, boolean hasAlpha) { + if( reversedChannels ) { if(hasAlpha) { - line.scanline[lineOff + 3] = d.get(dOff--);// R + line.scanline[lineOff + 3] = d.get(dOff++); // A } + line.scanline[lineOff + 2] = d.get(dOff++); // R + line.scanline[lineOff + 1] = d.get(dOff++); // G + line.scanline[lineOff ] = d.get(dOff++); // B } else { + line.scanline[lineOff ] = d.get(dOff++); // R + line.scanline[lineOff + 1] = d.get(dOff++); // G + line.scanline[lineOff + 2] = d.get(dOff++); // B if(hasAlpha) { - line.scanline[lineOff + 3] = d.get(dOff--); // A + line.scanline[lineOff + 3] = d.get(dOff++); // A } - line.scanline[lineOff + 2] = d.get(dOff--); // B - line.scanline[lineOff + 1] = d.get(dOff--); // G - line.scanline[lineOff ] = d.get(dOff--); // R } - return dOff; + return isGLOriented ? dOff - bytesPerPixel - bytesPerPixel : dOff; } - private PNGImage(int width, int height, double dpiX, double dpiY, int bytesPerPixel, boolean reversedChannels, ByteBuffer data) { + private PNGImage(int width, int height, double dpiX, double dpiY, int bytesPerPixel, boolean reversedChannels, boolean isGLOriented, ByteBuffer data) { pixelWidth=width; pixelHeight=height; dpi = new double[] { dpiX, dpiY }; @@ -109,6 +129,7 @@ public class PNGImage { } this.bytesPerPixel = bytesPerPixel; this.reversedChannels = reversedChannels; + this.isGLOriented = isGLOriented; this.data = data; } @@ -162,13 +183,14 @@ public class PNGImage { data = Buffers.newDirectByteBuffer(bytesPerPixel * pixelWidth * pixelHeight); reversedChannels = false; // RGB[A] + isGLOriented = true; int dataOff = bytesPerPixel * pixelWidth * pixelHeight - 1; // start at end-of-buffer, reverse store int[] rgbaScanline = indexed ? new int[imgInfo.cols * channels] : null; for (int row = 0; row < pixelHeight; row++) { final ImageLine l1 = pngr.readRow(row); - int lineOff = ( pixelWidth - 1 ) * bytesPerPixel ; // start w/ last pixel in line, reverse read + int lineOff = ( pixelWidth - 1 ) * bytesPerPixel ; // start w/ last pixel in line, reverse read (PNG top-left -> OpenGL bottom-left origin) if( indexed ) { for (int j = pixelWidth - 1; j >= 0; j--) { rgbaScanline = ImageLineHelper.palette2rgb(l1, plte, trns, rgbaScanline); // reuse rgbaScanline and update if resized @@ -189,7 +211,8 @@ public class PNGImage { pngr.end(); } private final int pixelWidth, pixelHeight, glFormat, bytesPerPixel; - private boolean reversedChannels; + private final boolean reversedChannels; + private final boolean isGLOriented; private final double[] dpi; private final ByteBuffer data; @@ -202,6 +225,16 @@ public class PNGImage { /** Returns true if data has the channels reversed to BGR or BGRA, otherwise RGB or RGBA is expected. */ public boolean getHasReversedChannels() { return reversedChannels; } + /** + * Returns <code>true</code> if the drawable is rendered in + * OpenGL's coordinate system, <i>origin at bottom left</i>. + * Otherwise returns <code>false</code>, i.e. <i>origin at top left</i>. + * <p> + * Default impl. is <code>true</code>, i.e. OpenGL coordinate system. + * </p> + */ + public boolean isGLOriented() { return isGLOriented; } + /** Returns the dpi of the image. */ public double[] getDpi() { return dpi; } @@ -231,20 +264,40 @@ public class PNGImage { // png.getMetadata().setText("my key", "my text"); final boolean hasAlpha = 4 == bytesPerPixel; final ImageLine l1 = new ImageLine(imi); - int dataOff = bytesPerPixel * pixelWidth * pixelHeight - 1; // start at end-of-buffer, reverse read - for (int row = 0; row < pixelHeight; row++) { - int lineOff = ( pixelWidth - 1 ) * bytesPerPixel ; // start w/ last pixel in line, reverse store - if(1 == bytesPerPixel) { - for (int j = pixelWidth - 1; j >= 0; j--) { - l1.scanline[lineOff--] = data.get(dataOff--); // // Luminance, 1 bytesPerPixel - } - } else { - for (int j = pixelWidth - 1; j >= 0; j--) { - dataOff = setPixelRGBA8(l1, lineOff, data, dataOff, hasAlpha, reversedChannels); - lineOff -= bytesPerPixel; + if( isGLOriented ) { + // start at last pixel at end-of-buffer, reverse read (OpenGL bottom-left -> PNG top-left origin) + int dataOff = ( pixelWidth * bytesPerPixel * ( pixelHeight - 1 ) ) + // full lines - 1 line + ( ( pixelWidth - 1 ) * bytesPerPixel ); // one line - 1 pixel + for (int row = 0; row < pixelHeight; row++) { + int lineOff = ( pixelWidth - 1 ) * bytesPerPixel ; // start w/ last pixel in line, reverse store (OpenGL bottom-left -> PNG top-left origin) + if(1 == bytesPerPixel) { + for (int j = pixelWidth - 1; j >= 0; j--) { + l1.scanline[lineOff--] = data.get(dataOff--); // // Luminance, 1 bytesPerPixel + } + } else { + for (int j = pixelWidth - 1; j >= 0; j--) { + dataOff = setPixelRGBA8(l1, lineOff, data, dataOff, hasAlpha); + lineOff -= bytesPerPixel; + } } + png.writeRow(l1, row); } - png.writeRow(l1, row); + } else { + int dataOff = 0; // start at first pixel at start-of-buffer, normal read (same origin: top-left) + for (int row = 0; row < pixelHeight; row++) { + int lineOff = 0; // start w/ first pixel in line, normal store (same origin: top-left) + if(1 == bytesPerPixel) { + for (int j = pixelWidth - 1; j >= 0; j--) { + l1.scanline[lineOff++] = data.get(dataOff++); // // Luminance, 1 bytesPerPixel + } + } else { + for (int j = pixelWidth - 1; j >= 0; j--) { + dataOff = setPixelRGBA8(l1, lineOff, data, dataOff, hasAlpha); + lineOff += bytesPerPixel; + } + } + png.writeRow(l1, row); + } } png.end(); } finally { diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java index 09db70f64..5b3eb9119 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java @@ -75,11 +75,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil private boolean sampleBuffers = false; private int numSamples = 2; - // Bits for pbuffer creation - private boolean pbufferFloatingPointBuffers; - private boolean pbufferRenderToTexture; - private boolean pbufferRenderToTextureRectangle; - /** Creates a GLCapabilities object. All attributes are in a default state. * @param glp GLProfile, or null for the default GLProfile * @throws GLException if no profile is given and no default profile is available for the default device. @@ -122,9 +117,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil accumBlueBits = source.getAccumBlueBits(); accumAlphaBits = source.getAccumAlphaBits(); sampleBuffers = source.getSampleBuffers(); - pbufferFloatingPointBuffers = source.getPbufferFloatingPointBuffers(); - pbufferRenderToTexture = source.getPbufferRenderToTexture(); - pbufferRenderToTextureRectangle = source.getPbufferRenderToTextureRectangle(); numSamples = source.getNumSamples(); sampleExtension = source.getSampleExtension(); return this; @@ -148,9 +140,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil hash = ((hash << 5) - hash) + this.accumGreenBits; hash = ((hash << 5) - hash) + this.accumBlueBits; hash = ((hash << 5) - hash) + this.accumAlphaBits; - hash = ((hash << 5) - hash) + ( this.pbufferFloatingPointBuffers ? 1 : 0 ); - hash = ((hash << 5) - hash) + ( this.pbufferRenderToTexture ? 1 : 0 ); - hash = ((hash << 5) - hash) + ( this.pbufferRenderToTextureRectangle ? 1 : 0 ); return hash; } @@ -174,10 +163,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil other.getAccumGreenBits()==accumGreenBits && other.getAccumBlueBits()==accumBlueBits && other.getAccumAlphaBits()==accumAlphaBits && - other.getSampleBuffers()==sampleBuffers && - other.getPbufferFloatingPointBuffers()==pbufferFloatingPointBuffers && - other.getPbufferRenderToTexture()==pbufferRenderToTexture && - other.getPbufferRenderToTextureRectangle()==pbufferRenderToTextureRectangle; + other.getSampleBuffers()==sampleBuffers; if(res && sampleBuffers) { res = other.getNumSamples()==getNumSamples() && other.getSampleExtension().equals(sampleExtension) ; @@ -449,40 +435,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil return sampleBuffers ? numSamples : 0; } - /** For pbuffers only, indicates whether floating-point buffers - should be used if available. Defaults to false. */ - public void setPbufferFloatingPointBuffers(boolean enable) { - pbufferFloatingPointBuffers = enable; - } - - @Override - public final boolean getPbufferFloatingPointBuffers() { - return pbufferFloatingPointBuffers; - } - - /** For pbuffers only, indicates whether the render-to-texture - extension should be used if available. Defaults to false. */ - public void setPbufferRenderToTexture(boolean enable) { - pbufferRenderToTexture = enable; - } - - @Override - public final boolean getPbufferRenderToTexture() { - return pbufferRenderToTexture; - } - - /** For pbuffers only, indicates whether the - render-to-texture-rectangle extension should be used if - available. Defaults to false. */ - public void setPbufferRenderToTextureRectangle(boolean enable) { - pbufferRenderToTextureRectangle = enable; - } - - @Override - public final boolean getPbufferRenderToTextureRectangle() { - return pbufferRenderToTextureRectangle; - } - @Override public StringBuilder toString(StringBuilder sink) { if(null == sink) { @@ -526,10 +478,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil } if(isPBuffer()) { if(ns) { sink.append(CSEP); } - sink.append("pbuffer [r2t ").append(pbufferRenderToTexture?1:0) - .append(", r2tr ").append(pbufferRenderToTextureRectangle?1:0) - .append(", float ").append(pbufferFloatingPointBuffers?1:0) - .append("]"); + sink.append("pbuffer"); ns = true; } if(isBitmap()) { diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java index ee261ca01..6af35021f 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java @@ -130,33 +130,6 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { int getNumSamples(); /** - * For pbuffers only, returns whether floating-point buffers should - * be used if available. - * <p> - * Default is false. - * </p> - */ - boolean getPbufferFloatingPointBuffers(); - - /** - * For pbuffers only, returns whether the render-to-texture - * extension should be used if available. - * <p> - * Default is false. - * </p> - */ - boolean getPbufferRenderToTexture(); - - /** - * For pbuffers only, returns whether the render-to-texture - * extension should be used. - * <p> - * Default is false. - * </p> - */ - boolean getPbufferRenderToTextureRectangle(); - - /** * Returns the number of stencil buffer bits. * <p> * Default is 0. diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 23ca96504..d26076344 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -1026,16 +1026,6 @@ public abstract class GLContext { */ public abstract int getDefaultReadBuffer(); - /** On some platforms the mismatch between OpenGL's coordinate - system (origin at bottom left) and the window system's - coordinate system (origin at top left) necessitates a vertical - flip of pixels read from offscreen contexts. - <p> - Default impl. is <code>true</code>. - </p> - */ - public abstract boolean isGLOrientationFlippedVertical(); - /** Get the default pixel data type, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}. */ public abstract int getDefaultPixelDataType(); diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java index 65c8b2ea5..369ea6d2b 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java @@ -145,6 +145,20 @@ public interface GLDrawable { /** Returns the current height of this GLDrawable. */ public int getHeight(); + /** + * Returns <code>true</code> if the drawable is rendered in + * OpenGL's coordinate system, <i>origin at bottom left</i>. + * Otherwise returns <code>false</code>, i.e. <i>origin at top left</i>. + * <p> + * Default impl. is <code>true</code>, i.e. OpenGL coordinate system. + * </p> + * <p> + * Currently only MS-Windows bitmap offscreen drawable uses a non OpenGL orientation and hence returns <code>false</code>.<br/> + * This removes the need of a vertical flip when used in AWT or Windows applications. + * </p> + */ + public boolean isGLOriented(); + /** Swaps the front and back buffers of this drawable. For {@link GLAutoDrawable} implementations, when automatic buffer swapping is enabled (as is the default), this method is called diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index e775afbff..9feb54a46 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -114,9 +114,6 @@ public abstract class GLDrawableFactory { */ protected static final boolean disableOpenGLES = Debug.isPropertyDefined("jogl.disable.opengles", true); - static final String macosxFactoryClassNameCGL = "jogamp.opengl.macosx.cgl.MacOSXCGLDrawableFactory"; - static final String macosxFactoryClassNameAWTCGL = "jogamp.opengl.macosx.cgl.awt.MacOSXAWTCGLDrawableFactory"; - private static volatile boolean isInit = false; private static GLDrawableFactory eglFactory; private static GLDrawableFactory nativeOSFactory; @@ -154,11 +151,7 @@ public abstract class GLDrawableFactory { } else if ( nwt == NativeWindowFactory.TYPE_WINDOWS ) { factoryClassName = "jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory"; } else if ( nwt == NativeWindowFactory.TYPE_MACOSX ) { - if(ReflectionUtil.isClassAvailable(macosxFactoryClassNameAWTCGL, cl)) { - factoryClassName = macosxFactoryClassNameAWTCGL; - } else { - factoryClassName = macosxFactoryClassNameCGL; - } + factoryClassName = "jogamp.opengl.macosx.cgl.MacOSXCGLDrawableFactory"; } else { // may use egl*Factory .. if (DEBUG || GLProfile.DEBUG) { diff --git a/src/jogl/classes/javax/media/opengl/GLPbuffer.java b/src/jogl/classes/javax/media/opengl/GLPbuffer.java index de7731a3b..12f57fcd8 100644 --- a/src/jogl/classes/javax/media/opengl/GLPbuffer.java +++ b/src/jogl/classes/javax/media/opengl/GLPbuffer.java @@ -50,32 +50,7 @@ package javax.media.opengl; @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 { - /** Indicates the GL_APPLE_float_pixels extension is being used for this pbuffer. */ - public static final int APPLE_FLOAT = 1; - - /** Indicates the GL_ATI_texture_float extension is being used for this pbuffer. */ - public static final int ATI_FLOAT = 2; - - /** Indicates the GL_NV_float_buffer extension is being used for this pbuffer. */ - public static final int NV_FLOAT = 3; - - /** Binds this pbuffer to its internal texture target. Only valid to - call if offscreen render-to-texture has been specified in the - NWCapabilities for this GLPbuffer. If the - render-to-texture-rectangle capability has also been specified, - this will use e.g. wglBindTexImageARB as its implementation and - cause the texture to be bound to e.g. the - GL_TEXTURE_RECTANGLE_NV state; otherwise, during the display() - phase the pixels will have been copied into an internal texture - target and this will cause that to be bound to the GL_TEXTURE_2D - state. */ - public void bindTexture(); - - /** Unbinds the pbuffer from its internal texture target. */ - public void releaseTexture(); - /** 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 @@ -84,13 +59,4 @@ public interface GLPbuffer extends GLAutoDrawable { #createContext}. */ @Override public void destroy(); - - /** Indicates which vendor's extension is being used to support - floating point channels in this pbuffer if that capability was - requested in the NWCapabilities during pbuffer creation. Returns - one of NV_FLOAT, ATI_FLOAT or APPLE_FLOAT, or throws GLException - if floating-point channels were not requested for this pbuffer. - This function may only be called once the init method for this - pbuffer's GLEventListener has been called. */ - public int getFloatingPointMode(); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index c1d5fb1d2..b7a24a777 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -887,6 +887,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } @Override + public boolean isGLOriented() { + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.isGLOriented() : true; + } + + @Override public NativeSurface getNativeSurface() { final GLDrawable _drawable = drawable; return (null != _drawable) ? _drawable.getNativeSurface() : null; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index e82ad54c3..6ef695319 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -83,17 +83,12 @@ import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableHelper; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.awt.Java2D; -import jogamp.opengl.awt.Java2DGLContext; import jogamp.opengl.util.glsl.GLSLTextureRaster; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.util.GLPixelStorageModes; -// FIXME: Subclasses need to call resetGLFunctionAvailability() on their -// context whenever the displayChanged() function is called on their -// GLEventListeners - /** A lightweight Swing component which provides OpenGL rendering support. Provided for compatibility with Swing user interfaces when adding a heavyweight doesn't work either because of @@ -627,6 +622,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override + public boolean isGLOriented() { + if(null != backend) { + return backend.getDrawable().isGLOriented(); + } + return true; + } + + @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { return backend.getChosenGLCapabilities(); } @@ -916,7 +919,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final int fboTextureUnit = 0; private GLContextImpl offscreenContext; - private boolean flippedVertical; + private boolean flipVertical; // For saving/restoring of OpenGL state during ReadPixels private final GLPixelStorageModes psm = new GLPixelStorageModes(); @@ -941,9 +944,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { isInitialized = true; final GL gl = offscreenContext.getGL(); - flippedVertical = offscreenContext.isGLOrientationFlippedVertical(); + flipVertical = offscreenDrawable.isGLOriented(); final GLCapabilitiesImmutable chosenCaps = offscreenDrawable.getChosenGLCapabilities(); - if( USE_GLSL_TEXTURE_RASTERIZER && chosenCaps.isFBO() && flippedVertical && gl.isGL2ES2() ) { + if( USE_GLSL_TEXTURE_RASTERIZER && chosenCaps.isFBO() && flipVertical && gl.isGL2ES2() ) { final boolean _autoSwapBufferMode = helper.getAutoSwapBufferMode(); helper.setAutoSwapBufferMode(false); final GLFBODrawable fboDrawable = (GLFBODrawable) offscreenDrawable; @@ -1054,14 +1057,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing glType = GL.GL_UNSIGNED_BYTE; // offscreenContext.getDefaultPixelDataType(); offscreenImage = new BufferedImage(panelWidth, panelHeight, withAlpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB); - if(!flippedVertical || null != glslTextureRaster) { + if(!flipVertical || null != glslTextureRaster) { final int[] readBackIntBuffer = ((DataBufferInt) offscreenImage.getRaster().getDataBuffer()).getData(); readBackInts = IntBuffer.wrap(readBackIntBuffer); } else { readBackInts = IntBuffer.allocate(readBackWidthInPixels * readBackHeightInPixels); } if(DEBUG) { - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: flippedVertical "+flippedVertical+", glslTextureRaster "+(null!=glslTextureRaster)); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster)); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: panelSize "+panelWidth+"x"+panelHeight +", readBackSizeInPixels "+readBackWidthInPixels+"x"+readBackHeightInPixels); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: offscreenImage "+offscreenImage.getWidth()+"x"+offscreenImage.getHeight()); } @@ -1101,7 +1104,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } else { gl.glReadPixels(0, 0, readBackWidthInPixels, readBackHeightInPixels, glFormat, glType, readBackInts); - if ( flippedVertical ) { + if ( flipVertical ) { // Copy temporary data into raster of BufferedImage for faster // blitting Note that we could avoid this copy in the cases // where !offscreenContext.offscreenImageNeedsVerticalFlip(), @@ -1641,28 +1644,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing System.err.println("-- Created External Drawable: "+joglDrawable); System.err.println("-- Created Context: "+joglContext); } - } else if (factory.canCreateContextOnJava2DSurface(device)) { - // Mac OS X code path - joglContext = factory.createContextOnJava2DSurface(g, j2dContext); - if (DEBUG) { - System.err.println("-- Created Context: "+joglContext); - } } - /*if (DEBUG) { - joglContext.setGL(new DebugGL2(joglContext.getGL().getGL2())); - }*/ - if (Java2D.isFBOEnabled() && Java2D.getOGLSurfaceType(g) == Java2D.FBOBJECT && fbObjectWorkarounds) { createNewDepthBuffer = true; } } - if (joglContext instanceof Java2DGLContext) { - // Mac OS X code path - ((Java2DGLContext) joglContext).setGraphics(g); - } - helper.invokeGL(joglDrawable, joglContext, updaterDisplayAction, updaterInitAction); } } finally { diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index 705f8b94e..53fe6c3c9 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -655,6 +655,12 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe } @Override + public boolean isGLOriented() { + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.isGLOriented() : true; + } + + @Override public final GLCapabilitiesImmutable getChosenGLCapabilities() { final GLDrawable _drawable = drawable; return null != _drawable ? _drawable.getChosenGLCapabilities() : null; diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 7b760ed0e..883f90591 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1766,11 +1766,6 @@ public abstract class GLContextImpl extends GLContext { } @Override - public boolean isGLOrientationFlippedVertical() { - return true; - } - - @Override public int getDefaultPixelDataType() { if(!pixelDataTypeEvaluated) { synchronized(this) { @@ -1804,6 +1799,8 @@ public abstract class GLContextImpl extends GLContext { pixelDataFormat=GL.GL_RGBA; pixelDataType = GL.GL_UNSIGNED_BYTE; } + // TODO: Consider: + // return gl.isGL2GL3()?GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:GL.GL_UNSIGNED_SHORT_5_5_5_1; } //---------------------------------------------------------------------- diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 92ec96ad7..7ef99b241 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -469,17 +469,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { return (GLDrawableFactoryImpl) getFactory(glp); } - //--------------------------------------------------------------------------- - // Support for Java2D/JOGL bridge on Mac OS X; the external - // GLDrawable mechanism in the public API is sufficient to - // implement this functionality on all other platforms - // - - public abstract boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device); - - public abstract GLContext createContextOnJava2DSurface(Object graphics, GLContext shareWith) - throws GLException; - //---------------------------------------------------------------------- // Gamma adjustment support // Thanks to the LWJGL team for illustrating how to make these diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index a2b99c7da..877e7b60b 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -283,6 +283,11 @@ public abstract class GLDrawableImpl implements GLDrawable { return surface.getHeight(); } + @Override + public boolean isGLOriented() { + return true; + } + /** * {@link NativeSurface#lockSurface() Locks} the underlying windowing toolkit's {@link NativeSurface surface}. * <p> diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index ddc6d5917..b8841d6e2 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -49,7 +49,6 @@ import com.jogamp.common.util.locks.RecursiveLock; @SuppressWarnings("deprecation") public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { - private int floatMode; public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContextImpl pbufferContext) { super(pbufferDrawable, pbufferContext, true); // drawable := pbufferDrawable, context := pbufferContext @@ -59,28 +58,6 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { // pbuffer specifics // - @Override - public void bindTexture() { - // Doesn't make much sense to try to do this on the event dispatch - // thread given that it has to be called while the context is current - context.bindPbufferToTexture(); - } - - @Override - public void releaseTexture() { - // Doesn't make much sense to try to do this on the event dispatch - // thread given that it has to be called while the context is current - context.releasePbufferFromTexture(); - } - - @Override - public int getFloatingPointMode() { - if (floatMode == 0) { - throw new GLException("Pbuffer not initialized, or floating-point support not requested"); - } - return floatMode; - } - // // GLDrawable delegation // @@ -119,22 +96,10 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { _lock.lock(); // sync: context/drawable could been recreated/destroyed while animating try { if( null != context ) { - helper.invokeGL(drawable, context, defaultDisplayAction, initAction); + helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction); } } finally { _lock.unlock(); } } - - //---------------------------------------------------------------------- - // Internals only below this point - // - - protected final Runnable initAction = new Runnable() { - @Override - public final void run() { - floatMode = context.getFloatingPointMode(); - defaultInitAction.run(); - } }; - } diff --git a/src/jogl/classes/jogamp/opengl/awt/Java2DGLContext.java b/src/jogl/classes/jogamp/opengl/awt/Java2DGLContext.java deleted file mode 100644 index 4a5b1db54..000000000 --- a/src/jogl/classes/jogamp/opengl/awt/Java2DGLContext.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2006 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 jogamp.opengl.awt; - -import jogamp.opengl.*; -import java.awt.Graphics; - -/** Provides a construct by which the shared GLJPanel code can - * interact with a few methods in the Mac OS X-specific Java2D/JOGL - * bridge implementation. - */ - -public interface Java2DGLContext { - public void setGraphics(Graphics g); -} diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 1c0cd0d3c..2b8ca31c9 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -56,7 +56,7 @@ import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import com.jogamp.opengl.GLRendererQuirks; -public abstract class EGLContext extends GLContextImpl { +public class EGLContext extends GLContextImpl { private boolean eglQueryStringInitialized; private boolean eglQueryStringAvailable; private EGLExt _eglExt; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 9b87860cb..431de5159 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -779,15 +779,4 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { protected GLDrawable createExternalGLDrawableImpl() { throw new GLException("Not yet implemented"); } - - @Override - public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) { - return false; - } - - @Override - public GLContext createContextOnJava2DSurface(Object graphics, GLContext shareWith) - throws GLException { - throw new GLException("Unimplemented on this platform"); - } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenContext.java deleted file mode 100644 index 325ad6142..000000000 --- a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenContext.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2008 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. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package jogamp.opengl.egl; - -import javax.media.opengl.*; - -public class EGLOnscreenContext extends EGLContext { - public EGLOnscreenContext(EGLOnscreenDrawable drawable, GLContext shareWith) { - super(drawable, shareWith); - } -} - diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java index 6440cf1e5..19084ba19 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java @@ -50,7 +50,7 @@ public class EGLOnscreenDrawable extends EGLDrawable { @Override public GLContext createContext(GLContext shareWith) { - return new EGLOnscreenContext(this, shareWith); + return new EGLContext(this, shareWith); } @Override diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferContext.java deleted file mode 100644 index bb9eeb892..000000000 --- a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferContext.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2008 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. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package jogamp.opengl.egl; - -import javax.media.opengl.*; - -public class EGLPbufferContext extends EGLContext { - public EGLPbufferContext(EGLPbufferDrawable drawable, GLContext shareWith) { - super(drawable, shareWith); - } - - @Override - public int getFloatingPointMode() { - return 0; // FIXME ?? - } -} - diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java index 9e5d9327b..45e39f5d1 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java @@ -57,7 +57,7 @@ public class EGLPbufferDrawable extends EGLDrawable { @Override public GLContext createContext(GLContext shareWith) { - return new EGLPbufferContext(this, shareWith); + return new EGLContext(this, shareWith); } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 6cab369cf..666cd30af 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -80,7 +80,7 @@ import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; -public abstract class MacOSXCGLContext extends GLContextImpl +public class MacOSXCGLContext extends GLContextImpl { // Abstract interface for implementation of this context (either // NSOpenGL-based or CGL-based) @@ -184,6 +184,9 @@ public abstract class MacOSXCGLContext extends GLContextImpl // CGL extension functions. private CGLExtProcAddressTable cglExtProcAddressTable; + private long updateHandle = 0; + private int lastWidth, lastHeight; + protected MacOSXCGLContext(GLDrawableImpl drawable, GLContext shareWith) { super(drawable, shareWith); @@ -280,9 +283,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); GLCapabilitiesImmutable capabilitiesChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - if (capabilitiesChosen.getPbufferFloatingPointBuffers() && !isTigerOrLater) { - throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later"); - } GLProfile glp = capabilitiesChosen.getGLProfile(); if(glp.isGLES1() || glp.isGLES2() || glp.isGL4() || glp.isGL3() && !isLionOrLater) { throw new GLException("OpenGL profile not supported on MacOSX "+Platform.getOSVersionNumber()+": "+glp); @@ -311,6 +311,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl if (!impl.makeCurrent(contextHandle)) { throw new GLException("Error making Context current: "+this); } + drawableUpdatedNotify(); } @Override @@ -322,18 +323,70 @@ public abstract class MacOSXCGLContext extends GLContextImpl @Override protected void destroyImpl() throws GLException { + releaseUpdateHandle(); if(!impl.destroy(contextHandle)) { throw new GLException("Error destroying OpenGL Context: "+this); } } + private final long getUpdateHandle() { + if( 0 == updateHandle ) { + lastWidth = -1; + lastHeight = -1; + if( isCreated() && drawable.getChosenGLCapabilities().isOnscreen() && isNSContext() ) { + final boolean incompleteView; + final NativeSurface surface = drawable.getNativeSurface(); + if( surface instanceof ProxySurface ) { + incompleteView = ((ProxySurface)surface).containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE ); + } else { + incompleteView = false; + } + if(!incompleteView) { + updateHandle = CGL.updateContextRegister(contextHandle, drawable.getHandle()); + if(0 == updateHandle) { + throw new InternalError("XXX2"); + } + } + } + } + return updateHandle; + } + + private final void releaseUpdateHandle() { + if ( 0 != updateHandle ) { + CGL.updateContextUnregister(updateHandle); + updateHandle = 0; + } + } + + @Override + protected void drawableUpdatedNotify() throws GLException { + if( drawable.getChosenGLCapabilities().isOnscreen() ) { + final long _updateHandle = getUpdateHandle(); + final int w = drawable.getWidth(); + final int h = drawable.getHeight(); + final boolean updateContext = ( 0!=_updateHandle && CGL.updateContextNeedsUpdate(_updateHandle) ) || + w != lastWidth || h != lastHeight; + if(updateContext) { + lastWidth = w; + lastHeight = h; + if (contextHandle == 0) { + throw new GLException("Context not created"); + } + CGL.updateContext(contextHandle); + } + } + } + @Override protected void associateDrawable(boolean bound) { // context stuff depends on drawable stuff if(bound) { super.associateDrawable(true); // 1) init drawable stuff impl.associateDrawable(true); // 2) init context stuff + getUpdateHandle(); } else { + releaseUpdateHandle(); impl.associateDrawable(false); // 1) free context stuff super.associateDrawable(false); // 2) free drawable stuff } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index 6c647108f..39178290a 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -405,17 +405,6 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { throw new GLException("Not yet implemented"); } - @Override - public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) { - return false; - } - - @Override - public GLContext createContextOnJava2DSurface(Object graphics, GLContext shareWith) - throws GLException { - throw new GLException("not supported in non AWT enviroment"); - } - //------------------------------------------------------ // Gamma-related functionality // diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java index fa8e8d468..86e1ef481 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java @@ -104,7 +104,8 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration break; case CGL.kCGLPFAColorFloat: - ivalues.put(idx, ( !caps.isOnscreen() && caps.isPBuffer() && caps.getPbufferFloatingPointBuffers() ) ? 1 : 0); + // ivalues.put(idx, ( !caps.isOnscreen() && caps.isPBuffer() && caps.getPbufferFloatingPointBuffers() ) ? 1 : 0); + ivalues.put(idx, 0); break; case CGL.NSOpenGLPFAPixelBuffer: @@ -176,12 +177,13 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration attrs.put(i++, CGL.kCGLPFAOpenGLProfile); attrs.put(i++, MacOSXCGLContext.GLProfile2CGLOGLProfileValue(ctp, major, minor)); } + /** if(!caps.isOnscreen() && caps.isPBuffer()) { attrs.put(i++, CGL.kCGLPFAPBuffer); if (caps.getPbufferFloatingPointBuffers()) { attrs.put(i++, CGL.kCGLPFAColorFloat); } - } + } */ if (caps.getDoubleBuffered()) { attrs.put(i++, CGL.kCGLPFADoubleBuffer); } @@ -284,7 +286,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration break; case CGL.kCGLPFAColorFloat: - caps.setPbufferFloatingPointBuffers(ivalue != 0); + // caps.setPbufferFloatingPointBuffers(ivalue != 0); break; case CGL.NSOpenGLPFAPixelBuffer: diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLContext.java deleted file mode 100644 index f2e636796..000000000 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLContext.java +++ /dev/null @@ -1,56 +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 jogamp.opengl.macosx.cgl; - -import javax.media.opengl.*; - -public class MacOSXOffscreenCGLContext extends MacOSXPbufferCGLContext -{ - public MacOSXOffscreenCGLContext(MacOSXPbufferCGLDrawable drawable, - GLContext shareWith) { - super(drawable, shareWith); - } - - @Override - public int getDefaultPixelDataType() { - final GL gl = getGL(); - return gl.isGL2GL3()?GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:GL.GL_UNSIGNED_SHORT_5_5_5_1; - } -} diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java index 4f9005504..446a834b9 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java @@ -53,6 +53,6 @@ public class MacOSXOffscreenCGLDrawable extends MacOSXPbufferCGLDrawable { @Override public GLContext createContext(GLContext shareWith) { - return new MacOSXOffscreenCGLContext(this, shareWith); + return new MacOSXCGLContext(this, shareWith); } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java deleted file mode 100644 index 447d18f68..000000000 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java +++ /dev/null @@ -1,115 +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 jogamp.opengl.macosx.cgl; - -import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.ProxySurface; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLException; - -import jogamp.opengl.GLContextImpl; - -public class MacOSXOnscreenCGLContext extends MacOSXCGLContext { - - public MacOSXOnscreenCGLContext(MacOSXOnscreenCGLDrawable drawable, - GLContext shareWith) { - super(drawable, shareWith); - } - - @Override - protected void makeCurrentImpl() throws GLException { - super.makeCurrentImpl(); - drawableUpdatedNotify(); - } - - @Override - protected void drawableUpdatedNotify() throws GLException { - final int w = drawable.getWidth(); - final int h = drawable.getHeight(); - final boolean updateContext = ( 0!=updateHandle && CGL.updateContextNeedsUpdate(updateHandle) ) || - w != lastWidth || h != lastHeight; - if(updateContext) { - lastWidth = w; - lastHeight = h; - if (contextHandle == 0) { - throw new GLException("Context not created"); - } - CGL.updateContext(contextHandle); - } - } - - @Override - protected boolean createImpl(GLContextImpl sharedWith) { - boolean res = super.createImpl(sharedWith); - lastWidth = -1; - lastHeight = -1; - if(res && isNSContext()) { - if(0 != updateHandle) { - throw new InternalError("XXX1"); - } - final boolean incompleteView; - final NativeSurface surface = drawable.getNativeSurface(); - if( surface instanceof ProxySurface ) { - incompleteView = ((ProxySurface)surface).containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE ); - } else { - incompleteView = false; - } - if(!incompleteView) { - updateHandle = CGL.updateContextRegister(contextHandle, drawable.getHandle()); - if(0 == updateHandle) { - throw new InternalError("XXX2"); - } - } - } - return res; - } - - @Override - protected void destroyImpl() throws GLException { - if ( 0 != updateHandle ) { - CGL.updateContextUnregister(updateHandle); - updateHandle = 0; - } - super.destroyImpl(); - } - - private long updateHandle = 0; - private int lastWidth, lastHeight; -} diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java index ec9628004..c6f0c1383 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java @@ -52,7 +52,7 @@ public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable { @Override public GLContext createContext(GLContext shareWith) { - return new MacOSXOnscreenCGLContext(this, shareWith); + return new MacOSXCGLContext(this, shareWith); } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java deleted file mode 100644 index 7e2d8cf10..000000000 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java +++ /dev/null @@ -1,95 +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. - */ - -package jogamp.opengl.macosx.cgl; - -import javax.media.opengl.GL; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLPbuffer; - -import jogamp.opengl.GLContextImpl; - -@SuppressWarnings("deprecation") -public class MacOSXPbufferCGLContext extends MacOSXCGLContext { - - // State for render-to-texture and render-to-texture-rectangle support - private int texture; // actual texture object - - public MacOSXPbufferCGLContext(MacOSXPbufferCGLDrawable drawable, - GLContext shareWith) { - super(drawable, shareWith); - } - - @Override - public void bindPbufferToTexture() { - GL gl = getGL(); - gl.glBindTexture(((MacOSXPbufferCGLDrawable)drawable).getTextureTarget(), texture); - // FIXME: not clear whether this is really necessary, but since - // the API docs seem to imply it is and since it doesn't seem to - // impact performance, leaving it in - CGL.setContextTextureImageToPBuffer(contextHandle, drawable.getHandle(), GL.GL_FRONT); - } - - @Override - public void releasePbufferFromTexture() { - } - - @Override - protected boolean createImpl(GLContextImpl shareWith) { - boolean res = super.createImpl(shareWith); - if(res) { - // Initialize render-to-texture support if requested - final GL gl = getGL(); - final MacOSXPbufferCGLDrawable osxPDrawable = (MacOSXPbufferCGLDrawable)drawable; - final int textureTarget = osxPDrawable.getTextureTarget(); - - int[] tmp = new int[1]; - gl.glGenTextures(1, tmp, 0); - texture = tmp[0]; - gl.glBindTexture(textureTarget, texture); - gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); - gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); - gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE); - gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE); - gl.glTexImage2D(textureTarget, 0, GL.GL_RGB, osxPDrawable.getTextureWidth(), osxPDrawable.getTextureHeight(), - 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, null); - gl.glCopyTexSubImage2D(textureTarget, 0, 0, 0, 0, 0, drawable.getWidth(), drawable.getHeight()); - } - return res; - } - - @Override - public int getFloatingPointMode() { - return GLPbuffer.APPLE_FLOAT; - } -} diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 1e845d179..982bb57e1 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -47,7 +47,6 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GL; import javax.media.opengl.GL2; -import javax.media.opengl.GL2GL3; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; @@ -89,7 +88,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { @Override public GLContext createContext(GLContext shareWith) { - return new MacOSXPbufferCGLContext(this, shareWith); + return new MacOSXCGLContext(this, shareWith); } protected int getTextureTarget() { return pBufferTexTarget; } @@ -134,12 +133,8 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { } } - if ( capabilities.getPbufferRenderToTextureRectangle() && null!=sr && sr.isRECTTextureAvailable() ) { - pBufferTexTarget = GL2GL3.GL_TEXTURE_RECTANGLE; - } else { - pBufferTexTarget = GL.GL_TEXTURE_2D; - } - if ( GL2GL3.GL_TEXTURE_RECTANGLE == pBufferTexTarget || ( null!=sr && sr.isNPOTTextureAvailable() ) ) { + pBufferTexTarget = GL.GL_TEXTURE_2D; + if ( null!=sr && sr.isNPOTTextureAvailable() ) { pBufferTexWidth = getWidth(); pBufferTexHeight = getHeight(); } else { @@ -147,18 +142,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { pBufferTexHeight = GLBuffers.getNextPowerOf2(getHeight()); } - int internalFormat = GL.GL_RGBA; - if (capabilities.getPbufferFloatingPointBuffers()) { - if(!glProfile.isGL2GL3() || null==sr || sr.isAppleFloatPixelsAvailable()) { - throw new GLException("Floating-point support (GL_APPLE_float_pixels) not available"); - } - switch (capabilities.getRedBits()) { - case 16: internalFormat = GL2.GL_RGBA_FLOAT16_APPLE; break; - case 32: internalFormat = GL2.GL_RGBA_FLOAT32_APPLE; break; - default: throw new GLException("Invalid floating-point bit depth (only 16 and 32 supported)"); - } - } - + final int internalFormat = GL.GL_RGBA; final long pBuffer = impl.create(pBufferTexTarget, internalFormat, getWidth(), getHeight()); if(DEBUG) { System.err.println("MacOSXPbufferCGLDrawable tex: target "+toHexString(pBufferTexTarget)+ diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLDrawableFactory.java deleted file mode 100644 index fe60710f0..000000000 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLDrawableFactory.java +++ /dev/null @@ -1,60 +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 jogamp.opengl.macosx.cgl.awt; - -import javax.media.nativewindow.*; -import javax.media.opengl.*; -import jogamp.opengl.macosx.cgl.*; - -public class MacOSXAWTCGLDrawableFactory extends MacOSXCGLDrawableFactory { - - public MacOSXAWTCGLDrawableFactory() { - super(); - } - - public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) { - return true; - } - - public GLContext createContextOnJava2DSurface(Object graphics, GLContext shareWith) - throws GLException { - return new MacOSXJava2DCGLContext(shareWith); - } -} diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java deleted file mode 100644 index bd183b900..000000000 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2006 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 jogamp.opengl.macosx.cgl.awt; - -import java.awt.Graphics; - -import javax.media.opengl.GLContext; -import javax.media.opengl.GLException; - -import jogamp.opengl.GLContextImpl; -import jogamp.opengl.awt.Java2D; -import jogamp.opengl.awt.Java2DGLContext; -import jogamp.opengl.macosx.cgl.MacOSXCGLContext; -import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.GLBackendType; - - -/** MacOSXCGLContext implementation supporting the Java2D/JOGL bridge - * on Mac OS X. The external GLDrawable mechanism does not work on Mac - * OS X due to how drawables and contexts are operated upon on this - * platform, so it is necessary to supply an alternative means to - * create, make current, and destroy contexts on the Java2D "drawable" - * on the Mac platform. - */ - -public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGLContext { - private Graphics graphics; - - // FIXME: ignoring context sharing for the time being; will need to - // rethink this in particular if using FBOs to implement the - // Java2D/OpenGL pipeline on Mac OS X - - MacOSXJava2DCGLContext(GLContext shareWith) { - super(null, shareWith); - } - - public void setGraphics(Graphics g) { - this.graphics = g; - } - - protected void makeCurrentImpl() throws GLException { - if (!Java2D.makeOGLContextCurrentOnSurface(graphics, contextHandle)) { - throw new GLException("Error making context current"); - } - } - - protected boolean createImpl(GLContextImpl shareWith) { - long share = createImplPreset(shareWith); - - long ctx = Java2D.createOGLContextOnSurface(graphics, share); - if (ctx == 0) { - if(DEBUG) { - System.err.println("Error creating current: "+this); - } - return false; - } - if (!Java2D.makeOGLContextCurrentOnSurface(graphics, contextHandle)) { - Java2D.destroyOGLContext(ctx); - if(DEBUG) { - System.err.println("Error making created context current: "+this); - } - return false; - } - setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION - contextHandle = ctx; - return true; - } - - protected void releaseImpl() throws GLException { - // FIXME: would need another primitive in the Java2D class in - // order to implement this; hopefully should not matter for - // correctness - } - - protected void destroyImpl() throws GLException { - Java2D.destroyOGLContext(contextHandle); - } - - public void setOpenGLMode(GLBackendType mode) { - if (mode != GLBackendType.CGL) { - throw new GLException("OpenGL mode switching not supported for Java2D GLContexts"); - } - super.setOpenGLMode(mode); - } -} diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java index 10a4b56d5..4444e9d63 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java @@ -32,9 +32,7 @@ import java.nio.IntBuffer; import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR; -import jogamp.opengl.GLGraphicsConfigurationUtil; -import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; @@ -161,19 +159,13 @@ public class WGLGLCapabilities extends GLCapabilities { } if (res == WGLExt.WGL_TYPE_RGBA_FLOAT_ARB) { - setPbufferFloatingPointBuffers(true); + return false; // not supported } // normal RGBA FB: WGLExt.WGL_TYPE_RGBA_ARB // ignore unknown results here break; - case WGLExt.WGL_FLOAT_COMPONENTS_NV: - if (res != 0) { - setPbufferFloatingPointBuffers(true); - } - break; - case WGLExt.WGL_RED_BITS_ARB: setRedBits(res); break; diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLContext.java deleted file mode 100644 index c8aac7f7b..000000000 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLContext.java +++ /dev/null @@ -1,61 +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.windows.wgl; - -import javax.media.opengl.*; - -public class WindowsBitmapWGLContext extends WindowsWGLContext { - public WindowsBitmapWGLContext(WindowsBitmapWGLDrawable drawable, - GLContext shareWith) { - super(drawable, shareWith); - } - - @Override - public int getDefaultPixelDataType() { - return GL.GL_UNSIGNED_BYTE; - } - - @Override - public boolean isGLOrientationFlippedVertical() { - // We can take care of this in the DIB creation (see below) - return false; - } -} diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java index bd018105a..a7f62fccf 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java @@ -73,9 +73,14 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable { @Override public GLContext createContext(GLContext shareWith) { - return new WindowsBitmapWGLContext(this, shareWith); + return new WindowsWGLContext(this, shareWith); } + @Override + public boolean isGLOriented() { + return false; + } + private void createBitmap() { int werr; final NativeSurface ns = getNativeSurface(); @@ -111,9 +116,9 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable { bitsPerPixel = 24; // RGB888 only! header.setBiSize(BITMAPINFOHEADER.size()); header.setBiWidth(width); - // NOTE: negating the height causes the DIB to be in top-down row - // order rather than bottom-up; ends up being correct during pixel - // readback + // NOTE: Positive height causes the DIB's origin at bottom-left (OpenGL), + // a negative height causes the DIB's origin at top-left (Java AWT, Windows, ..). + // We use !OpenGL origin to remove the need for vertical flip, see 'isGLOriented()' above. header.setBiHeight(-1 * height); header.setBiPlanes((short) 1); header.setBiBitCount((short) bitsPerPixel); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsOnscreenWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsOnscreenWGLContext.java deleted file mode 100644 index aef55efc6..000000000 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsOnscreenWGLContext.java +++ /dev/null @@ -1,49 +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 jogamp.opengl.windows.wgl; - -import javax.media.opengl.*; - -public class WindowsOnscreenWGLContext extends WindowsWGLContext { - public WindowsOnscreenWGLContext(WindowsOnscreenWGLDrawable drawable, - GLContext shareWith) { - super(drawable, shareWith); - } -} diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsOnscreenWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsOnscreenWGLDrawable.java index ddbb29d51..61fb787c6 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsOnscreenWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsOnscreenWGLDrawable.java @@ -51,7 +51,7 @@ public class WindowsOnscreenWGLDrawable extends WindowsWGLDrawable { @Override public GLContext createContext(GLContext shareWith) { - return new WindowsOnscreenWGLContext(this, shareWith); + return new WindowsWGLContext(this, shareWith); } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java deleted file mode 100644 index 7dda6a1f1..000000000 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java +++ /dev/null @@ -1,156 +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.windows.wgl; - -import javax.media.opengl.*; - -import com.jogamp.opengl.GLExtensions; - -import jogamp.opengl.GLContextImpl; - -public class WindowsPbufferWGLContext extends WindowsWGLContext { - // State for render-to-texture and render-to-texture-rectangle support - private boolean rtt; // render-to-texture? - private boolean hasRTT; // render-to-texture extension available? - private boolean rect; // render-to-texture-rectangle? - private int textureTarget; // e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_NV - private int texture; // actual texture object - - protected WindowsPbufferWGLContext(WindowsPbufferWGLDrawable drawable, - GLContext shareWith) { - super(drawable, shareWith); - } - - @Override - public void bindPbufferToTexture() { - if (!rtt) { - throw new GLException("Shouldn't try to bind a pbuffer to a texture if render-to-texture hasn't been " + - "specified in its GLCapabilities"); - } - GL gl = getGL(); - WGLExt wglExt = getWGLExt(); - gl.glBindTexture(textureTarget, texture); - if (rtt && hasRTT) { - if (!wglExt.wglBindTexImageARB(((WindowsPbufferWGLDrawable)drawable).getPbufferHandle(), WGLExt.WGL_FRONT_LEFT_ARB)) { - throw new GLException("Binding of pbuffer to texture failed: " + wglGetLastError()); - } - } - // FIXME: comment is wrong now - // Note that if the render-to-texture extension is not supported, - // we perform a glCopyTexImage2D in swapBuffers(). - } - - @Override - public void releasePbufferFromTexture() { - if (!rtt) { - throw new GLException("Shouldn't try to bind a pbuffer to a texture if render-to-texture hasn't been " + - "specified in its GLCapabilities"); - } - if (rtt && hasRTT) { - WGLExt wglExt = getWGLExt(); - if (!wglExt.wglReleaseTexImageARB(((WindowsPbufferWGLDrawable)drawable).getPbufferHandle(), WGLExt.WGL_FRONT_LEFT_ARB)) { - throw new GLException("Releasing of pbuffer from texture failed: " + wglGetLastError()); - } - } - } - - @Override - protected boolean createImpl(GLContextImpl shareWith) { - boolean res = super.createImpl(shareWith); - if(res) { - GLCapabilitiesImmutable capabilities = drawable.getChosenGLCapabilities(); - - // Initialize render-to-texture support if requested - GL gl = getGL(); - rtt = capabilities.getPbufferRenderToTexture(); - rect = gl.isGL2GL3() && capabilities.getPbufferRenderToTextureRectangle(); - - if (rtt) { - if (DEBUG) { - System.err.println("Initializing render-to-texture support"); - } - - if (!gl.isExtensionAvailable("WGL_ARB_render_texture")) { - System.err.println("WindowsPbufferWGLContext: WARNING: WGL_ARB_render_texture extension not " + - "supported; implementing render_to_texture support using slow texture readback"); - } else { - hasRTT = true; - - if (rect && !gl.isExtensionAvailable(GLExtensions.NV_texture_rectangle)) { - System.err.println("WindowsPbufferWGLContext: WARNING: GL_NV_texture_rectangle extension not " + - "supported; skipping requested render_to_texture_rectangle support for pbuffer"); - rect = false; - } - if (rect) { - if (DEBUG) { - System.err.println(" Using render-to-texture-rectangle"); - } - textureTarget = GL2GL3.GL_TEXTURE_RECTANGLE_ARB; - } else { - if (DEBUG) { - System.err.println(" Using vanilla render-to-texture"); - } - textureTarget = GL.GL_TEXTURE_2D; - } - int[] tmp = new int[1]; - gl.glGenTextures(1, tmp, 0); - texture = tmp[0]; - gl.glBindTexture(textureTarget, texture); - gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); - gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); - gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE); - gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE); - gl.glCopyTexImage2D(textureTarget, 0, GL.GL_RGB, 0, 0, drawable.getWidth(), drawable.getHeight(), 0); - } - } - } - return res; - } - - @Override - public int getFloatingPointMode() { - return ((WindowsPbufferWGLDrawable)drawable).getFloatingPointMode(); - } - - private static String wglGetLastError() { - return WindowsWGLDrawableFactory.wglGetLastError(); - } -} diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java index b65f5dd2f..2a0f2596e 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -47,7 +47,6 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; -import javax.media.opengl.GL; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; @@ -60,15 +59,12 @@ import jogamp.nativewindow.windows.GDI; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLGraphicsConfigurationUtil; import jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory.SharedResource; -// import javax.media.opengl.GLPbuffer; public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { private WGLExt cachedWGLExt; // cached WGLExt instance from parent GLCanvas, // needed to destroy pbuffer private long buffer; // pbuffer handle - private int floatMode; - protected WindowsPbufferWGLDrawable(GLDrawableFactory factory, NativeSurface target) { super(factory, target, false); } @@ -84,7 +80,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { @Override public GLContext createContext(GLContext shareWith) { - return new WindowsPbufferWGLContext(this, shareWith); + return new WindowsWGLContext(this, shareWith); } protected void destroyPbuffer() { @@ -115,10 +111,6 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { return buffer; } - public int getFloatingPointMode() { - return floatMode; - } - private void createPbuffer() { WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration(); SharedResource sharedResource = ((WindowsWGLDrawableFactory)factory).getOrCreateSharedResource(config.getScreen().getDevice()); @@ -155,17 +147,6 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { throw new GLException("Pbuffer-related extensions not supported"); } - floatMode = floatModeTmp[0]; - boolean rtt = chosenCaps.getPbufferRenderToTexture(); - boolean rect = chosenCaps.getPbufferRenderToTextureRectangle(); - boolean useFloat = chosenCaps.getPbufferFloatingPointBuffers(); - // boolean ati = false; - - /** - if (useFloat) { - ati = (floatMode == GLPbuffer.ATI_FLOAT); - } */ - final IntBuffer pformats = Buffers.newDirectIntBuffer(WindowsWGLGraphicsConfiguration.MAX_PFORMATS); final IntBuffer nformatsTmp = Buffers.newDirectIntBuffer(1); if (!wglExt.wglChoosePixelFormatARB(sharedHdc, @@ -198,24 +179,6 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { // Create the p-buffer. niattribs = 0; - if (rtt) { - iattributes.put(niattribs++, WGLExt.WGL_TEXTURE_FORMAT_ARB); - if (useFloat) { - iattributes.put(niattribs++, WGLExt.WGL_TEXTURE_FLOAT_RGB_NV); - } else { - iattributes.put(niattribs++, WGLExt.WGL_TEXTURE_RGBA_ARB); - } - - iattributes.put(niattribs++, WGLExt.WGL_TEXTURE_TARGET_ARB); - iattributes.put(niattribs++, rect ? WGLExt.WGL_TEXTURE_RECTANGLE_NV : WGLExt.WGL_TEXTURE_2D_ARB); - - iattributes.put(niattribs++, WGLExt.WGL_MIPMAP_TEXTURE_ARB); - iattributes.put(niattribs++, GL.GL_FALSE); - - iattributes.put(niattribs++, WGLExt.WGL_PBUFFER_LARGEST_ARB); // exact - iattributes.put(niattribs++, GL.GL_FALSE); - } - iattributes.put(niattribs++, 0); tmpBuffer = wglExt.wglCreatePbufferARB(sharedHdc, format, getWidth(), getHeight(), iattributes); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index 9f034adb1..1f41563ba 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -540,15 +540,4 @@ public class WindowsWGLContext extends GLContextImpl { public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { return getWGLExt().wglAllocateMemoryNV(arg0, arg1, arg2, arg3); } - - @Override - public void bindPbufferToTexture() { - throw new GLException("Should not call this"); - } - - @Override - public void releasePbufferFromTexture() { - throw new GLException("Should not call this"); - } - } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index d7d6ceab4..26d73638f 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -617,17 +617,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { return detail; } - @Override - public final boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) { - return false; - } - - @Override - public final GLContext createContextOnJava2DSurface(Object graphics, GLContext shareWith) - throws GLException { - throw new GLException("Unimplemented on this platform"); - } - //------------------------------------------------------ // Gamma-related functionality // diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java index fdff20daa..3b71c4462 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -46,12 +46,10 @@ import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; -import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; import com.jogamp.common.nio.Buffers; import com.jogamp.nativewindow.MutableGraphicsConfiguration; -import com.jogamp.opengl.GLExtensions; import jogamp.nativewindow.windows.DWM_BLURBEHIND; import jogamp.nativewindow.windows.GDI; @@ -61,7 +59,6 @@ import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLGraphicsConfigurationUtil; -@SuppressWarnings("deprecation") public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { protected static final int MAX_PFORMATS = 256; protected static final int MAX_ATTRIBS = 256; @@ -257,15 +254,6 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio iattributes.put(niattribs++, WGLExt.WGL_SAMPLE_BUFFERS_ARB); iattributes.put(niattribs++, WGLExt.WGL_SAMPLES_ARB); } - - if(sharedResource.hasARBPBuffer()) { - GLContextImpl sharedCtx = sharedResource.getContext(); - if(null != sharedCtx && sharedCtx.isExtensionAvailable(WindowsWGLDrawableFactory.WGL_NV_float_buffer)) { - // pbo float buffer - iattributes.put(niattribs++, WGLExt.WGL_FLOAT_COMPONENTS_NV); // nvidia - } - } - return niattribs; } @@ -511,85 +499,8 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio iattributes.put(niattribs++, caps.getNumSamples()); } - boolean rtt = caps.getPbufferRenderToTexture(); - boolean rect = caps.getPbufferRenderToTextureRectangle(); - boolean useFloat = caps.getPbufferFloatingPointBuffers(); - boolean ati = false; - boolean nvidia = false; - if ( usePBuffer ) { - // Check some invariants and set up some state - if (rect && !rtt) { - throw new GLException("Render-to-texture-rectangle requires render-to-texture to be specified"); - } - - GLContextImpl sharedCtx = sharedResource.getContext(); - if (rect) { - if (!sharedCtx.isExtensionAvailable(GLExtensions.NV_texture_rectangle)) { - throw new GLException("Render-to-texture-rectangle requires GL_NV_texture_rectangle extension"); - } - } - - if (useFloat) { - // Prefer NVidia extension over ATI - nvidia = sharedCtx.isExtensionAvailable(WindowsWGLDrawableFactory.WGL_NV_float_buffer); - if(nvidia) { - floatMode[0] = GLPbuffer.NV_FLOAT; - } else { - ati = sharedCtx.isExtensionAvailable("WGL_ATI_pixel_format_float"); - if(ati) { - floatMode[0] = GLPbuffer.ATI_FLOAT; - } else { - throw new GLException("Floating-point pbuffers not supported by this hardware"); - } - } - - if (DEBUG) { - System.err.println("Using " + (ati ? "ATI" : ( nvidia ? "NVidia" : "NONE" ) ) + " floating-point extension"); - } - } - - // See whether we need to change the pixel type to support ATI's - // floating-point pbuffers - if (useFloat && ati) { - if (rtt) { - throw new GLException("Render-to-floating-point-texture not supported on ATI hardware"); - } else { - iattributes.put(niattribs++, WGLExt.WGL_PIXEL_TYPE_ARB); - iattributes.put(niattribs++, WGLExt.WGL_TYPE_RGBA_FLOAT_ARB); - } - } else { - if (!rtt) { - // Currently we don't support non-truecolor visuals in the - // GLCapabilities, so we don't offer the option of making - // color-index pbuffers. - iattributes.put(niattribs++, WGLExt.WGL_PIXEL_TYPE_ARB); - iattributes.put(niattribs++, WGLExt.WGL_TYPE_RGBA_ARB); - } - } - - if (useFloat && nvidia) { - iattributes.put(niattribs++, WGLExt.WGL_FLOAT_COMPONENTS_NV); - iattributes.put(niattribs++, GL.GL_TRUE); - } - - if (rtt) { - if (useFloat) { - assert(!ati); - assert(nvidia); - if (!rect) { - throw new GLException("Render-to-floating-point-texture only supported on NVidia hardware with render-to-texture-rectangle"); - } - iattributes.put(niattribs++, WGLExt.WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV); - iattributes.put(niattribs++, GL.GL_TRUE); - } else { - iattributes.put(niattribs++, rect ? WGLExt.WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV : WGLExt.WGL_BIND_TO_TEXTURE_RGB_ARB); - iattributes.put(niattribs++, GL.GL_TRUE); - } - } - } else { - iattributes.put(niattribs++, WGLExt.WGL_PIXEL_TYPE_ARB); - iattributes.put(niattribs++, WGLExt.WGL_TYPE_RGBA_ARB); - } + iattributes.put(niattribs++, WGLExt.WGL_PIXEL_TYPE_ARB); + iattributes.put(niattribs++, WGLExt.WGL_TYPE_RGBA_ARB); iattributes.put(niattribs++, 0); return true; diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index 575ff51b8..c60619452 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -65,7 +65,7 @@ import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.opengl.GLExtensions; -public abstract class X11GLXContext extends GLContextImpl { +public class X11GLXContext extends GLContextImpl { private static final Map<String, String> functionNameMap; private static final Map<String, String> extensionNameMap; private GLXExt _glXExt; @@ -624,16 +624,6 @@ public abstract class X11GLXContext extends GLContextImpl { } @Override - public void bindPbufferToTexture() { - throw new GLException("Should not call this"); - } - - @Override - public void releasePbufferFromTexture() { - throw new GLException("Should not call this"); - } - - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getClass().getSimpleName()); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 9486b5875..19005e48c 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -571,17 +571,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { return X11ExternalGLXDrawable.create(this, null); } - @Override - public final boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) { - return false; - } - - @Override - public final GLContext createContextOnJava2DSurface(Object graphics, GLContext shareWith) - throws GLException { - throw new GLException("Unimplemented on this platform"); - } - //---------------------------------------------------------------------- // Gamma-related functionality // diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java index 12ce22392..523364389 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java @@ -225,17 +225,6 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.put(idx++, GLX.GLX_SAMPLES); res.put(idx++, caps.getNumSamples()); } - if (caps.isPBuffer()) { - if (caps.getPbufferFloatingPointBuffers()) { - String glXExtensions = GLX.glXQueryExtensionsString(display, screen); - if (glXExtensions == null || - glXExtensions.indexOf("GLX_NV_float_buffer") < 0) { - throw new GLException("Floating-point pbuffers on X11 currently require NVidia hardware: "+glXExtensions); - } - res.put(idx++, GLXExt.GLX_FLOAT_COMPONENTS_NV); - res.put(idx++, GL.GL_TRUE); - } - } res.put(idx++, 0); return res; } @@ -341,10 +330,6 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.setDepthBits (glXGetFBConfig(display, fbcfg, GLX.GLX_DEPTH_SIZE, tmp)); res.setStencilBits (glXGetFBConfig(display, fbcfg, GLX.GLX_STENCIL_SIZE, tmp)); - try { - res.setPbufferFloatingPointBuffers(glXGetFBConfig(display, fbcfg, GLXExt.GLX_FLOAT_COMPONENTS_NV, tmp) != GL.GL_FALSE); - } catch (Exception e) {} - return (X11GLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXContext.java deleted file mode 100644 index 460dc10ca..000000000 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXContext.java +++ /dev/null @@ -1,48 +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 jogamp.opengl.x11.glx; - -import javax.media.opengl.*; - -public class X11OnscreenGLXContext extends X11GLXContext { - - public X11OnscreenGLXContext(X11OnscreenGLXDrawable drawable, GLContext shareWith) { - super(drawable, shareWith); - } -} diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java index 6b239a43d..9da189290 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java @@ -104,6 +104,6 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable { @Override public GLContext createContext(GLContext shareWith) { - return new X11OnscreenGLXContext(this, shareWith); + return new X11GLXContext(this, shareWith); } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXContext.java deleted file mode 100644 index a34e050cd..000000000 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXContext.java +++ /dev/null @@ -1,67 +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 jogamp.opengl.x11.glx; - -import javax.media.opengl.*; - -public class X11PbufferGLXContext extends X11GLXContext { - - public X11PbufferGLXContext(X11PbufferGLXDrawable drawable, GLContext shareWith) { - super(drawable, shareWith); - } - - @Override - public void bindPbufferToTexture() { - // FIXME: figure out how to implement this - throw new GLException("Not yet implemented"); - } - - @Override - public void releasePbufferFromTexture() { - // FIXME: figure out how to implement this - throw new GLException("Not yet implemented"); - } - - - @Override - public int getFloatingPointMode() { - return ((X11PbufferGLXDrawable)drawable).getFloatingPointMode(); - } -} diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java index d2d0c6789..0e771fd0f 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java @@ -46,15 +46,12 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.MutableSurface; -import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; -import javax.media.opengl.GLPbuffer; import com.jogamp.common.nio.Buffers; -@SuppressWarnings("deprecation") public class X11PbufferGLXDrawable extends X11GLXDrawable { protected X11PbufferGLXDrawable(GLDrawableFactory factory, NativeSurface target) { /* GLCapabilities caps, @@ -74,7 +71,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { @Override public GLContext createContext(GLContext shareWith) { - return new X11PbufferGLXContext(this, shareWith); + return new X11GLXContext(this, shareWith); } protected void destroyPbuffer() { @@ -103,16 +100,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { throw new GLException("Null display"); } - GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); - - if (chosenCaps.getPbufferRenderToTexture()) { - throw new GLException("Render-to-texture pbuffers not supported yet on X11"); - } - - if (chosenCaps.getPbufferRenderToTextureRectangle()) { - throw new GLException("Render-to-texture-rectangle pbuffers not supported yet on X11"); - } - // Create the p-buffer. int niattribs = 0; IntBuffer iattributes = Buffers.newDirectIntBuffer(7); @@ -138,9 +125,4 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { System.err.println(getThreadName()+": Created pbuffer " + this); } } - - public int getFloatingPointMode() { - // Floating-point pbuffers currently require NVidia hardware on X11 - return GLPbuffer.NV_FLOAT; - } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXContext.java deleted file mode 100644 index 1cfb7e427..000000000 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXContext.java +++ /dev/null @@ -1,58 +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.x11.glx; - -import javax.media.opengl.*; - -public class X11PixmapGLXContext extends X11GLXContext { - - public X11PixmapGLXContext(X11PixmapGLXDrawable drawable, - GLContext shareWith) { - super(drawable, shareWith); - } - - @Override - public int getDefaultPixelDataType() { - GL gl = getGL(); - return gl.isGL2GL3()?GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:GL.GL_UNSIGNED_SHORT_5_5_5_1; - } - -} diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java index ab25e4ef4..c1388db8a 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java @@ -69,7 +69,7 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable { @Override public GLContext createContext(GLContext shareWith) { - return new X11PixmapGLXContext(this, shareWith); + return new X11GLXContext(this, shareWith); } private void createPixmap() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java index 6221a1029..728b040af 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java @@ -107,7 +107,7 @@ public class TestGearsGLJPanelAWT extends UITestCase { } } ) ; if( useAnimator ) { - animator.setUpdateFPSFrames(1, null); + animator.setUpdateFPSFrames(60, System.err); animator.start(); Assert.assertEquals(true, animator.isAnimating()); } @@ -117,13 +117,18 @@ public class TestGearsGLJPanelAWT extends UITestCase { new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glJPanel); new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); - snap.setMakeSnapshot(); - final long t0 = System.currentTimeMillis(); long t1 = t0; + boolean triggerSnap = false; while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { Thread.sleep(100); t1 = System.currentTimeMillis(); + snap.getDisplayCount(); + if( !triggerSnap && snap.getDisplayCount() > 1 ) { + // Snapshot only after one frame has been rendered to suite FBO MSAA! + snap.setMakeSnapshot(); + triggerSnap = true; + } } Assert.assertNotNull(frame); @@ -145,7 +150,7 @@ public class TestGearsGLJPanelAWT extends UITestCase { } @Test - public void test01_default() + public void test01_DefaultNorm() throws AWTException, InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); @@ -163,7 +168,7 @@ public class TestGearsGLJPanelAWT extends UITestCase { } @Test - public void test02_msaa() + public void test02_DefaultMsaa() throws AWTException, InterruptedException, InvocationTargetException { if( manualTest ) { @@ -176,25 +181,53 @@ public class TestGearsGLJPanelAWT extends UITestCase { } @Test - public void test03_pbuffer() + public void test03_PbufferNorm() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setPBuffer(true); + runTestGL(caps); + } + + @Test + public void test04_PbufferMsaa() throws AWTException, InterruptedException, InvocationTargetException { if( manualTest ) { return; } GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setNumSamples(4); + caps.setSampleBuffers(true); caps.setPBuffer(true); runTestGL(caps); } @Test - public void test04_bitmap() + public void test05_BitmapNorm() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setBitmap(true); + runTestGL(caps); + } + + @Test + public void test06_BitmapMsaa() throws AWTException, InterruptedException, InvocationTargetException { if( manualTest ) { return; } GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setNumSamples(4); + caps.setSampleBuffers(true); caps.setBitmap(true); runTestGL(caps); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java index 743d682c8..7b53d973c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java @@ -17,22 +17,43 @@ public class TestPNGImage01NEWT extends UITestCase { public void testPNGReadWriteAndCompare() throws InterruptedException, IOException, MalformedURLException { final File out1_f=new File(getSimpleTestName(".")+"-PNGImageTest1.png"); final File out2_f=new File(getSimpleTestName(".")+"-PNGImageTest2.png"); + final File out2F_f=new File(getSimpleTestName(".")+"-PNGImageTest2Flipped.png"); + final File out2R_f=new File(getSimpleTestName(".")+"-PNGImageTest2Reversed.png"); + final File out2RF_f=new File(getSimpleTestName(".")+"-PNGImageTest2ReversedFlipped.png"); final String url_s="jogl/util/data/av/test-ntsc01-160x90.png"; URLConnection urlConn = IOUtil.getResource(url_s, this.getClass().getClassLoader()); - PNGImage image0 = PNGImage.read(urlConn.getInputStream()); - System.err.println("PNGImage - Orig: "+image0); - image0.write(out1_f, true); + PNGImage image1 = PNGImage.read(urlConn.getInputStream()); + System.err.println("PNGImage - Orig: "+image1); + image1.write(out1_f, true); { - Assert.assertEquals(image0.getData(), PNGImage.read(IOUtil.toURL(out1_f).openStream()).getData()); + Assert.assertEquals(image1.getData(), PNGImage.read(IOUtil.toURL(out1_f).openStream()).getData()); } - final PNGImage image1 = PNGImage.createFromData(image0.getWidth(), image0.getHeight(), - image0.getDpi()[0], image0.getDpi()[1], - image0.getBytesPerPixel(), false, image0.getData()); - image1.write(out2_f, true); + final PNGImage image2 = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), false /* reverseChannels */, image1.isGLOriented(), image1.getData()); + image2.write(out2_f, true); { - Assert.assertEquals(image0.getData(), PNGImage.read(IOUtil.toURL(out2_f).openStream()).getData()); - } + Assert.assertEquals(image1.getData(), PNGImage.read(IOUtil.toURL(out2_f).openStream()).getData()); + } + + // flipped + final PNGImage image2F = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), false /* reverseChannels */, !image1.isGLOriented(), image1.getData()); + image2F.write(out2F_f, true); + + // reversed channels + final PNGImage image2R = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), true /* reverseChannels */, image1.isGLOriented(), image1.getData()); + image2R.write(out2R_f, true); + + // reversed channels and flipped + final PNGImage image2RF = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), true /* reverseChannels */, !image1.isGLOriented(), image1.getData()); + image2RF.write(out2RF_f, true); } public static void main(String args[]) { |