aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-06-02 22:56:14 +0000
committerKenneth Russel <[email protected]>2005-06-02 22:56:14 +0000
commit90752caa7b31475d4fd424e8007ef2c9dd3851b5 (patch)
tree7fdd7426b5b02f0eefa955dbcf914e621397b5bd /src
parent2c06e5f46292ee7e3e4824527e1fe6cf6708df7b (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
Diffstat (limited to 'src')
-rw-r--r--src/native/jogl/MacOSXWindowSystemInterface.m14
-rw-r--r--src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java8
-rw-r--r--src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java23
3 files changed, 40 insertions, 5 deletions
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;