diff options
author | Sven Gothel <[email protected]> | 2012-09-08 19:45:11 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-09-08 19:45:11 +0200 |
commit | 9036376b7806a5fc61590bf49404eb71830de92f (patch) | |
tree | e12bd10755b88b8fb5318268c1243da0b5467157 /src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java | |
parent | d22ac65d0f841e4c3698ec817d4ebbfdb7ee25a0 (diff) |
Fix window mode attribute bit FBO_BIT usage in platform dependent code (map it to native type) ; OSX Caps selection ; WGL/GDI BITMAP fix
Fix window mode attribute bit FBO_BIT usage in platform dependent code (map it to native type)
All platform dependent winAttrBit mapping: 'nativeType -> winAttrBit' and 'GLCapabilities -> winAttrBits'
shall replace FBO_BIT w/ the native type of the wrapper surface, i.e. WINDOW_BIT (X11, WGL, CGL) or PBUFFER_BIT (EGL).
This condenses to changes in
- EGLGraphicsConfiguration: EGLConfigDrawableTypeBits / GLCapabilities2AttribList
- X11GLXGraphicsConfiguration: FBCfgDrawableTypeBits, XVisualInfo2GLCapabilities / GLCapabilities2AttribList
- WindowsWGLGraphicsConfiguration: AttribList2DrawableTypeBits, PFD2DrawableTypeBits / GLCapabilities2AttribList
- OSX CGL/NS requires changes in MacOSXCGLContext, i.e. fix the surface mode of
NSPixelFormat2GLCapabilities, CGLPixelFormat2GLCapabilities results.
This change is included in the upcoming commit (class is heavily edited).
OSX chooseGraphicsConfigurationStatic: Add missing 'GLGraphicsConfigurationUtil.fixGLCapabilities(..)' call
- all platform impl. require to fix the given user caps due to the new offscreen auto selection mode
WindowsWGLGraphicsConfiguration*: ARB / GDI updateGraphicsConfiguration*()
- ARB method detects early whether it's suitable for given HDC, i.e. in case of BITMAP (it's not here)
- GDI methods detect failure while choosing PFD and doesn't care of DOUBLEBUFFER in case of bitmap (fixes BITMAP usage)
Capabilities/GLCapabilities:
- Fix missing double-buffer check in GLCapabilities.equals()
- add 'copyFrom(..)' method copy all data from give caps
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index 135101ff2..8ee98072f 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -46,7 +46,6 @@ import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -129,12 +128,28 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple return configs.get(0); } - static int EGLConfigDrawableTypeBits(final EGLGraphicsDevice device, final GLProfile glp, final long config) { + public static boolean isEGLConfigValid(long display, long config) { + if(0 == config) { + return false; + } + final IntBuffer val = Buffers.newDirectIntBuffer(1); + + // get the configID + if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_CONFIG_ID, val)) { + final int eglErr = EGL.eglGetError(); + if(DEBUG) { + System.err.println("Info: Couldn't retrieve EGL ConfigID for config "+toHexString(config)+", error "+toHexString(eglErr)); + } + return false; + } + return true; + } + + static int EGLConfigDrawableTypeBits(final EGLGraphicsDevice device, final long config) { int val = 0; - final long display = device.getHandle(); int[] stype = new int[1]; - if(! EGL.eglGetConfigAttrib(display, config, EGL.EGL_SURFACE_TYPE, stype, 0)) { + if(! EGL.eglGetConfigAttrib(device.getHandle(), config, EGL.EGL_SURFACE_TYPE, stype, 0)) { throw new GLException("Could not determine EGL_SURFACE_TYPE"); } @@ -145,12 +160,9 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple val |= GLGraphicsConfigurationUtil.BITMAP_BIT; } if ( 0 != ( stype[0] & EGL.EGL_PBUFFER_BIT ) ) { - val |= GLGraphicsConfigurationUtil.PBUFFER_BIT; - } - if ( GLContext.isFBOAvailable(device, glp) ) { - val |= GLGraphicsConfigurationUtil.FBO_BIT; + val |= GLGraphicsConfigurationUtil.PBUFFER_BIT | + GLGraphicsConfigurationUtil.FBO_BIT; } - return val; } @@ -269,8 +281,8 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple // Since the passed GLProfile may be null, // we use EGL_RENDERABLE_TYPE derived profile as created in the EGLGLCapabilities constructor. - final int allDrawableTypeBits = EGLConfigDrawableTypeBits(device, caps.getGLProfile(), config); - final int drawableTypeBits = winattrmask & allDrawableTypeBits; + final int availableTypeBits = EGLConfigDrawableTypeBits(device, config); + final int drawableTypeBits = winattrmask & availableTypeBits; if( 0 == drawableTypeBits ) { return null; @@ -284,7 +296,19 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple int idx=0; attrs[idx++] = EGL.EGL_SURFACE_TYPE; - attrs[idx++] = caps.isOnscreen() ? ( EGL.EGL_WINDOW_BIT ) : ( caps.isPBuffer() ? EGL.EGL_PBUFFER_BIT : EGL.EGL_PIXMAP_BIT ) ; + final int surfaceType; + if( caps.isOnscreen() ) { + surfaceType = EGL.EGL_WINDOW_BIT; + } else if( caps.isFBO() ) { + surfaceType = EGL.EGL_PBUFFER_BIT; // native replacement! + } else if( caps.isPBuffer() ) { + surfaceType = EGL.EGL_PBUFFER_BIT; + } else if( caps.isBitmap() ) { + surfaceType = EGL.EGL_PIXMAP_BIT; + } else { + throw new GLException("no surface type set in caps: "+caps); + } + attrs[idx++] = surfaceType; attrs[idx++] = EGL.EGL_RED_SIZE; attrs[idx++] = caps.getRedBits(); |