From 0fa2740c8c186b0908baa5b7629bef657fe38527 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Thu, 7 Jul 2005 22:49:47 +0000 Subject: Merged with main trunk (tag JOGL_PRE_1_1_1) git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@317 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../jogl/impl/macosx/MacOSXPbufferGLContext.java | 53 ++++++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) (limited to 'src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java') diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java index 8e65ce1f3..93bde269b 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java @@ -1,10 +1,27 @@ package net.java.games.jogl.impl.macosx; +import java.security.*; +import java.util.*; + import net.java.games.jogl.*; import net.java.games.jogl.impl.*; public class MacOSXPbufferGLContext extends MacOSXGLContext { private static final boolean DEBUG = Debug.debug("MacOSXPbufferGLContext"); + private static boolean isTigerOrLater; + + static { + String osVersion = + (String) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty("os.version"); + } + }); + StringTokenizer tok = new StringTokenizer(osVersion, ". "); + int major = Integer.parseInt(tok.nextToken()); + int minor = Integer.parseInt(tok.nextToken()); + isTigerOrLater = ((major > 10) || (minor > 3)); + } protected int initWidth; protected int initHeight; @@ -64,14 +81,26 @@ public class MacOSXPbufferGLContext extends MacOSXGLContext { height = getNextPowerOf2(initHeight); renderTarget = GL.GL_TEXTURE_2D; } + + int internalFormat = GL.GL_RGBA; + if (capabilities.getOffscreenFloatingPointBuffers()) { + if (!gl.isExtensionAvailable("GL_APPLE_float_pixels")) { + throw new GLException("Floating-point support (GL_APPLE_float_pixels) not available"); + } + switch (capabilities.getRedBits()) { + case 16: internalFormat = GL.GL_RGBA_FLOAT16_APPLE; break; + case 32: internalFormat = GL.GL_RGBA_FLOAT32_APPLE; break; + default: throw new GLException("Invalid floating-point bit depth (only 16 and 32 supported)"); + } + } - this.pBuffer = CGL.createPBuffer(renderTarget, width, height); - if (this.pBuffer == 0) { + pBuffer = CGL.createPBuffer(renderTarget, internalFormat, width, height); + if (pBuffer == 0) { throw new GLException("pbuffer creation error: CGL.createPBuffer() failed"); } if (DEBUG) { - System.err.println("Created pbuffer " + width + " x " + height); + System.err.println("Created pbuffer 0x" + Long.toHexString(pBuffer) + ", " + width + " x " + height + " for " + this); } } @@ -79,6 +108,9 @@ public class MacOSXPbufferGLContext extends MacOSXGLContext { created = false; if (pBuffer == 0) { + if (DEBUG) { + System.err.println("Pbuffer not instantiated yet for " + this); + } // pbuffer not instantiated yet return false; } @@ -138,6 +170,10 @@ public class MacOSXPbufferGLContext extends MacOSXGLContext { // FIXME: do we need to do anything if the pbuffer is double-buffered? } + public int getFloatingPointMode() { + return GLPbuffer.APPLE_FLOAT; + } + private int getNextPowerOf2(int number) { if (((number-1) & number) == 0) { //ex: 8 -> 0b1000; 8-1=7 -> 0b0111; 0b1000&0b0111 == 0 @@ -151,10 +187,17 @@ public class MacOSXPbufferGLContext extends MacOSXGLContext { return (1<