summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-04-17 14:57:24 +0200
committerSven Gothel <[email protected]>2013-04-17 14:57:24 +0200
commit6dd851e74dde28d24a2d2bb6e788a78bc7fedd76 (patch)
tree0c384f7725ba8aa0526806bcce7ce9eefa07289e /src
parent1af639340bb119e4839170c6e5e3258012d99136 (diff)
*Capabilities: Cleanup string ctor; GLGraphicsConfigurationUtil: Clean getExclusiveWinAttributeBits(..); WGLGLCapabilities: Add PFD2String(..)
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLCapabilities.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java44
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java47
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/Capabilities.java11
4 files changed, 92 insertions, 18 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
index 9b004a0af..09db70f64 100644
--- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
@@ -493,8 +493,8 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
super.toString(sink, false);
- 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);
+ sink.append(", accum-rgba ").append(accumRedBits).append(ESEP).append(accumGreenBits).append(ESEP).append(accumBlueBits).append(ESEP).append(accumAlphaBits);
+ sink.append(", dp/st/ms ").append(depthBits).append(ESEP).append(stencilBits).append(ESEP).append(samples);
if(samples>0) {
sink.append(", sample-ext ").append(sampleExtension);
}
@@ -525,7 +525,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
ns = true;
}
if(isPBuffer()) {
- if(ns) { sink.append(", "); }
+ if(ns) { sink.append(CSEP); }
sink.append("pbuffer [r2t ").append(pbufferRenderToTexture?1:0)
.append(", r2tr ").append(pbufferRenderToTextureRectangle?1:0)
.append(", float ").append(pbufferFloatingPointBuffers?1:0)
@@ -533,7 +533,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
ns = true;
}
if(isBitmap()) {
- if(ns) { sink.append(", "); }
+ if(ns) { sink.append(CSEP); }
sink.append("bitmap");
ns = true;
}
diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
index 31e52b86c..d69b02bb9 100644
--- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
+++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
@@ -101,17 +101,16 @@ public class GLGraphicsConfigurationUtil {
* @return bitmask representing the input boolean in exclusive or logic, ie only one bit will be set.
*/
public static final int getExclusiveWinAttributeBits(boolean isOnscreen, boolean isFBO, boolean isPBuffer, boolean isBitmap) {
- int winattrbits = 0;
+ final int winattrbits;
if(isOnscreen) {
- winattrbits |= WINDOW_BIT;
+ winattrbits = WINDOW_BIT;
} else if(isFBO) {
- winattrbits |= FBO_BIT;
+ winattrbits = FBO_BIT;
} else if(isPBuffer ){
- winattrbits |= PBUFFER_BIT;
+ winattrbits = PBUFFER_BIT;
} else if(isBitmap) {
- winattrbits |= BITMAP_BIT;
- }
- if(0 == winattrbits) {
+ winattrbits = BITMAP_BIT;
+ } else {
throw new InternalError("Empty bitmask");
}
return winattrbits;
@@ -287,4 +286,35 @@ public class GLGraphicsConfigurationUtil {
}
return capsRequested;
}
+
+ public static GLCapabilitiesImmutable clipRGBAGLCapabilities(GLCapabilitiesImmutable caps, boolean allowRGB555)
+ {
+ final int iR = caps.getRedBits();
+ final int iG = caps.getGreenBits();
+ final int iB = caps.getBlueBits();
+ final int iA = caps.getAlphaBits();
+ final int oR = clipColor(iR, allowRGB555);
+ final int oG = clipColor(iG, allowRGB555);
+ final int oB = clipColor(iB, allowRGB555);
+ final int oA = 0 < iA ? oR : 0 ; // align alpha to red if requested
+ if( iR != oR || iG != oG || iB != oB || iA != oA ) {
+ final GLCapabilities caps2 = (GLCapabilities) caps.cloneMutable();
+ caps2.setRedBits(oR);
+ caps2.setGreenBits(oG);
+ caps2.setBlueBits(oB);
+ caps2.setAlphaBits(oA);
+ return caps2;
+ }
+ return caps;
+ }
+
+ public static int clipColor(final int compIn, final boolean allowRGB555) {
+ final int compOut;
+ if( 5 < compIn || !allowRGB555 ) {
+ compOut = 8;
+ } else {
+ compOut = 5;
+ }
+ return compOut;
+ }
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
index 99064b123..10a4b56d5 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
@@ -32,7 +32,9 @@ import java.nio.IntBuffer;
import jogamp.nativewindow.windows.GDI;
import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR;
+import jogamp.opengl.GLGraphicsConfigurationUtil;
+import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.NativeWindowException;
import javax.media.opengl.GL;
import javax.media.opengl.GLCapabilities;
@@ -65,10 +67,11 @@ public class WGLGLCapabilities extends GLCapabilities {
setAccumAlphaBits(pfd.getCAccumAlphaBits());
setDepthBits(pfd.getCDepthBits());
setStencilBits(pfd.getCStencilBits());
- setDoubleBuffered((pfd.getDwFlags() & GDI.PFD_DOUBLEBUFFER) != 0);
- setStereo((pfd.getDwFlags() & GDI.PFD_STEREO) != 0);
- setHardwareAccelerated((pfd.getDwFlags() & GDI.PFD_GENERIC_FORMAT) == 0
- || (pfd.getDwFlags() & GDI.PFD_GENERIC_ACCELERATED) != 0);
+ final int dwFlags = pfd.getDwFlags();
+ setDoubleBuffered((dwFlags & GDI.PFD_DOUBLEBUFFER) != 0);
+ setStereo((dwFlags & GDI.PFD_STEREO) != 0);
+ setHardwareAccelerated((dwFlags & GDI.PFD_GENERIC_FORMAT) == 0
+ || (dwFlags & GDI.PFD_GENERIC_ACCELERATED) != 0);
// n/a with non ARB/GDI method:
// multisample
// opaque
@@ -76,6 +79,42 @@ public class WGLGLCapabilities extends GLCapabilities {
return true;
}
+
+ public static final String PFD2String(PIXELFORMATDESCRIPTOR pfd, int pfdID) {
+ final int dwFlags = pfd.getDwFlags();
+ StringBuffer sb = new StringBuffer();
+ boolean sep = false;
+
+ if( 0 != (GDI.PFD_DRAW_TO_WINDOW & dwFlags ) ) {
+ sep = true;
+ sb.append("window");
+ }
+ if( 0 != (GDI.PFD_DRAW_TO_BITMAP & dwFlags ) ) {
+ if(sep) { sb.append(CSEP); } sep=true;
+ sb.append("bitmap");
+ }
+ if( 0 != (GDI.PFD_SUPPORT_OPENGL & dwFlags ) ) {
+ if(sep) { sb.append(CSEP); } sep=true;
+ sb.append("opengl");
+ }
+ if( 0 != (GDI.PFD_DOUBLEBUFFER & dwFlags ) ) {
+ if(sep) { sb.append(CSEP); } sep=true;
+ sb.append("dblbuf");
+ }
+ if( 0 != (GDI.PFD_STEREO & dwFlags ) ) {
+ if(sep) { sb.append(CSEP); } sep=true;
+ sb.append("stereo");
+ }
+ if( 0 == (GDI.PFD_GENERIC_FORMAT & dwFlags ) || 0 == (GDI.PFD_GENERIC_ACCELERATED & dwFlags ) ) {
+ if(sep) { sb.append(CSEP); } sep=true;
+ sb.append("hw-accel");
+ }
+ return "PFD[id = "+pfdID+" (0x"+Integer.toHexString(pfdID)+
+ "), colorBits "+pfd.getCColorBits()+", rgba "+pfd.getCRedBits()+ESEP+pfd.getCGreenBits()+ESEP+pfd.getCBlueBits()+ESEP+pfd.getCAlphaBits()+
+ ", accum-rgba "+pfd.getCAccumRedBits()+ESEP+pfd.getCAccumGreenBits()+ESEP+pfd.getCAccumBlueBits()+ESEP+pfd.getCAccumAlphaBits()+
+ ", dp/st/ms: "+pfd.getCDepthBits()+ESEP+pfd.getCStencilBits()+ESEP+"0"+
+ ", flags: "+sb.toString();
+ }
public boolean setValuesByARB(final IntBuffer iattribs, final int niattribs, final IntBuffer iresults) {
arb_pixelformat = 1;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
index d35f92fea..8e83eda33 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
@@ -388,18 +388,23 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable {
return sink;
}
+ /** Element separator */
+ protected static final String ESEP = "/";
+ /** Component separator */
+ protected static final String CSEP = ", ";
+
protected StringBuilder toString(StringBuilder sink, boolean withOnOffScreen) {
if(null == sink) {
sink = new StringBuilder();
}
- sink.append("rgba 0x").append(toHexString(redBits)).append("/").append(toHexString(greenBits)).append("/").append(toHexString(blueBits)).append("/").append(toHexString(alphaBits));
+ sink.append("rgba ").append(redBits).append(ESEP).append(greenBits).append(ESEP).append(blueBits).append(ESEP).append(alphaBits);
if(backgroundOpaque) {
sink.append(", opaque");
} else {
- sink.append(", trans-rgba 0x").append(toHexString(transparentValueRed)).append("/").append(toHexString(transparentValueGreen)).append("/").append(toHexString(transparentValueBlue)).append("/").append(toHexString(transparentValueAlpha));
+ sink.append(", trans-rgba 0x").append(toHexString(transparentValueRed)).append(ESEP).append(toHexString(transparentValueGreen)).append(ESEP).append(toHexString(transparentValueBlue)).append(ESEP).append(toHexString(transparentValueAlpha));
}
if(withOnOffScreen) {
- sink.append(", ");
+ sink.append(CSEP);
onoffScreenToString(sink);
}
return sink;