From 93d272a0525ec57aa3cd584f15cde6cf2a637e0c Mon Sep 17 00:00:00 2001
From: Kenneth Russel <kbrussel@alum.mit.edu>
Date: Thu, 3 Jul 2003 00:09:30 +0000
Subject: Added pbuffer support to JOGL on X11; HWShadowmapsSimple and
 ProceduralTexturePhysics demos are now working on Linux with the appropriate
 hardware. Moved core GLX routines out of the public GLX interface; this
 allowed XVisualInfo (and the new GLXFBConfig) to be removed from the public
 API. Added support to GlueGen for returning arrays of pointers as arrays of
 StructAccessors in Java and for choosing the typedef name for a
 pointer-to-struct if the struct itself does not have a typedef name. Added
 support to GLEmitter to emit ProcAddressTables under arbitrary names and to
 support arbitrary mechanisms for fetching those tables. Made GLU (on all
 platforms) and GLX (on X11) be dynamically linked. Refactored
 ProcAddressTable filling to be mostly shared code. Tested changes on Linux,
 Mac OS X and Windows.

git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@17 232f8b59-042b-4e1e-8c03-345bb8c30851
---
 .../games/jogl/impl/x11/X11OnscreenGLContext.java  | 24 ++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

(limited to 'src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java')

diff --git a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java
index 496e113a5..385874da7 100644
--- a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java
@@ -40,6 +40,8 @@
 package net.java.games.jogl.impl.x11;
 
 import java.awt.Component;
+import java.util.*;
+
 import net.java.games.jogl.*;
 import net.java.games.jogl.impl.*;
 
@@ -49,6 +51,9 @@ public class X11OnscreenGLContext extends X11GLContext {
   private JAWT_DrawingSurfaceInfo dsi;
   private JAWT_X11DrawingSurfaceInfo x11dsi;
 
+  // Variables for pbuffer support
+  List pbuffersToInstantiate = new ArrayList();
+
   public X11OnscreenGLContext(Component component, GLCapabilities capabilities, GLCapabilitiesChooser chooser) {
     super(component, capabilities, chooser);
   }
@@ -75,14 +80,16 @@ public class X11OnscreenGLContext extends X11GLContext {
   }
 
   public boolean canCreatePbufferContext() {
-    // For now say no
-    return false;
+    // FIXME: should we gate this on GLX 1.3 being available?
+    return true;
   }
 
   public synchronized GLContext createPbufferContext(GLCapabilities capabilities,
                                                      int initialWidth,
                                                      int initialHeight) {
-    throw new GLException("Not yet supported");
+    X11PbufferGLContext ctx = new X11PbufferGLContext(capabilities, initialWidth, initialHeight);
+    pbuffersToInstantiate.add(ctx);
+    return ctx;
   }
 
   public void bindPbufferToTexture() {
@@ -98,7 +105,16 @@ public class X11OnscreenGLContext extends X11GLContext {
       if (!lockSurface()) {
         return false;
       }
-      return super.makeCurrent(initAction);
+      boolean ret = super.makeCurrent(initAction);
+      if (ret) {
+        // Instantiate any pending pbuffers
+        while (!pbuffersToInstantiate.isEmpty()) {
+          X11PbufferGLContext ctx =
+            (X11PbufferGLContext) pbuffersToInstantiate.remove(pbuffersToInstantiate.size() - 1);
+          ctx.createPbuffer(display, context);
+        }
+      }
+      return ret;
     } catch (RuntimeException e) {
       try {
         unlockSurface();
-- 
cgit v1.2.3