From 945e2ae3d234815b43f83049c9d597cb61585797 Mon Sep 17 00:00:00 2001
From: Kenneth Russel <kbrussel@alum.mit.edu>
Date: Thu, 16 Feb 2006 02:49:30 +0000
Subject: Fixed problems with lack of hardware acceleration on Linux
 distributions using DRI drivers. Hacked around limitations of the current DRI
 implementation by manually dlopen'ing libGL.so.1; avoids changing glue code
 generation for core OpenGL 1.1 routines which do not otherwise need to be
 called through function pointers on any platform.

git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@614 232f8b59-042b-4e1e-8c03-345bb8c30851
---
 .../com/sun/opengl/util/JOGLAppletLauncher.java    | 34 ++++++++++++++++++++--
 1 file changed, 31 insertions(+), 3 deletions(-)

(limited to 'src/classes/com/sun/opengl/util/JOGLAppletLauncher.java')

diff --git a/src/classes/com/sun/opengl/util/JOGLAppletLauncher.java b/src/classes/com/sun/opengl/util/JOGLAppletLauncher.java
index 7a9f8ab74..6db8d39be 100755
--- a/src/classes/com/sun/opengl/util/JOGLAppletLauncher.java
+++ b/src/classes/com/sun/opengl/util/JOGLAppletLauncher.java
@@ -181,6 +181,10 @@ public class JOGLAppletLauncher extends Applet {
   // The signatures of these native libraries are checked before
   // installing them.
   private String[] nativeLibNames;
+  // Whether the "DRI hack" native library is present and whether we
+  // therefore might need to run the DRIHack during loading of the
+  // native libraries
+  private boolean driHackPresent;
 
   /** The applet we have to start */
   private Applet subApplet;
@@ -524,6 +528,9 @@ public class JOGLAppletLauncher extends Applet {
       JarEntry entry = (JarEntry) e.nextElement();
       if (nativeLibInfo.matchesNativeLib(entry.getName())) {
         list.add(entry.getName());
+        if (entry.getName().indexOf("jogl_drihack") >= 0) {
+          driHackPresent = true;
+        }
       }
     }
     if (list.isEmpty()) {
@@ -615,9 +622,33 @@ public class JOGLAppletLauncher extends Applet {
         public void run() {
           displayMessage("Loading native libraries");
 
+          // disable JOGL loading from elsewhere
+          com.sun.opengl.impl.NativeLibLoader.disableLoading();
+
+          Class driHackClass = null;
+          if (driHackPresent) {
+            // Load DRI hack library and run the DRI hack itself
+            loadLibrary(nativeLibDir, "jogl_drihack");
+            try {
+              driHackClass = Class.forName("com.sun.opengl.impl.x11.DRIHack");
+              driHackClass.getMethod("begin", new Class[] {}).invoke(null, new Object[] {});
+            } catch (Exception e) {
+              e.printStackTrace();
+            }
+          }
+
           // Load core JOGL native library
           loadLibrary(nativeLibDir, "jogl");
 
+          if (driHackPresent) {
+            // End DRI hack
+            try {
+              driHackClass.getMethod("end", new Class[] {}).invoke(null, new Object[] {});
+            } catch (Exception e) {
+              e.printStackTrace();
+            }
+          }
+
           if (!nativeLibInfo.isMacOS()) { // borrowed from NativeLibLoader
             // Must pre-load JAWT on all non-Mac platforms to
             // ensure references from jogl_awt shared object
@@ -638,9 +669,6 @@ public class JOGLAppletLauncher extends Applet {
           // Load AWT-specific native code
           loadLibrary(nativeLibDir, "jogl_awt");
 
-          // disable JOGL loading from elsewhere
-          com.sun.opengl.impl.NativeLibLoader.disableLoading();
-
           displayMessage("Starting applet " + subAppletDisplayName);
 
           // start the subapplet
-- 
cgit v1.2.3