aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-08 03:19:41 +0200
committerSven Gothel <[email protected]>2011-10-08 03:19:41 +0200
commit0c138d5410ed32bdeef22052b57f1bcecf6b5d4f (patch)
tree55707ace5fa46d3c97f621e5bdcca1c380991b4b
parent727c697f6808caec2fcbcc35d155552590d4f869 (diff)
Generalize sample extension in GLCapabilities*, currently NV_coverage_sample is respected in EGL
-rw-r--r--src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java11
-rw-r--r--src/jogl/classes/javax/media/opengl/GLCapabilities.java58
-rw-r--r--src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java34
-rw-r--r--src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java1
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java20
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java24
6 files changed, 75 insertions, 73 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();
diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
index cc7a578cd..318d00637 100644
--- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
+++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
@@ -33,6 +33,7 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesImmutable;
public class GLGraphicsConfigurationUtil {
+ public static final String NV_coverage_sample = "NV_coverage_sample";
public static final int WINDOW_BIT = 1 << 0;
public static final int BITMAP_BIT = 1 << 1;
public static final int PBUFFER_BIT = 1 << 2;
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
index 42d911610..bd5eb1b99 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
@@ -38,25 +38,13 @@ public class EGLGLCapabilities extends GLCapabilities {
final int eglcfgid;
final int renderableType;
int nativeVisualID;
- boolean useNV_coverage_sample;
/** Comparing EGLConfig ID only */
- public static class EglCfgIDComparator implements Comparator {
+ public static class EglCfgIDComparator implements Comparator<EGLGLCapabilities> {
- public int compare(Object o1, Object o2) {
- if ( ! ( o1 instanceof EGLGLCapabilities ) ) {
- Class c = (null != o1) ? o1.getClass() : null ;
- throw new ClassCastException("arg1 not a EGLGLCapabilities object: " + c);
- }
- if ( ! ( o2 instanceof EGLGLCapabilities ) ) {
- Class c = (null != o2) ? o2.getClass() : null ;
- throw new ClassCastException("arg2 not a EGLGLCapabilities object: " + c);
- }
-
- final EGLGLCapabilities caps1 = (EGLGLCapabilities) o1;
+ public int compare(EGLGLCapabilities caps1, EGLGLCapabilities caps2) {
final long id1 = caps1.getEGLConfigID();
- final EGLGLCapabilities caps2 = (EGLGLCapabilities) o2;
final long id2 = caps2.getEGLConfigID();
if(id1 > id2) {
@@ -86,7 +74,6 @@ public class EGLGLCapabilities extends GLCapabilities {
" with EGL-RenderableType["+renderableTypeToString(null, renderableType)+"]");
}
this.renderableType = renderableType;
- this.useNV_coverage_sample = false;
}
public Object cloneMutable() {
@@ -106,8 +93,6 @@ public class EGLGLCapabilities extends GLCapabilities {
final public int getRenderableType() { return renderableType; }
final public void setNativeVisualID(int vid) { nativeVisualID=vid; }
final public int getNativeVisualID() { return nativeVisualID; }
- final public boolean getUseNV_coverage_sample() { return useNV_coverage_sample; }
- final public void setUseNV_coverage_sample(boolean v) { useNV_coverage_sample=v; }
public static boolean isCompatible(GLProfile glp, int renderableType) {
if(null == glp) {
@@ -165,7 +150,6 @@ public class EGLGLCapabilities extends GLCapabilities {
sink.append("0x").append(Long.toHexString(eglcfgid)).append(": ");
sink.append("vid 0x").append(Integer.toHexString(nativeVisualID)).append(", ");
super.toString(sink);
- sink.append(", nv-covrg ").append(getUseNV_coverage_sample());
sink.append(", [");
renderableTypeToString(sink, renderableType);
return sink.append("]");
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
index 5f241a1d0..4fb3dca78 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
@@ -222,7 +222,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
if(EGL.eglGetConfigAttrib(display, config, EGLExt.EGL_COVERAGE_BUFFERS_NV, val)) {
if(val.get(0)>0 &&
EGL.eglGetConfigAttrib(display, config, EGLExt.EGL_COVERAGE_SAMPLES_NV, val)) {
- caps.setUseNV_coverage_sample(true);
+ caps.setSampleExtension(GLGraphicsConfigurationUtil.NV_coverage_sample);
caps.setSampleBuffers(true);
caps.setNumSamples(val.get(0));
}
@@ -274,13 +274,25 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
attrs[idx++] = EGL.EGL_DEPTH_SIZE;
attrs[idx++] = caps.getDepthBits();
- attrs[idx++] = EGL.EGL_SAMPLES;
- attrs[idx++] = caps.getSampleBuffers() ? caps.getNumSamples() : 1;
+ if(caps.getSampleBuffers()) {
+ if(caps.getSampleExtension().equals(GLGraphicsConfigurationUtil.NV_coverage_sample)) {
+ attrs[idx++] = EGLExt.EGL_COVERAGE_BUFFERS_NV;
+ attrs[idx++] = 1;
+ attrs[idx++] = EGLExt.EGL_COVERAGE_SAMPLES_NV;
+ attrs[idx++] = caps.getNumSamples();
+ } else {
+ // try default ..
+ attrs[idx++] = EGL.EGL_SAMPLE_BUFFERS;
+ attrs[idx++] = 1;
+ attrs[idx++] = EGL.EGL_SAMPLES;
+ attrs[idx++] = caps.getNumSamples();
+ }
+ }
attrs[idx++] = EGL.EGL_TRANSPARENT_TYPE;
attrs[idx++] = caps.isBackgroundOpaque() ? EGL.EGL_NONE : EGL.EGL_TRANSPARENT_TYPE;
- // 20
+ // 22
if(!caps.isBackgroundOpaque()) {
attrs[idx++] = EGL.EGL_TRANSPARENT_RED_VALUE;
@@ -297,7 +309,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
attrs[idx++] = caps.getTransparentAlphaValue()>=0?caps.getTransparentAlphaValue():EGL.EGL_DONT_CARE; */
}
- // 26
+ // 28
attrs[idx++] = EGL.EGL_RENDERABLE_TYPE;
if(caps.getGLProfile().usesNativeGLES1()) {
attrs[idx++] = EGL.EGL_OPENGL_ES_BIT;
@@ -307,7 +319,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
attrs[idx++] = EGL.EGL_OPENGL_BIT;
}
- // 28
+ // 30
attrs[idx++] = EGL.EGL_NONE;