aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp
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/jogl/classes/jogamp
parent1af639340bb119e4839170c6e5e3258012d99136 (diff)
*Capabilities: Cleanup string ctor; GLGraphicsConfigurationUtil: Clean getExclusiveWinAttributeBits(..); WGLGLCapabilities: Add PFD2String(..)
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java44
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java47
2 files changed, 80 insertions, 11 deletions
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;