summaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java42
-rw-r--r--src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java24
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java29
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLContext.java29
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java20
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java109
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java140
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java1
9 files changed, 312 insertions, 89 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 0727dad1b..47a453484 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -549,6 +549,48 @@ public abstract class GLContext {
return isGL2ES2() ;
}
+ public final void setSwapInterval(int interval) {
+ if (!isCurrent()) {
+ throw new GLException("This context is not current. Current context: "+getCurrent()+", this context "+this);
+ }
+ setSwapIntervalImpl(interval);
+ }
+ protected void setSwapIntervalImpl(int interval) { /** nop per default .. **/ }
+ protected int currentSwapInterval = -1; // default: not set yet ..
+ public int getSwapInterval() {
+ return currentSwapInterval;
+ }
+
+ public final boolean queryMaxSwapGroups(int[] maxGroups, int maxGroups_offset,
+ int[] maxBarriers, int maxBarriers_offset) {
+
+ if (!isCurrent()) {
+ throw new GLException("This context is not current. Current context: "+getCurrent()+", this context "+this);
+ }
+ return queryMaxSwapGroupsImpl(maxGroups, maxGroups_offset, maxBarriers, maxBarriers_offset);
+ }
+ protected boolean queryMaxSwapGroupsImpl(int[] maxGroups, int maxGroups_offset,
+ int[] maxBarriers, int maxBarriers_offset) { return false; }
+ public final boolean joinSwapGroup(int group) {
+ if (!isCurrent()) {
+ throw new GLException("This context is not current. Current context: "+getCurrent()+", this context "+this);
+ }
+ return joinSwapGroupImpl(group);
+ }
+ protected boolean joinSwapGroupImpl(int group) { /** nop per default .. **/ return false; }
+ protected int currentSwapGroup = -1; // default: not set yet ..
+ public int getSwapGroup() {
+ return currentSwapGroup;
+ }
+ public final boolean bindSwapBarrier(int group, int barrier) {
+ if (!isCurrent()) {
+ throw new GLException("This context is not current. Current context: "+getCurrent()+", this context "+this);
+ }
+ return bindSwapBarrierImpl(group, barrier);
+ }
+ protected boolean bindSwapBarrierImpl(int group, int barrier) { /** nop per default .. **/ return false; }
+
+
/**
* @return The extension implementing the GLDebugOutput feature,
* either <i>GL_ARB_debug_output</i> or <i>GL_AMD_debug_output</i>.
diff --git a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java
index 971b32d47..a35137f15 100644
--- a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java
+++ b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java
@@ -41,6 +41,7 @@
package jogamp.opengl;
import javax.media.opengl.*;
+
import java.util.*;
/**
@@ -132,9 +133,9 @@ final class ExtensionAvailabilityCache {
if(useGetStringi) {
GL2GL3 gl2gl3 = gl.getGL2GL3();
int[] numExtensions = { 0 } ;
- gl2gl3.glGetIntegerv(gl2gl3.GL_NUM_EXTENSIONS, numExtensions, 0);
+ gl2gl3.glGetIntegerv(GL2GL3.GL_NUM_EXTENSIONS, numExtensions, 0);
for (int i = 0; i < numExtensions[0]; i++) {
- sb.append(gl2gl3.glGetStringi(gl2gl3.GL_EXTENSIONS, i));
+ sb.append(gl2gl3.glGetStringi(GL.GL_EXTENSIONS, i));
if(i < numExtensions[0]) {
sb.append(" ");
}
@@ -151,8 +152,21 @@ final class ExtensionAvailabilityCache {
sb.append(gl.glGetString(GL.GL_EXTENSIONS));
}
glExtensions = sb.toString();
- glXExtensions = context.getPlatformExtensionsString();
-
+
+ // Platform Extensions
+ {
+ // unify platform extension .. might have duplicates
+ HashSet<String> platformSet = new HashSet<String>(50);
+ StringTokenizer tok = new StringTokenizer(context.getPlatformExtensionsStringImpl().toString());
+ while (tok.hasMoreTokens()) {
+ platformSet.add(tok.nextToken().trim());
+ }
+ final StringBuffer sb2 = new StringBuffer();
+ for(Iterator<String> iter = platformSet.iterator(); iter.hasNext(); ) {
+ sb2.append(iter.next()).append(" ");
+ }
+ glXExtensions = sb2.toString();
+ }
sb.append(" ");
sb.append(glXExtensions);
@@ -210,7 +224,7 @@ final class ExtensionAvailabilityCache {
private boolean initialized = false;
private String glExtensions = null;
private String glXExtensions = null;
- private HashSet availableExtensionCache = new HashSet(50);
+ private HashSet<String> availableExtensionCache = new HashSet<String>(50);
private GLContextImpl context;
static String getThreadName() {
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index cf4a71a8a..c3fcc5057 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -126,6 +126,7 @@ public abstract class GLContextImpl extends GLContext {
this.glDebugHandler = new GLDebugMessageHandler(this);
}
+ @Override
protected void resetStates() {
// Because we don't know how many other contexts we might be
// sharing with (and it seems too complicated to implement the
@@ -800,24 +801,10 @@ public abstract class GLContextImpl extends GLContext {
public abstract ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3);
- public final void setSwapInterval(final int interval) {
- GLContext current = getCurrent();
- if (current != this) {
- throw new GLException("This context is not current. Current context: "+current+
- ", this context "+this);
- }
- setSwapIntervalImpl(interval);
- }
- protected void setSwapIntervalImpl(final int interval) { /** nop per default .. **/ }
- protected int currentSwapInterval = -1; // default: not set yet ..
- public int getSwapInterval() {
- return currentSwapInterval;
- }
-
/** Maps the given "platform-independent" function name to a real function
name. Currently this is only used to map "glAllocateMemoryNV" and
associated routines to wglAllocateMemoryNV / glXAllocateMemoryNV. */
- protected String mapToRealGLFunctionName(String glFunctionName) {
+ protected final String mapToRealGLFunctionName(String glFunctionName) {
Map<String, String> map = getFunctionNameMap();
String lookup = ( null != map ) ? map.get(glFunctionName) : null;
if (lookup != null) {
@@ -832,7 +819,7 @@ public abstract class GLContextImpl extends GLContext {
"GL_ARB_pbuffer" to "WGL_ARB_pbuffer/GLX_SGIX_pbuffer" and
"GL_ARB_pixel_format" to "WGL_ARB_pixel_format/n.a."
*/
- protected String mapToRealGLExtensionName(String glExtensionName) {
+ protected final String mapToRealGLExtensionName(String glExtensionName) {
Map<String, String> map = getExtensionNameMap();
String lookup = ( null != map ) ? map.get(glExtensionName) : null;
if (lookup != null) {
@@ -844,7 +831,7 @@ public abstract class GLContextImpl extends GLContext {
/** Helper routine which resets a ProcAddressTable generated by the
GLEmitter by looking up anew all of its function pointers. */
- protected void resetProcAddressTable(ProcAddressTable table) {
+ protected final void resetProcAddressTable(ProcAddressTable table) {
table.reset(getDrawableImpl().getGLDynamicLookupHelper() );
}
@@ -957,6 +944,8 @@ public abstract class GLContextImpl extends GLContext {
*/
protected abstract void updateGLXProcAddressTable();
+ protected abstract StringBuffer getPlatformExtensionsStringImpl();
+
/**
* Returns true if the specified OpenGL core- or extension-function can be
* successfully called using this GL context given the current host (OpenGL
@@ -968,7 +957,7 @@ public abstract class GLContextImpl extends GLContext {
* "glPolygonOffsetEXT" or "glPolygonOffset" to check if the {@link
* javax.media.opengl.GL#glPolygonOffset(float,float)} is available).
*/
- public boolean isFunctionAvailable(String glFunctionName) {
+ public final boolean isFunctionAvailable(String glFunctionName) {
// Check GL 1st (cached)
ProcAddressTable pTable = getGLProcAddressTable(); // null if ctx not created once
if(null!=pTable) {
@@ -1023,14 +1012,14 @@ public abstract class GLContextImpl extends GLContext {
return false;
}
- public String getPlatformExtensionsString() {
+ public final String getPlatformExtensionsString() {
if(null!=extensionAvailability) {
return extensionAvailability.getPlatformExtensionsString();
}
return null;
}
- public String getGLExtensionsString() {
+ public final String getGLExtensionsString() {
if(null!=extensionAvailability) {
return extensionAvailability.getGLExtensionsString();
}
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
index e04ced6fa..704f71457 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
@@ -44,6 +44,8 @@ import java.nio.*;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
+import com.jogamp.common.util.VersionNumber;
+
/** Extends GLDrawableFactory with a few methods for handling
typically software-accelerated offscreen rendering (Device
Independent Bitmaps on Windows, pixmaps on X11). Direct access to
@@ -51,6 +53,11 @@ import javax.media.opengl.*;
they may be instantiated by the GLJPanel implementation. */
public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
protected static final boolean DEBUG = GLDrawableImpl.DEBUG;
+ public static final VersionNumber versionOneZero = new VersionNumber(1, 0, 0);
+ public static final VersionNumber versionOneOne = new VersionNumber(1, 1, 0);
+ public static final VersionNumber versionOneTwo = new VersionNumber(1, 2, 0);
+ public static final VersionNumber versionOneThree = new VersionNumber(1, 3, 0);
+ public static final VersionNumber versionOneFour = new VersionNumber(1, 4, 0);
protected GLDrawableFactoryImpl() {
super();
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
index 4d39472a4..2deae65fb 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
@@ -42,13 +42,14 @@ import com.jogamp.gluegen.runtime.ProcAddressTable;
import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
import java.nio.*;
import java.util.*;
+
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
public abstract class EGLContext extends GLContextImpl {
private boolean eglQueryStringInitialized;
private boolean eglQueryStringAvailable;
- private EGLExt eglExt;
+ private EGLExt _eglExt;
// Table that holds the addresses of the native C-language entry points for
// EGL extension functions.
private EGLExtProcAddressTable eglExtProcAddressTable;
@@ -58,15 +59,23 @@ public abstract class EGLContext extends GLContextImpl {
super(drawable, shareWith);
}
+ @Override
+ protected void resetStates() {
+ eglQueryStringInitialized = false;
+ eglQueryStringAvailable = false;
+ // no inner state _eglExt = null;
+ super.resetStates();
+ }
+
public Object getPlatformGLExtensions() {
return getEGLExt();
}
public EGLExt getEGLExt() {
- if (eglExt == null) {
- eglExt = new EGLExtImpl(this);
+ if (_eglExt == null) {
+ _eglExt = new EGLExtImpl(this);
}
- return eglExt;
+ return _eglExt;
}
public final ProcAddressTable getPlatformExtProcAddressTable() {
@@ -237,22 +246,22 @@ public abstract class EGLContext extends GLContextImpl {
}
}
- public synchronized String getPlatformExtensionsString() {
+ protected final StringBuffer getPlatformExtensionsStringImpl() {
+ StringBuffer sb = new StringBuffer();
if (!eglQueryStringInitialized) {
eglQueryStringAvailable =
getDrawableImpl().getGLDynamicLookupHelper().dynamicLookupFunction("eglQueryString") != 0;
eglQueryStringInitialized = true;
}
if (eglQueryStringAvailable) {
- String ret = EGL.eglQueryString(((EGLDrawable)drawable).getDisplay(),
- EGL.EGL_EXTENSIONS);
+ final String ret = EGL.eglQueryString(((EGLDrawable)drawable).getDisplay(),
+ EGL.EGL_EXTENSIONS);
if (DEBUG) {
System.err.println("!!! EGL extensions: " + ret);
}
- return ret;
- } else {
- return "";
+ sb.append(ret);
}
+ return sb;
}
protected void setSwapIntervalImpl(int interval) {
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index f6fe16eae..150a5e105 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -51,7 +51,7 @@ import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
public abstract class MacOSXCGLContext extends GLContextImpl
{
protected boolean isNSContext;
- private CGLExt cglExt;
+ private CGLExt _cglExt;
// Table that holds the addresses of the native C-language entry points for
// CGL extension functions.
private CGLExtProcAddressTable cglExtProcAddressTable;
@@ -61,6 +61,13 @@ public abstract class MacOSXCGLContext extends GLContextImpl
super(drawable, shareWith);
}
+ @Override
+ protected void resetStates() {
+ isNSContext = false;
+ // no inner state _cglExt = null;
+ super.resetStates();
+ }
+
public Object getPlatformGLExtensions() {
return getCGLExt();
}
@@ -68,10 +75,10 @@ public abstract class MacOSXCGLContext extends GLContextImpl
protected boolean isNSContext() { return isNSContext; }
public CGLExt getCGLExt() {
- if (cglExt == null) {
- cglExt = new CGLExtImpl(this);
+ if (_cglExt == null) {
+ _cglExt = new CGLExtImpl(this);
}
- return cglExt;
+ return _cglExt;
}
public final ProcAddressTable getPlatformExtProcAddressTable() {
@@ -255,9 +262,8 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
}
- public String getPlatformExtensionsString()
- {
- return "";
+ protected final StringBuffer getPlatformExtensionsStringImpl() {
+ return new StringBuffer();
}
protected void swapBuffers() {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
index d48f76c13..b95b7edbf 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
@@ -46,6 +46,7 @@ import java.util.Map;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.NativeSurface;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLException;
import javax.media.opengl.GLCapabilitiesImmutable;
@@ -64,10 +65,12 @@ public class WindowsWGLContext extends GLContextImpl {
private boolean wglGetExtensionsStringEXTAvailable;
private boolean wglGLReadDrawableAvailableSet;
private boolean wglGLReadDrawableAvailable;
- private WGLExt wglExt;
+ private WGLExt _wglExt;
// Table that holds the addresses of the native C-language entry points for
// WGL extension functions.
private WGLExtProcAddressTable wglExtProcAddressTable;
+ private int hasSwapIntervalSGI = 0;
+ private int hasSwapGroupNV = 0;
static {
functionNameMap = new HashMap<String, String>();
@@ -85,13 +88,17 @@ public class WindowsWGLContext extends GLContextImpl {
super(drawable, shareWith);
}
- protected void resetState() {
+ @Override
+ protected void resetStates() {
wglGetExtensionsStringEXTInitialized=false;
wglGetExtensionsStringEXTAvailable=false;
wglGLReadDrawableAvailableSet=false;
wglGLReadDrawableAvailable=false;
// no inner state _wglExt=null;
wglExtProcAddressTable=null;
+ hasSwapIntervalSGI = 0;
+ hasSwapGroupNV = 0;
+ super.resetStates();
}
public Object getPlatformGLExtensions() {
@@ -102,10 +109,10 @@ public class WindowsWGLContext extends GLContextImpl {
if( null == getWGLExtProcAddressTable()) {
throw new InternalError("Null WGLExtProcAddressTable");
}
- if (wglExt == null) {
- wglExt = new WGLExtImpl(this);
+ if (_wglExt == null) {
+ _wglExt = new WGLExtImpl(this);
}
- return wglExt;
+ return _wglExt;
}
public final boolean isGLReadDrawableAvailable() {
@@ -141,8 +148,8 @@ public class WindowsWGLContext extends GLContextImpl {
int werr = ( !ok ) ? GDI.GetLastError() : GDI.ERROR_SUCCESS;
if(DEBUG && !ok) {
Throwable t = new Throwable ("Info: wglMakeContextCurrent draw "+
- this.toHexString(hDrawDC) + ", read " + this.toHexString(hReadDC) +
- ", ctx " + this.toHexString(ctx) + ", werr " + werr);
+ GLContext.toHexString(hDrawDC) + ", read " + GLContext.toHexString(hReadDC) +
+ ", ctx " + GLContext.toHexString(ctx) + ", werr " + werr);
t.printStackTrace();
}
if(!ok && 0==hDrawDC && 0==hReadDC) {
@@ -427,27 +434,95 @@ public class WindowsWGLContext extends GLContextImpl {
}
}
- public String getPlatformExtensionsString() {
+ protected final StringBuffer getPlatformExtensionsStringImpl() {
+ StringBuffer sb = new StringBuffer();
+
if (!wglGetExtensionsStringEXTInitialized) {
wglGetExtensionsStringEXTAvailable = (WGL.wglGetProcAddress("wglGetExtensionsStringEXT") != 0);
wglGetExtensionsStringEXTInitialized = true;
}
if (wglGetExtensionsStringEXTAvailable) {
- return getWGLExt().wglGetExtensionsStringEXT();
- } else {
- return "";
+ sb.append(getWGLExt().wglGetExtensionsStringEXT());
}
+ return sb;
}
-
+
+ @Override
protected void setSwapIntervalImpl(int interval) {
WGLExt wglExt = getWGLExt();
- if (wglExt.isExtensionAvailable("WGL_EXT_swap_control")) {
- if ( wglExt.wglSwapIntervalEXT(interval) ) {
- currentSwapInterval = interval ;
- }
+ if(0==hasSwapIntervalSGI) {
+ try {
+ hasSwapIntervalSGI = wglExt.isExtensionAvailable("WGL_EXT_swap_control")?1:-1;
+ } catch (Throwable t) { hasSwapIntervalSGI=1; }
+ }
+ if (hasSwapIntervalSGI>0) {
+ try {
+ if ( wglExt.wglSwapIntervalEXT(interval) ) {
+ currentSwapInterval = interval ;
+ }
+ } catch (Throwable t) { hasSwapIntervalSGI=-1; }
}
}
-
+
+ private final int initSwapGroupImpl(WGLExt wglExt) {
+ if(0==hasSwapGroupNV) {
+ try {
+ hasSwapGroupNV = wglExt.isExtensionAvailable("WGL_NV_swap_group")?1:-1;
+ } catch (Throwable t) { hasSwapGroupNV=1; }
+ if(DEBUG) {
+ System.err.println("initSwapGroupImpl: hasSwapGroupNV: "+hasSwapGroupNV);
+ }
+ }
+ return hasSwapGroupNV;
+ }
+
+ @Override
+ protected final boolean queryMaxSwapGroupsImpl(int[] maxGroups, int maxGroups_offset,
+ int[] maxBarriers, int maxBarriers_offset) {
+ boolean res = false;
+ WGLExt wglExt = getWGLExt();
+ if (initSwapGroupImpl(wglExt)>0) {
+ final NativeSurface ns = drawable.getNativeSurface();
+ try {
+ if( wglExt.wglQueryMaxSwapGroupsNV(ns.getDisplayHandle(),
+ maxGroups, maxGroups_offset,
+ maxBarriers, maxBarriers_offset) ) {
+ res = true;
+ }
+ } catch (Throwable t) { hasSwapGroupNV=-1; }
+ }
+ return res;
+ }
+
+ @Override
+ protected final boolean joinSwapGroupImpl(int group) {
+ boolean res = false;
+ WGLExt wglExt = getWGLExt();
+ if (initSwapGroupImpl(wglExt)>0) {
+ try {
+ if( wglExt.wglJoinSwapGroupNV(drawable.getHandle(), group) ) {
+ currentSwapGroup = group;
+ res = true;
+ }
+ } catch (Throwable t) { hasSwapGroupNV=-1; }
+ }
+ return res;
+ }
+
+ @Override
+ protected final boolean bindSwapBarrierImpl(int group, int barrier) {
+ boolean res = false;
+ WGLExt wglExt = getWGLExt();
+ if (initSwapGroupImpl(wglExt)>0) {
+ try {
+ if( wglExt.wglBindSwapBarrierNV(group, barrier) ) {
+ res = true;
+ }
+ } catch (Throwable t) { hasSwapGroupNV=-1; }
+ }
+ return res;
+ }
+
public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
return getWGLExt().wglAllocateMemoryNV(arg0, arg1, arg2, arg3);
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index 104fc031e..26ad41fc7 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -60,14 +60,14 @@ public abstract class X11GLXContext extends GLContextImpl {
private static final Map<String, String> functionNameMap;
private static final Map<String, String> extensionNameMap;
private VersionNumber glXVersion;
+ private boolean glXVersionOneOneCapable;
private boolean glXVersionOneThreeCapable;
- private boolean glXQueryExtensionsStringInitialized;
- private boolean glXQueryExtensionsStringAvailable;
- private GLXExt glXExt;
+ private GLXExt _glXExt;
// Table that holds the addresses of the native C-language entry points for
// GLX extension functions.
private GLXExtProcAddressTable glXExtProcAddressTable;
private int hasSwapIntervalSGI = 0;
+ private int hasSwapGroupNV = 0;
// This indicates whether the context we have created is indirect
// and therefore requires the toolkit to be locked around all GL
@@ -89,15 +89,17 @@ public abstract class X11GLXContext extends GLContextImpl {
super(drawable, shareWith);
}
- protected void resetState() {
+ @Override
+ protected void resetStates() {
glXVersion = null;
+ glXVersionOneOneCapable = false;
glXVersionOneThreeCapable = false;
- glXQueryExtensionsStringInitialized=false;
- glXQueryExtensionsStringAvailable=false;
- // no inner state glXExt=null;
+ // no inner state _glXExt=null;
glXExtProcAddressTable = null;
hasSwapIntervalSGI = 0;
+ hasSwapGroupNV = 0;
isDirect = false;
+ super.resetStates();
}
public final ProcAddressTable getPlatformExtProcAddressTable() {
@@ -113,24 +115,32 @@ public abstract class X11GLXContext extends GLContextImpl {
}
public GLXExt getGLXExt() {
- if (glXExt == null) {
- glXExt = new GLXExtImpl(this);
+ if (_glXExt == null) {
+ _glXExt = new GLXExtImpl(this);
}
- return glXExt;
+ return _glXExt;
}
protected Map<String, String> getFunctionNameMap() { return functionNameMap; }
protected Map<String, String> getExtensionNameMap() { return extensionNameMap; }
- public final boolean isGLXVersionGreaterEqualOneThree() {
+ private final void initGLXVersion() {
if(null == glXVersion) {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
X11GraphicsDevice device = (X11GraphicsDevice) config.getScreen().getDevice();
glXVersion = X11GLXDrawableFactory.getGLXVersion(device);
- glXVersionOneThreeCapable = ( null != glXVersion ) ? glXVersion.compareTo(X11GLXDrawableFactory.versionOneThree) >= 0 : false ;
- }
+ glXVersionOneOneCapable = ( null != glXVersion ) ? glXVersion.compareTo(GLDrawableFactoryImpl.versionOneOne) >= 0 : false ;
+ glXVersionOneThreeCapable = ( null != glXVersion ) ? glXVersion.compareTo(GLDrawableFactoryImpl.versionOneThree) >= 0 : false ;
+ }
+ }
+ public final boolean isGLXVersionGreaterEqualOneOne() {
+ initGLXVersion();
+ return glXVersionOneOneCapable;
+ }
+ public final boolean isGLXVersionGreaterEqualOneThree() {
+ initGLXVersion();
return glXVersionOneThreeCapable;
}
@@ -470,9 +480,6 @@ public abstract class X11GLXContext extends GLContextImpl {
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Initializing GLX extension address table: "+key);
}
- glXQueryExtensionsStringInitialized = false;
- glXQueryExtensionsStringAvailable = false;
-
ProcAddressTable table = null;
synchronized(mappedContextTypeObjectLock) {
table = mappedGLXProcAddress.get( key );
@@ -497,22 +504,36 @@ public abstract class X11GLXContext extends GLContextImpl {
}
}
- public synchronized String getPlatformExtensionsString() {
- if (!glXQueryExtensionsStringInitialized) {
- glXQueryExtensionsStringAvailable =
- getDrawableImpl().getGLDynamicLookupHelper().dynamicLookupFunction("glXQueryExtensionsString") != 0;
- glXQueryExtensionsStringInitialized = true;
+ protected final StringBuffer getPlatformExtensionsStringImpl() {
+ StringBuffer sb = new StringBuffer();
+ if (DEBUG) {
+ System.err.println("!!! GLX Version "+glXVersion);
}
- if (glXQueryExtensionsStringAvailable) {
- NativeSurface ns = drawable.getNativeSurface();
- String ret = GLX.glXQueryExtensionsString(ns.getDisplayHandle(), ns.getScreenIndex());
- if (DEBUG) {
- System.err.println("!!! GLX extensions: " + ret);
+ if(isGLXVersionGreaterEqualOneOne()) {
+ final NativeSurface ns = drawable.getNativeSurface();
+ {
+ final String ret = GLX.glXGetClientString(ns.getDisplayHandle(), GLX.GLX_EXTENSIONS);
+ if (DEBUG) {
+ System.err.println("!!! GLX extensions (glXGetClientString): " + ret);
+ }
+ sb.append(ret).append(" ");
+ }
+ {
+ final String ret = GLX.glXQueryExtensionsString(ns.getDisplayHandle(), ns.getScreenIndex());
+ if (DEBUG) {
+ System.err.println("!!! GLX extensions (glXQueryExtensionsString): " + ret);
+ }
+ sb.append(ret).append(" ");
+ }
+ {
+ final String ret = GLX.glXQueryServerString(ns.getDisplayHandle(), ns.getScreenIndex(), GLX.GLX_EXTENSIONS);
+ if (DEBUG) {
+ System.err.println("!!! GLX extensions (glXQueryServerString): " + ret);
+ }
+ sb.append(ret).append(" ");
}
- return ret;
- } else {
- return "";
}
+ return sb;
}
public boolean isExtensionAvailable(String glExtensionName) {
@@ -524,6 +545,7 @@ public abstract class X11GLXContext extends GLContextImpl {
return super.isExtensionAvailable(glExtensionName);
}
+ @Override
protected void setSwapIntervalImpl(int interval) {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
@@ -544,6 +566,66 @@ public abstract class X11GLXContext extends GLContextImpl {
}
}
+ private final int initSwapGroupImpl(GLXExt glXExt) {
+ if(0==hasSwapGroupNV) {
+ try {
+ hasSwapGroupNV = glXExt.isExtensionAvailable("GLX_NV_swap_group")?1:-1;
+ } catch (Throwable t) { hasSwapGroupNV=1; }
+ if(DEBUG) {
+ System.err.println("initSwapGroupImpl: hasSwapGroupNV: "+hasSwapGroupNV);
+ }
+ }
+ return hasSwapGroupNV;
+ }
+
+ @Override
+ protected final boolean queryMaxSwapGroupsImpl(int[] maxGroups, int maxGroups_offset,
+ int[] maxBarriers, int maxBarriers_offset) {
+ boolean res = false;
+ GLXExt glXExt = getGLXExt();
+ if (initSwapGroupImpl(glXExt)>0) {
+ final NativeSurface ns = drawable.getNativeSurface();
+ try {
+ if( glXExt.glXQueryMaxSwapGroupsNV(ns.getDisplayHandle(), ns.getScreenIndex(),
+ maxGroups, maxGroups_offset,
+ maxBarriers, maxBarriers_offset) ) {
+ res = true;
+ }
+ } catch (Throwable t) { hasSwapGroupNV=-1; }
+ }
+ return res;
+ }
+
+ @Override
+ protected final boolean joinSwapGroupImpl(int group) {
+ boolean res = false;
+ GLXExt glXExt = getGLXExt();
+ if (initSwapGroupImpl(glXExt)>0) {
+ try {
+ if( glXExt.glXJoinSwapGroupNV(drawable.getNativeSurface().getDisplayHandle(), drawable.getHandle(), group) ) {
+ currentSwapGroup = group;
+ res = true;
+ }
+ } catch (Throwable t) { hasSwapGroupNV=-1; }
+ }
+ return res;
+ }
+
+ @Override
+ protected final boolean bindSwapBarrierImpl(int group, int barrier) {
+ boolean res = false;
+ GLXExt glXExt = getGLXExt();
+ if (initSwapGroupImpl(glXExt)>0) {
+ try {
+ if( glXExt.glXBindSwapBarrierNV(drawable.getNativeSurface().getDisplayHandle(), group, barrier) ) {
+ res = true;
+ }
+ } catch (Throwable t) { hasSwapGroupNV=-1; }
+ }
+ return res;
+ }
+
+ @Override
public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
return getGLXExt().glXAllocateMemoryNV(arg0, arg1, arg2, arg3);
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
index d37d6c53a..51316dc77 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
@@ -56,7 +56,6 @@ import jogamp.nativewindow.x11.*;
public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
private static final DesktopGLDynamicLookupHelper x11GLXDynamicLookupHelper;
- static final VersionNumber versionOneThree = new VersionNumber(1, 3, 0);
static {
DesktopGLDynamicLookupHelper tmp = null;