aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-11-25 02:59:37 +0100
committerSven Gothel <[email protected]>2011-11-25 02:59:37 +0100
commit6b8f6e8d7c548cb6bfed14d8a04c9cf252ca7c4d (patch)
tree99d9dfc3711353307020373ad908387f974591ff /src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
parent603f6eab78a0e8f7a22f0e51af1afa426d9d80a2 (diff)
GLX Information usage cleanup
- GLXUtil: Distinguish between client and server GLX information, cache client information. - GLXDrawableFactory: Utilize GLXUtil client data, as well as cache (SharedResource) GLX server data, avoiding 'uncontrolled' GLX queries, ie. w/o locking. - isMultisampleAvailable = isClientMultisampleAvailable && isServerMultisampleAvailable
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java99
1 files changed, 63 insertions, 36 deletions
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java b/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
index e95c80205..33e85dd0b 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,14 +33,40 @@
package jogamp.opengl.x11.glx;
-import javax.media.opengl.*;
+import javax.media.nativewindow.x11.X11GraphicsDevice;
+import javax.media.opengl.GLException;
+import jogamp.opengl.Debug;
+
+import com.jogamp.common.util.VersionNumber;
public class GLXUtil {
- public static String getExtension(long display) {
- return GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
- }
+ public static final boolean DEBUG = Debug.debug("GLXUtil");
+
+ public static VersionNumber getGLXServerVersionNumber(long display) {
+ int[] major = new int[1];
+ int[] minor = new int[1];
+
+ if (!GLX.glXQueryVersion(display, major, 0, minor, 0)) {
+ throw new GLException("glXQueryVersion failed");
+ }
+ // Work around bugs in ATI's Linux drivers where they report they
+ // only implement GLX version 1.2 on the server side
+ if (major[0] == 1 && minor[0] == 2) {
+ String str = GLX.glXGetClientString(display, GLX.GLX_VERSION);
+ try {
+ // e.g. "1.3"
+ major[0] = Integer.valueOf(str.substring(0, 1)).intValue();
+ minor[0] = Integer.valueOf(str.substring(2, 3)).intValue();
+ } catch (Exception e) {
+ major[0] = 1;
+ minor[0] = 2;
+ }
+ }
+ return new VersionNumber(major[0], minor[0], 0);
+ }
+
public static boolean isMultisampleAvailable(String extensions) {
if (extensions != null) {
return (extensions.indexOf("GLX_ARB_multisample") >= 0);
@@ -47,16 +74,6 @@ public class GLXUtil {
return false;
}
- public static boolean isMultisampleAvailable(long display) {
- return isMultisampleAvailable(getExtension(display));
- }
-
- /** Workaround for apparent issue with ATI's proprietary drivers
- where direct contexts still send GLX tokens for GL calls */
- public static String getVendorName(long display) {
- return GLX.glXGetClientString(display, GLX.GLX_VENDOR);
- }
-
public static boolean isVendorNVIDIA(String vendor) {
return vendor != null && vendor.startsWith("NVIDIA") ;
}
@@ -65,38 +82,48 @@ public class GLXUtil {
return vendor != null && vendor.startsWith("ATI") ;
}
- public static boolean isVendorATI(long display) {
- return isVendorATI(getVendorName(display));
+ public static boolean isClientMultisampleAvailable() {
+ return clientMultisampleAvailable;
}
-
- public static boolean isVendorNVIDIA(long display) {
- return isVendorNVIDIA(getVendorName(display));
+ public static String getClientVendorName() {
+ return clientVendorName;
}
-
- public static void getGLXVersion(long display, int major[], int minor[]) {
- if(0 == display) {
- throw new GLException("null display handle");
+ public static VersionNumber getClientVersionNumber() {
+ return clientVersionNumber;
+ }
+ public static synchronized boolean initGLXClientDataSingleton(X11GraphicsDevice x11Device) {
+ if(null != clientVendorName) {
+ return false;
}
- if(major.length<1||minor.length<1) {
- throw new GLException("passed int arrays size is not >= 1");
+ if(DEBUG) {
+ System.err.println("initGLXClientDataSingleton: "+x11Device);
+ Thread.dumpStack();
}
-
- if (!GLX.glXQueryVersion(display, major, 0, minor, 0)) {
- throw new GLException("glXQueryVersion failed");
+ if(null == x11Device) {
+ throw new GLException("null X11GraphicsDevice");
}
-
- // Work around bugs in ATI's Linux drivers where they report they
- // only implement GLX version 1.2 on the server side
- if (major[0] == 1 && minor[0] == 2) {
- String str = GLX.glXGetClientString(display, GLX.GLX_VERSION);
- try {
+ if(0 == x11Device.getHandle()) {
+ throw new GLException("null X11GraphicsDevice display handle");
+ }
+
+ clientMultisampleAvailable = isMultisampleAvailable(GLX.glXGetClientString(x11Device.getHandle(), GLX.GLX_EXTENSIONS));
+ clientVendorName = GLX.glXGetClientString(x11Device.getHandle(), GLX.GLX_VENDOR);
+
+ int[] major = new int[1];
+ int[] minor = new int[1];
+ final String str = GLX.glXGetClientString(x11Device.getHandle(), GLX.GLX_VERSION);
+ try {
// e.g. "1.3"
major[0] = Integer.valueOf(str.substring(0, 1)).intValue();
minor[0] = Integer.valueOf(str.substring(2, 3)).intValue();
- } catch (Exception e) {
+ } catch (Exception e) {
major[0] = 1;
minor[0] = 2;
- }
}
+ clientVersionNumber = new VersionNumber(major[0], minor[0], 0);
+ return true;
}
+ private static boolean clientMultisampleAvailable = false;
+ private static String clientVendorName = null;
+ private static VersionNumber clientVersionNumber = null;
}