diff options
author | Sven Gothel <[email protected]> | 2011-10-08 03:19:41 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-10-08 03:19:41 +0200 |
commit | 0c138d5410ed32bdeef22052b57f1bcecf6b5d4f (patch) | |
tree | 55707ace5fa46d3c97f621e5bdcca1c380991b4b /src/jogl/classes/javax/media/opengl | |
parent | 727c697f6808caec2fcbcc35d155552590d4f869 (diff) |
Generalize sample extension in GLCapabilities*, currently NV_coverage_sample is respected in EGL
Diffstat (limited to 'src/jogl/classes/javax/media/opengl')
3 files changed, 54 insertions, 49 deletions
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java index 0ad97c3bf..803a47c34 100644 --- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java +++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java @@ -127,6 +127,7 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { 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) @@ -140,6 +141,7 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { scores[i] = NO_SCORE; } final int gldes_samples = gldes.getSampleBuffers() ? gldes.getNumSamples() : 0; + final boolean gldes_defaultSampleExt = gldes.getSampleExtension().equals(GLCapabilitiesImmutable.DEFAULT_SAMPLE_EXTENSION); // Compute score for each for (int i = 0; i < availnum; i++) { @@ -187,8 +189,13 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { 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; + if (gldes_samples > 0) { + if (cur_samples == 0) { + score += sign(score) * MULTISAMPLE_MISMATCH_PENALTY; + } + if (!gldes_defaultSampleExt && !gldes.getSampleExtension().equals(cur.getSampleExtension())) { + score += sign(score) * MULTISAMPLE_EXTENSION_MISMATCH_PENALTY; + } } scores[i] = score; } diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java index 4d9d08827..9022c7df5 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java @@ -69,6 +69,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil // are unlikely to be supported on Windows anyway // Support for full-scene antialiasing (FSAA) + private String sampleExtension = DEFAULT_SAMPLE_EXTENSION; private boolean sampleBuffers = false; private int numSamples = 2; @@ -111,6 +112,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil hash = ((hash << 5) - hash) + this.accumAlphaBits; hash = ((hash << 5) - hash) + ( this.sampleBuffers ? 1 : 0 ); hash = ((hash << 5) - hash) + this.numSamples; + hash = ((hash << 5) - hash) + this.sampleExtension.hashCode(); hash = ((hash << 5) - hash) + ( this.pbufferFloatingPointBuffers ? 1 : 0 ); hash = ((hash << 5) - hash) + ( this.pbufferRenderToTexture ? 1 : 0 ); hash = ((hash << 5) - hash) + ( this.pbufferRenderToTextureRectangle ? 1 : 0 ); @@ -139,7 +141,9 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil other.getPbufferRenderToTexture()==pbufferRenderToTexture && other.getPbufferRenderToTextureRectangle()==pbufferRenderToTextureRectangle; if(sampleBuffers) { - res = res && other.getNumSamples()==numSamples; + res = res && + other.getNumSamples()==numSamples && + other.getSampleExtension().equals(sampleExtension) ; } return res; } @@ -147,7 +151,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil /** comparing hw/sw, stereo, multisample, stencil, RGBA and depth only */ public int compareTo(Object o) { if ( ! ( o instanceof GLCapabilities ) ) { - Class c = (null != o) ? o.getClass() : null ; + Class<?> c = (null != o) ? o.getClass() : null ; throw new ClassCastException("Not a GLCapabilities object: " + c); } @@ -173,6 +177,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil } else if( ms < xms ) { return -1; } + // ignore the sample extension if(stencilBits > caps.stencilBits) { return 1; @@ -194,7 +199,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil return 0; // they are equal: hw/sw, stereo, multisample, stencil, RGBA and depth } - /** Returns the GL profile you desire or used by the drawable. */ public GLProfile getGLProfile() { return glProfile; } @@ -204,7 +208,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil glProfile=profile; } - /** Indicates whether pbuffer is used/requested. */ public boolean isPBuffer() { return pbuffer; } @@ -233,7 +236,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil super.setOnscreen(onscreen); } - /** Indicates whether double-buffering is enabled. */ public boolean getDoubleBuffered() { return doubleBuffered; } @@ -243,7 +245,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil doubleBuffered = enable; } - /** Indicates whether stereo is enabled. */ public boolean getStereo() { return stereo; } @@ -253,7 +254,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil stereo = enable; } - /** Indicates whether hardware acceleration is enabled. */ public boolean getHardwareAccelerated() { return hardwareAccelerated; } @@ -263,7 +263,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil hardwareAccelerated = enable; } - /** Returns the number of bits requested for the depth buffer. */ public int getDepthBits() { return depthBits; } @@ -273,7 +272,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil this.depthBits = depthBits; } - /** Returns the number of bits requested for the stencil buffer. */ public int getStencilBits() { return stencilBits; } @@ -283,10 +281,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil this.stencilBits = stencilBits; } - /** Returns the number of bits requested for the accumulation - buffer's red component. On some systems only the accumulation - buffer depth, which is the sum of the red, green, and blue bits, - is considered. */ public int getAccumRedBits() { return accumRedBits; } @@ -299,10 +293,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil this.accumRedBits = accumRedBits; } - /** Returns the number of bits requested for the accumulation - buffer's green component. On some systems only the accumulation - buffer depth, which is the sum of the red, green, and blue bits, - is considered. */ public int getAccumGreenBits() { return accumGreenBits; } @@ -315,10 +305,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil this.accumGreenBits = accumGreenBits; } - /** Returns the number of bits requested for the accumulation - buffer's blue component. On some systems only the accumulation - buffer depth, which is the sum of the red, green, and blue bits, - is considered. */ public int getAccumBlueBits() { return accumBlueBits; } @@ -331,10 +317,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil this.accumBlueBits = accumBlueBits; } - /** Returns the number of bits requested for the accumulation - buffer's alpha component. On some systems only the accumulation - buffer depth, which is the sum of the red, green, and blue bits, - is considered. */ public int getAccumAlphaBits() { return accumAlphaBits; } @@ -348,6 +330,18 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil } /** + * Sets the desired extension for full-scene antialiasing + * (FSAA), default is {@link #DEFAULT_SAMPLE_EXTENSION}. + */ + public void setSampleExtension(String se) { + sampleExtension = se; + } + + public String getSampleExtension() { + return sampleExtension; + } + + /** * Defaults to false.<br> * Indicates whether sample buffers for full-scene antialiasing * (FSAA) should be allocated for this drawable.<br> @@ -362,9 +356,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil } } - /** Returns whether sample buffers for full-scene antialiasing - (FSAA) should be allocated for this drawable. Defaults to - false. */ public boolean getSampleBuffers() { return sampleBuffers; } @@ -375,8 +366,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil this.numSamples = numSamples; } - /** Returns the number of sample buffers to be allocated if sample - buffers are enabled. Defaults to 2. */ public int getNumSamples() { return numSamples; } @@ -387,8 +376,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil pbufferFloatingPointBuffers = enable; } - /** For pbuffers only, returns whether floating-point buffers should - be used if available. Defaults to false. */ public boolean getPbufferFloatingPointBuffers() { return pbufferFloatingPointBuffers; } @@ -399,8 +386,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil pbufferRenderToTexture = enable; } - /** For pbuffers only, returns whether the render-to-texture - extension should be used if available. Defaults to false. */ public boolean getPbufferRenderToTexture() { return pbufferRenderToTexture; } @@ -412,8 +397,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil pbufferRenderToTextureRectangle = enable; } - /** For pbuffers only, returns whether the render-to-texture - extension should be used. Defaults to false. */ public boolean getPbufferRenderToTextureRectangle() { return pbufferRenderToTextureRectangle; } @@ -429,6 +412,9 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil sink.append(", accum-rgba ").append(accumRedBits).append("/").append(accumGreenBits).append("/").append(accumBlueBits).append("/").append(accumAlphaBits); sink.append(", dp/st/ms: ").append(depthBits).append("/").append(stencilBits).append("/").append(samples); + if(samples>0) { + sink.append(", sample-ext ").append(sampleExtension); + } if(doubleBuffered) { sink.append(", dbl"); } else { diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java index b91ceae7a..5f8795edc 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java @@ -37,6 +37,17 @@ import javax.media.nativewindow.CapabilitiesImmutable; * @see javax.media.nativewindow.CapabilitiesImmutable */ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { + /** + * One of the platform's default sample extension + * <code>EGL.EGL_SAMPLES, GLX.GLX_SAMPLES, WGLExt.WGL_SAMPLES_ARB</code> + * if available, or any other <i>known</i> fallback one, ie <code>EGLExt.EGL_COVERAGE_SAMPLES_NV</code> + */ + public static final String DEFAULT_SAMPLE_EXTENSION = "default" ; + + /** + * Returns the GL profile you desire or used by the drawable. + */ + GLProfile getGLProfile(); /** * Returns the number of bits requested for the accumulation @@ -81,14 +92,22 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { boolean getDoubleBuffered(); /** - * Returns the GL profile you desire or used by the drawable. + * Indicates whether hardware acceleration is enabled. */ - GLProfile getGLProfile(); + boolean getHardwareAccelerated(); /** - * Indicates whether hardware acceleration is enabled. + * Returns the used extension for full-scene antialiasing + * (FSAA), default is {@link #DEFAULT_SAMPLE_EXTENSION}. */ - boolean getHardwareAccelerated(); + String getSampleExtension(); + + /** + * Returns whether sample buffers for full-scene antialiasing + * (FSAA) should be allocated for this drawable. Defaults to + * false. + */ + boolean getSampleBuffers(); /** * Returns the number of sample buffers to be allocated if sample @@ -115,13 +134,6 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { boolean getPbufferRenderToTextureRectangle(); /** - * Returns whether sample buffers for full-scene antialiasing - * (FSAA) should be allocated for this drawable. Defaults to - * false. - */ - boolean getSampleBuffers(); - - /** * Returns the number of bits requested for the stencil buffer. */ int getStencilBits(); |