From 130359e56c71e0486f47744f5c3dfbc7adf5f9f0 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Fri, 4 Feb 2005 20:24:58 +0000 Subject: 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 --- src/net/java/games/jogl/GLJPanel.java | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src/net/java/games') 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; -- cgit v1.2.3