diff options
author | Sven Gothel <[email protected]> | 2011-10-01 03:04:52 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-10-01 03:04:52 +0200 |
commit | 8612203a071f32b81f692374f17f495336cad64f (patch) | |
tree | 05de534971974556daf314b0756751224a77bc9d /src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java | |
parent | df3c10d8bb7c220b4837733a2fc5a53b7f56f50d (diff) |
DefaultGLCapabilitiesChooser: Add multisampling criteria
Diffstat (limited to 'src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java index be509c332..0ad97c3bf 100644 --- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java +++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java @@ -42,6 +42,8 @@ package javax.media.opengl; import javax.media.nativewindow.NativeWindowException; import jogamp.opengl.Debug; + +import java.security.AccessController; import java.util.List; import javax.media.nativewindow.CapabilitiesImmutable; @@ -84,7 +86,7 @@ import javax.media.nativewindow.CapabilitiesImmutable; */ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { - private static final boolean DEBUG = Debug.debug("CapabilitiesChooser"); + private static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.CapabilitiesChooser", true, AccessController.getContext()); public int chooseCapabilities(final CapabilitiesImmutable desired, final List /*<CapabilitiesImmutable>*/ available, @@ -124,6 +126,7 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { 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; // Pseudo attempt to keep equal rank penalties scale-equivalent // (e.g., stencil mismatch is 3 * accum because there are 3 accum // components) @@ -131,10 +134,13 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { 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; } + final int gldes_samples = gldes.getSampleBuffers() ? gldes.getNumSamples() : 0; + // Compute score for each for (int i = 0; i < availnum; i++) { GLCapabilitiesImmutable cur = (GLCapabilitiesImmutable) available.get(i); @@ -150,7 +156,10 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { if (gldes.getStereo() != cur.getStereo()) { continue; } + final int cur_samples = + cur.getSampleBuffers() ? cur.getNumSamples() : 0; int score = 0; + // Compute difference in color depth // (Note that this decides the direction of all other penalties) score += (COLOR_MISMATCH_PENALTY_SCALE * @@ -165,15 +174,22 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { (gldes.getAccumRedBits() + gldes.getAccumGreenBits() + gldes.getAccumBlueBits() + gldes.getAccumAlphaBits()))); // Compute difference in stencil bits score += STENCIL_MISMATCH_PENALTY_SCALE * sign(score) * (cur.getStencilBits() - gldes.getStencilBits()); + // Compute difference in multisampling bits + score += MULTISAMPLE_MISMATCH_PENALTY_SCALE * sign(score) * (cur_samples - gldes_samples); + // double buffer if (cur.getDoubleBuffered() != gldes.getDoubleBuffered()) { score += sign(score) * DOUBLE_BUFFER_MISMATCH_PENALTY; } + // opaque if (cur.isBackgroundOpaque() != gldes.isBackgroundOpaque()) { score += sign(score) * OPAQUE_MISMATCH_PENALTY; } if ((gldes.getStencilBits() > 0) && (cur.getStencilBits() == 0)) { score += sign(score) * STENCIL_MISMATCH_PENALTY; } + if ((gldes_samples > 0) && (cur_samples == 0)) { + score += sign(score) * MULTISAMPLE_MISMATCH_PENALTY; + } scores[i] = score; } // Now prefer hardware-accelerated visuals by pushing scores of |