From 0f343197b80999930287b8043c9197a685437116 Mon Sep 17 00:00:00 2001
From: Gerard Ziemski <gerard.ziemski@sun.com>
Date: Wed, 19 Nov 2003 18:47:55 +0000
Subject: implemented GLJPanel for Mac OS X

git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@74 232f8b59-042b-4e1e-8c03-345bb8c30851
---
 .../jogl/impl/macosx/MacOSXOffscreenGLContext.java | 61 +++++++++-------------
 1 file changed, 25 insertions(+), 36 deletions(-)

(limited to 'src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java')

diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java
index 431710a7c..1bbb32eda 100644
--- a/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java
@@ -43,48 +43,42 @@ import java.awt.image.BufferedImage;
 import net.java.games.jogl.*;
 import net.java.games.jogl.impl.*;
 
-public class MacOSXOffscreenGLContext extends MacOSXGLContext
-{
-  // Width and height of the underlying bitmap
-  private int  width;
-  private int  height;
-  
+public class MacOSXOffscreenGLContext extends MacOSXPbufferGLContext
+{  
   public MacOSXOffscreenGLContext(GLCapabilities capabilities,
                                   GLCapabilitiesChooser chooser,
                                   GLContext shareWith) {
-    super(null, capabilities, chooser, shareWith);
-  }
-	
-  protected GL createGL() {
-    return new MacOSXGLImpl(this);
+    super(capabilities, -1, -1);
   }
 	
   protected boolean isOffscreen() {
     return true;
   }
 	
+  public boolean offscreenImageNeedsVerticalFlip() {
+    return true;
+  }
+  
   public int getOffscreenContextBufferedImageType() {
       return BufferedImage.TYPE_INT_ARGB;
   }
 	
-  public int getOffscreenContextReadBuffer() {
-    return GL.GL_FRONT;
+  public int getOffscreenContextWidth() {
+      return initWidth;
   }
-	
-  public boolean offscreenImageNeedsVerticalFlip() {
-    // We can take care of this in the DIB creation (see below)
-    return false;
+
+  public int getOffscreenContextHeight() {
+      return initWidth;
   }
-	
-  public boolean canCreatePbufferContext() {
-    // For now say no
-    return false;
+
+  public int getOffscreenContextPixelDataType() {
+      return GL.GL_UNSIGNED_INT_8_8_8_8_REV;
   }
-	
-  public synchronized GLContext createPbufferContext(GLCapabilities capabilities, int initialWidth, int initialHeight) {
-    throw new GLException("Not supported");
+
+  public int getOffscreenContextReadBuffer() {
+    return GL.GL_BACK;
   }
-	
+
   public void bindPbufferToTexture() {
     throw new GLException("Should not call this");
   }
@@ -94,13 +88,12 @@ public class MacOSXOffscreenGLContext extends MacOSXGLContext
   }
 	
   protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
-    if (pendingOffscreenResize) {
+    if (pendingOffscreenResize && (nsContext != 0)) {
       if (pendingOffscreenWidth != width || pendingOffscreenHeight != height) {
-        if (nsContext != 0) {
-          destroy();
-        }
-        width  = pendingOffscreenWidth;
-        height = pendingOffscreenHeight;
+        destroyPBuffer();
+        initWidth  = pendingOffscreenWidth;
+        initHeight = pendingOffscreenHeight;
+        createPbuffer(0, 0);
         pendingOffscreenResize = false;
       }
     }
@@ -108,9 +101,5 @@ public class MacOSXOffscreenGLContext extends MacOSXGLContext
   }
 	
   protected synchronized void swapBuffers() throws GLException {
-  }
-	
-  private void destroy() {
-	free();
-  }
+  }	
 }
-- 
cgit v1.2.3