aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/javax/media/opengl')
-rw-r--r--src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java29
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java49
2 files changed, 59 insertions, 19 deletions
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
index 1bb509479..8aa6d5165 100644
--- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
+++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
@@ -88,6 +88,21 @@ import javax.media.nativewindow.CapabilitiesImmutable;
public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
private static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.CapabilitiesChooser", true, AccessController.getContext());
+ final static int NO_SCORE = -9999999;
+ final static int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000;
+ final static int OPAQUE_MISMATCH_PENALTY = 750;
+ final static int STENCIL_MISMATCH_PENALTY = 500;
+ final static int MULTISAMPLE_MISMATCH_PENALTY = 500;
+ final static int MULTISAMPLE_EXTENSION_MISMATCH_PENALTY = 250; // just a little drop, no scale
+ // Pseudo attempt to keep equal rank penalties scale-equivalent
+ // (e.g., stencil mismatch is 3 * accum because there are 3 accum
+ // components)
+ final static int COLOR_MISMATCH_PENALTY_SCALE = 36;
+ final static int DEPTH_MISMATCH_PENALTY_SCALE = 6;
+ final static int ACCUM_MISMATCH_PENALTY_SCALE = 1;
+ final static int STENCIL_MISMATCH_PENALTY_SCALE = 3;
+ final static int MULTISAMPLE_MISMATCH_PENALTY_SCALE = 3;
+
public int chooseCapabilities(final CapabilitiesImmutable desired,
final List /*<CapabilitiesImmutable>*/ available,
final int windowSystemRecommendedChoice) {
@@ -122,20 +137,6 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
// Create score array
int[] scores = new int[availnum];
- final int NO_SCORE = -9999999;
- final int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000;
- final int OPAQUE_MISMATCH_PENALTY = 750;
- final int STENCIL_MISMATCH_PENALTY = 500;
- final int MULTISAMPLE_MISMATCH_PENALTY = 500;
- final int MULTISAMPLE_EXTENSION_MISMATCH_PENALTY = 250; // just a little drop, no scale
- // Pseudo attempt to keep equal rank penalties scale-equivalent
- // (e.g., stencil mismatch is 3 * accum because there are 3 accum
- // components)
- final int COLOR_MISMATCH_PENALTY_SCALE = 36;
- final int DEPTH_MISMATCH_PENALTY_SCALE = 6;
- final int ACCUM_MISMATCH_PENALTY_SCALE = 1;
- final int STENCIL_MISMATCH_PENALTY_SCALE = 3;
- final int MULTISAMPLE_MISMATCH_PENALTY_SCALE = 3;
for (int i = 0; i < scores.length; i++) {
scores[i] = NO_SCORE;
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) {