aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java49
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLContext.java13
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java9
6 files changed, 63 insertions, 28 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index c039112c1..cc6b40f54 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -128,6 +128,7 @@ public abstract class GLContext {
protected int ctxMinorVersion;
protected int ctxOptions;
protected String ctxVersionString;
+ private int currentSwapInterval;
protected void resetStates() {
ctxMajorVersion=-1;
@@ -137,6 +138,7 @@ public abstract class GLContext {
attachedObjectsByString.clear();
attachedObjectsByInt.clear();
contextHandle=0;
+ currentSwapInterval = -1;
}
/**
@@ -621,17 +623,54 @@ public abstract class GLContext {
return isGL2GL3() || isGLES2() ;
}
- public final void setSwapInterval(int interval) {
+ /**
+ * Set the swap interval if the current context.
+ * @param interval Should be ≥ 0. 0 Disables the vertical synchronisation,
+ * where ≥ 1 is the number of vertical refreshes before a swap buffer occurs.
+ * A value < 0 is ignored.
+ * @return true if the operation was successful, otherwise false
+ *
+ * @throws GLException if the context is not current.
+ */
+ public final boolean setSwapInterval(int interval) throws GLException {
if (!isCurrent()) {
throw new GLException("This context is not current. Current context: "+getCurrent()+", this context "+this);
}
- setSwapIntervalImpl(interval);
+ if(0<=interval) {
+ if( setSwapIntervalImpl(interval) ) {
+ currentSwapInterval = interval;
+ return true;
+ }
+ }
+ return false;
}
- protected void setSwapIntervalImpl(int interval) { /** nop per default .. **/ }
- protected int currentSwapInterval = -1; // default: not set yet ..
- public int getSwapInterval() {
+ protected boolean setSwapIntervalImpl(int interval) {
+ return false;
+ }
+ /** Return the current swap interval.
+ * <p>
+ * If the context has not been made current at all,
+ * the default value <code>-1</code> is returned.
+ * </p>
+ * <p>
+ * The default value for a valid context is <code>1</code> for
+ * an EGL based profile (ES1 or ES2) and <code>-1</code> (undefined)
+ * for desktop.
+ * </p>
+ */
+ public final int getSwapInterval() {
+ if(-1 == currentSwapInterval && this.isGLES()) {
+ currentSwapInterval = 1;
+ }
return currentSwapInterval;
}
+ protected final void setDefaultSwapInterval() {
+ if(this.isGLES()) {
+ currentSwapInterval = 1;
+ } else {
+ currentSwapInterval = -1;
+ }
+ }
public final boolean queryMaxSwapGroups(int[] maxGroups, int maxGroups_offset,
int[] maxBarriers, int maxBarriers_offset) {
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 8c9ac589a..49b90008b 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -1083,6 +1083,8 @@ public abstract class GLContextImpl extends GLContext {
// Set GL Version (complete w/ version string)
//
setContextVersion(major, minor, ctxProfileBits, true);
+
+ setDefaultSwapInterval();
}
protected final void removeCachedVersion(int major, int minor, int ctxProfileBits) {
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
index dc47799c1..f5f9f62c4 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
@@ -274,18 +274,19 @@ public abstract class EGLContext extends GLContextImpl {
return sb;
}
- protected void setSwapIntervalImpl(int interval) {
+ @Override
+ protected boolean setSwapIntervalImpl(int interval) {
// FIXME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// eglSwapInterval(..) issued:
// Android 4.0.3 / Pandaboard ES / PowerVR SGX 540: crashes
// FIXME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- if( ! ( Platform.OSType.ANDROID == Platform.getOSType() && getGLRendererString(true).contains("powervr") ) ) {
- if (EGL.eglSwapInterval(((EGLDrawable)drawable).getDisplay(), interval)) {
- currentSwapInterval = interval ;
+ if( Platform.OSType.ANDROID == Platform.getOSType() && getGLRendererString(true).contains("powervr") ) {
+ if(DEBUG) {
+ System.err.println("Ignored: eglSwapInterval("+interval+") - cause: OS "+Platform.getOSType() + " / Renderer " + getGLRendererString(false));
}
- } else if(DEBUG) {
- System.err.println("Ignored: eglSwapInterval("+interval+") - cause: OS "+Platform.getOSType() + " / Renderer " + getGLRendererString(false));
+ return false;
}
+ return EGL.eglSwapInterval(((EGLDrawable)drawable).getDisplay(), interval);
}
public abstract void bindPbufferToTexture();
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index 4ef49e337..63d58f447 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -279,14 +279,9 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
}
- protected void setSwapIntervalImpl(int interval) {
- if( ! isCreated() ) {
- throw new GLException("OpenGL context not created");
- }
- if(!impl.setSwapInterval(interval)) {
- throw new GLException("Error set swap-interval: "+this);
- }
- currentSwapInterval = interval ;
+ @Override
+ protected boolean setSwapIntervalImpl(int interval) {
+ return impl.setSwapInterval(interval);
}
public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
index 06dc07c1e..a6ef9bd1c 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
@@ -435,7 +435,7 @@ public class WindowsWGLContext extends GLContextImpl {
}
@Override
- protected void setSwapIntervalImpl(int interval) {
+ protected boolean setSwapIntervalImpl(int interval) {
WGLExt wglExt = getWGLExt();
if(0==hasSwapIntervalSGI) {
try {
@@ -444,11 +444,10 @@ public class WindowsWGLContext extends GLContextImpl {
}
if (hasSwapIntervalSGI>0) {
try {
- if ( wglExt.wglSwapIntervalEXT(interval) ) {
- currentSwapInterval = interval ;
- }
+ return wglExt.wglSwapIntervalEXT(interval);
} catch (Throwable t) { hasSwapIntervalSGI=-1; }
}
+ return false;
}
private final int initSwapGroupImpl(WGLExt wglExt) {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index 79361ac0c..1dc1441e1 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -509,10 +509,10 @@ public abstract class X11GLXContext extends GLContextImpl {
}
@Override
- protected void setSwapIntervalImpl(int interval) {
+ protected boolean setSwapIntervalImpl(int interval) {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration();
GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
- if(!glCaps.isOnscreen()) return;
+ if(!glCaps.isOnscreen()) { return false; }
GLXExt glXExt = getGLXExt();
if(0==hasSwapIntervalSGI) {
@@ -522,11 +522,10 @@ public abstract class X11GLXContext extends GLContextImpl {
}
if (hasSwapIntervalSGI>0) {
try {
- if( 0 == glXExt.glXSwapIntervalSGI(interval) ) {
- currentSwapInterval = interval;
- }
+ return 0 == glXExt.glXSwapIntervalSGI(interval);
} catch (Throwable t) { hasSwapIntervalSGI=-1; }
}
+ return false;
}
private final int initSwapGroupImpl(GLXExt glXExt) {