summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-10 04:51:28 +0100
committerSven Gothel <[email protected]>2012-03-10 04:51:28 +0100
commitf0f696c4253691503a0d66636ea779e0731bda84 (patch)
tree74007b3923b06e040528429f7503715af74bc1a4 /src/jogl/classes/javax/media
parent42a08f9c8a6b86a104d9feba6e29397933b020c5 (diff)
GL/GLContext: Properly define swapInterval incl. default value for EGL (1) and desktop (undefined).
*GLContext.setSwapIntervalImpl: Simple return success, set state in GLContext.
Diffstat (limited to 'src/jogl/classes/javax/media')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java49
1 files changed, 44 insertions, 5 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 &ge; 0. 0 Disables the vertical synchronisation,
+ * where &ge; 1 is the number of vertical refreshes before a swap buffer occurs.
+ * A value &lt; 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) {