diff options
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java | 121 |
1 files changed, 81 insertions, 40 deletions
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java index 5ff63d93b..feacdb951 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java @@ -28,6 +28,8 @@ package jogamp.opengl.windows.wgl; +import java.nio.IntBuffer; + import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR; @@ -52,6 +54,7 @@ public class WGLGLCapabilities extends GLCapabilities { public boolean setValuesByGDI() { arb_pixelformat = -1; + // ALPHA shall be set at last - due to it's auto setting by !opaque / samples setRedBits(pfd.getCRedBits()); setGreenBits(pfd.getCGreenBits()); setBlueBits(pfd.getCBlueBits()); @@ -62,10 +65,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 @@ -74,11 +78,49 @@ public class WGLGLCapabilities extends GLCapabilities { return true; } - public boolean setValuesByARB(final int[] iattribs, final int niattribs, final int[] iresults) { + public static final String PFD2String(PIXELFORMATDESCRIPTOR pfd, int pfdID) { + final int dwFlags = pfd.getDwFlags(); + StringBuilder sb = new StringBuilder(); + 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; + int alphaBits = 0; for (int i = 0; i < niattribs; i++) { - int attr = iattribs[i]; + final int attr = iattribs.get(i); + final int res = iresults.get(i); switch (attr) { case WGLExt.WGL_DRAW_TO_WINDOW_ARB: case WGLExt.WGL_DRAW_TO_BITMAP_ARB: @@ -86,101 +128,99 @@ public class WGLGLCapabilities extends GLCapabilities { break; case WGLExt.WGL_ACCELERATION_ARB: - setHardwareAccelerated(iresults[i] == WGLExt.WGL_FULL_ACCELERATION_ARB); + setHardwareAccelerated(res == WGLExt.WGL_FULL_ACCELERATION_ARB); break; case WGLExt.WGL_SUPPORT_OPENGL_ARB: - if (iresults[i] != GL.GL_TRUE) { + if (res != GL.GL_TRUE) { return false; } break; case WGLExt.WGL_DEPTH_BITS_ARB: - setDepthBits(iresults[i]); + setDepthBits(res); break; case WGLExt.WGL_STENCIL_BITS_ARB: - setStencilBits(iresults[i]); + setStencilBits(res); break; case WGLExt.WGL_DOUBLE_BUFFER_ARB: - setDoubleBuffered(iresults[i] == GL.GL_TRUE); + setDoubleBuffered(res == GL.GL_TRUE); break; case WGLExt.WGL_STEREO_ARB: - setStereo(iresults[i] == GL.GL_TRUE); + setStereo(res == GL.GL_TRUE); break; case WGLExt.WGL_PIXEL_TYPE_ARB: - if(iresults[i] == WGLExt.WGL_TYPE_COLORINDEX_ARB) { + if(res == WGLExt.WGL_TYPE_COLORINDEX_ARB) { return false; // color index not supported } - if (iresults[i] == WGLExt.WGL_TYPE_RGBA_FLOAT_ARB) { - setPbufferFloatingPointBuffers(true); + if (res == WGLExt.WGL_TYPE_RGBA_FLOAT_ARB) { + return false; // not supported } - + // normal RGBA FB: WGLExt.WGL_TYPE_RGBA_ARB // ignore unknown results here break; - case WGLExt.WGL_FLOAT_COMPONENTS_NV: - if (iresults[i] != 0) { - setPbufferFloatingPointBuffers(true); - } - break; - case WGLExt.WGL_RED_BITS_ARB: - setRedBits(iresults[i]); + setRedBits(res); break; case WGLExt.WGL_GREEN_BITS_ARB: - setGreenBits(iresults[i]); + setGreenBits(res); break; case WGLExt.WGL_BLUE_BITS_ARB: - setBlueBits(iresults[i]); + setBlueBits(res); break; case WGLExt.WGL_ALPHA_BITS_ARB: - setAlphaBits(iresults[i]); + // ALPHA shall be set at last - due to it's auto setting by !opaque / samples + alphaBits = res; break; case WGLExt.WGL_ACCUM_RED_BITS_ARB: - setAccumRedBits(iresults[i]); + setAccumRedBits(res); break; case WGLExt.WGL_ACCUM_GREEN_BITS_ARB: - setAccumGreenBits(iresults[i]); + setAccumGreenBits(res); break; case WGLExt.WGL_ACCUM_BLUE_BITS_ARB: - setAccumBlueBits(iresults[i]); + setAccumBlueBits(res); break; case WGLExt.WGL_ACCUM_ALPHA_BITS_ARB: - setAccumAlphaBits(iresults[i]); + setAccumAlphaBits(res); break; case WGLExt.WGL_SAMPLE_BUFFERS_ARB: - setSampleBuffers(iresults[i] != 0); + setSampleBuffers(res != 0); break; case WGLExt.WGL_SAMPLES_ARB: - setNumSamples(iresults[i]); + setNumSamples(res); break; default: - throw new GLException("Unknown pixel format attribute " + iattribs[i]); + throw new GLException("Unknown pixel format attribute " + attr); } } + setAlphaBits(alphaBits); return true; } + @Override public Object cloneMutable() { return clone(); } + @Override public Object clone() { try { return super.clone(); @@ -191,11 +231,11 @@ public class WGLGLCapabilities extends GLCapabilities { final public PIXELFORMATDESCRIPTOR getPFD() { return pfd; } final public int getPFDID() { return pfdID; } - + final public boolean isSetByARB() { return 0 < arb_pixelformat; } final public boolean isSetByGDI() { return 0 > arb_pixelformat; } final public boolean isSet() { return 0 != arb_pixelformat; } - + @Override final public int getVisualID(VIDType type) throws NativeWindowException { switch(type) { @@ -205,16 +245,17 @@ public class WGLGLCapabilities extends GLCapabilities { return getPFDID(); default: throw new NativeWindowException("Invalid type <"+type+">"); - } + } } - + + @Override public StringBuilder toString(StringBuilder sink) { if(null == sink) { sink = new StringBuilder(); } - sink.append("wgl vid 0x").append(Integer.toHexString(pfdID)).append(" "); + sink.append("wgl vid ").append(pfdID).append(" "); switch (arb_pixelformat) { - case -1: + case -1: sink.append("gdi"); break; case 0: @@ -229,4 +270,4 @@ public class WGLGLCapabilities extends GLCapabilities { sink.append(": "); return super.toString(sink); } -}
\ No newline at end of file +} |