summaryrefslogtreecommitdiffstats
path: root/src/net/java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-02-04 20:24:58 +0000
committerKenneth Russel <[email protected]>2005-02-04 20:24:58 +0000
commit130359e56c71e0486f47744f5c3dfbc7adf5f9f0 (patch)
treeb1ab9f7fda96936eba43dffb2eba9d52b1edb734 /src/net/java
parent3c2f86c7e7255c073c8e05fa30fa9ce1ac253d03 (diff)
Changes to GLJPanel to make it work on Mac OS X
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@213 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java')
-rw-r--r--src/net/java/games/jogl/GLJPanel.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/net/java/games/jogl/GLJPanel.java b/src/net/java/games/jogl/GLJPanel.java
index f7e7fe6db..df7ffc7de 100644
--- a/src/net/java/games/jogl/GLJPanel.java
+++ b/src/net/java/games/jogl/GLJPanel.java
@@ -48,6 +48,7 @@ import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.awt.image.DataBufferInt;
+import java.security.*;
import javax.swing.JComponent;
import javax.swing.JPanel;
import net.java.games.jogl.impl.*;
@@ -66,6 +67,17 @@ import net.java.games.jogl.impl.*;
them. */
public final class GLJPanel extends JPanel implements GLDrawable {
+ private static boolean isMacOSX;
+
+ static {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ isMacOSX = System.getProperty("os.name").equals("Mac OS X");
+ return null;
+ }
+ });
+ }
+
private GLDrawableHelper drawableHelper = new GLDrawableHelper();
// Data used for either pbuffers or pixmap-based offscreen surfaces
@@ -455,6 +467,7 @@ public final class GLJPanel extends JPanel implements GLDrawable {
// bottleneck
int awtFormat = 0;
+ int hwGLFormat = 0;
if (!hardwareAccelerationDisabled) {
// Should be more flexible in these BufferedImage formats;
// perhaps see what the preferred image types are on the
@@ -462,7 +475,14 @@ public final class GLJPanel extends JPanel implements GLDrawable {
if (offscreenCaps.getAlphaBits() > 0) {
awtFormat = BufferedImage.TYPE_INT_ARGB;
} else {
- awtFormat = BufferedImage.TYPE_3BYTE_BGR;
+ awtFormat = BufferedImage.TYPE_INT_RGB;
+ }
+
+ // Choose better pixel format on Mac OS X
+ if (isMacOSX) {
+ hwGLFormat = GL.GL_UNSIGNED_INT_8_8_8_8_REV;
+ } else {
+ hwGLFormat = GL.GL_UNSIGNED_BYTE;
}
} else {
awtFormat = offscreenContext.getOffscreenContextBufferedImageType();
@@ -479,16 +499,11 @@ public final class GLJPanel extends JPanel implements GLDrawable {
break;
case BufferedImage.TYPE_INT_RGB:
- glFormat = GL.GL_BGRA;
- glType = GL.GL_UNSIGNED_BYTE;
- dbInt = (DataBufferInt) offscreenImage.getRaster().getDataBuffer();
- break;
-
case BufferedImage.TYPE_INT_ARGB:
glFormat = GL.GL_BGRA;
glType = (hardwareAccelerationDisabled
? offscreenContext.getOffscreenContextPixelDataType()
- : GL.GL_UNSIGNED_BYTE);
+ : hwGLFormat);
dbInt = (DataBufferInt) offscreenImage.getRaster().getDataBuffer();
break;