diff options
author | Kenneth Russel <[email protected]> | 2005-06-02 22:56:14 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-06-02 22:56:14 +0000 |
commit | 90752caa7b31475d4fd424e8007ef2c9dd3851b5 (patch) | |
tree | 7fdd7426b5b02f0eefa955dbcf914e621397b5bd | |
parent | 2c06e5f46292ee7e3e4824527e1fe6cf6708df7b (diff) |
Made pbuffer code and in particular floating-point pbuffer code more
correct on Mac OS X; problems still exist, however (very likely driver
bugs)
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@293 232f8b59-042b-4e1e-8c03-345bb8c30851
-rw-r--r-- | make/cgl-macosx.cfg | 2 | ||||
-rw-r--r-- | make/stub_includes/macosx/window-system.c | 2 | ||||
-rw-r--r-- | src/native/jogl/MacOSXWindowSystemInterface.m | 14 | ||||
-rw-r--r-- | src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java | 8 | ||||
-rw-r--r-- | src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java | 23 |
5 files changed, 44 insertions, 5 deletions
diff --git a/make/cgl-macosx.cfg b/make/cgl-macosx.cfg index 447937f1c..1a963f135 100644 --- a/make/cgl-macosx.cfg +++ b/make/cgl-macosx.cfg @@ -30,6 +30,8 @@ CustomCCode int accumBlueBits, CustomCCode int accumAlphaBits, CustomCCode int sampleBuffers, CustomCCode int numSamples, +CustomCCode int pbuffer, +CustomCCode int floatingPoint, CustomCCode int* viewNotReady); CustomCCode extern Bool makeCurrentContext(void* nsContext, void* nsView); CustomCCode extern Bool clearCurrentContext(void* nsContext, void* nsView); diff --git a/make/stub_includes/macosx/window-system.c b/make/stub_includes/macosx/window-system.c index 5335e6c41..e53300830 100644 --- a/make/stub_includes/macosx/window-system.c +++ b/make/stub_includes/macosx/window-system.c @@ -18,6 +18,8 @@ void* createContext(void* shareContext, void* nsView, int accumAlphaBits, int sampleBuffers, int numSamples, + int pbuffer, + int floatingPoint, int* viewNotReady); Bool makeCurrentContext(void* nsContext, void* nsView); Bool clearCurrentContext(void* nsContext, void* nsView); diff --git a/src/native/jogl/MacOSXWindowSystemInterface.m b/src/native/jogl/MacOSXWindowSystemInterface.m index 0b68ee5d4..516bda0db 100644 --- a/src/native/jogl/MacOSXWindowSystemInterface.m +++ b/src/native/jogl/MacOSXWindowSystemInterface.m @@ -1,5 +1,6 @@ #import <Cocoa/Cocoa.h> #import <OpenGL/gl.h> +#import <OpenGL/CGLTypes.h> #import <jni.h> #import "ContextUpdater.h" @@ -29,6 +30,8 @@ void* createContext(void* shareContext, void* view, int accumAlphaBits, int sampleBuffers, int numSamples, + int pbuffer, + int floatingPoint, int* viewNotReady) { int colorSize = redBits + greenBits + blueBits; @@ -50,11 +53,16 @@ void* createContext(void* shareContext, void* view, return NULL; } } - + NSOpenGLPixelFormatAttribute attribs[256]; int idx = 0; - if (doubleBuffer) attribs[idx++] = NSOpenGLPFADoubleBuffer; - if (stereo) attribs[idx++] = NSOpenGLPFAStereo; + if (pbuffer) attribs[idx++] = NSOpenGLPFAPixelBuffer; + // kCGLPFAColorFloat is equivalent to NSOpenGLPFAColorFloat, but the + // latter is only available on 10.4 and we need to compile under + // 10.3 + if (floatingPoint) attribs[idx++] = kCGLPFAColorFloat; + if (doubleBuffer) attribs[idx++] = NSOpenGLPFADoubleBuffer; + if (stereo) attribs[idx++] = NSOpenGLPFAStereo; attribs[idx++] = NSOpenGLPFAColorSize; attribs[idx++] = colorSize; attribs[idx++] = NSOpenGLPFAAlphaSize; attribs[idx++] = alphaBits; attribs[idx++] = NSOpenGLPFADepthSize; attribs[idx++] = depthBits; diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java index e4fe8c4b7..272f72372 100644 --- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java +++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java @@ -117,11 +117,15 @@ public abstract class MacOSXGLContext extends GLContext throw new GLException("Should not call this"); } + protected boolean create() { + return create(false, false); + } + /** * Creates and initializes an appropriate OpenGl nsContext. Should only be * called by {@link makeCurrent(Runnable)}. */ - protected boolean create() { + protected boolean create(boolean pbuffer, boolean floatingPoint) { MacOSXGLContext other = (MacOSXGLContext) GLContextShareSet.getShareContext(this); long share = 0; if (other != null) { @@ -147,6 +151,8 @@ public abstract class MacOSXGLContext extends GLContext capabilities.getAccumAlphaBits(), capabilities.getSampleBuffers() ? 1 : 0, capabilities.getNumSamples(), + (pbuffer ? 1 : 0), + (floatingPoint ? 1 : 0), viewNotReady); if (nsContext == 0) { if (viewNotReady[0] == 1) { diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java index 33658957d..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; @@ -171,7 +188,11 @@ public class MacOSXPbufferGLContext extends MacOSXGLContext { } protected boolean create() { - if (!super.create()) { + if (capabilities.getOffscreenFloatingPointBuffers() && + !isTigerOrLater) { + throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later"); + } + if (!super.create(true, capabilities.getOffscreenFloatingPointBuffers())) { return false; } created = true; |