diff options
author | Sven Gothel <[email protected]> | 2009-10-04 14:50:39 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-10-04 14:50:39 -0700 |
commit | dae3705d5b8bee0a2ae0a809632f2c6d607f6c30 (patch) | |
tree | 0a224f5f8e22662a6e4438c954be4b459ead99e6 /src/jogl/classes/com/sun/opengl/impl | |
parent | 012460d1fdef767afdc454fb09ba50f056d26e20 (diff) |
FIX: EGL Config: on-/offscreen and pbuffer; Added EGL-PBuffer setSurfaceHandle
Diffstat (limited to 'src/jogl/classes/com/sun/opengl/impl')
4 files changed, 50 insertions, 36 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java index 11ed21f6c..f1cbd6e35 100755 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java @@ -143,7 +143,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { // EGLSurface is ours .. ownEGLSurface=true; - long nDisplay; + long nDisplay=0; if( NativeWindowFactory.TYPE_WINDOWS.equals(NativeWindowFactory.getNativeWindowType(false)) ) { nDisplay = component.getSurfaceHandle(); // don't even ask .. } else { @@ -225,10 +225,12 @@ public abstract class EGLDrawable extends GLDrawableImpl { } public String toString() { - return "EGLDrawable[ realized "+getRealized()+ - ", window "+getNativeWindow()+ - ", egl surface " + eglSurface + - ", "+eglConfig+ - ", factory "+getFactory()+"]"; + return getClass().getName()+"[realized "+getRealized()+ + ",\n\tfactory "+getFactory()+ + ",\n\twindow "+getNativeWindow()+ + ",\n\teglSurface 0x"+Long.toHexString(eglSurface)+ + ",\n\teglConfig "+eglConfig+ + ",\n\trequested "+getRequestedGLCapabilities()+ + ",\n\tchosen "+getChosenGLCapabilities()+"]"; } } diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java index e98d97659..bd439eacb 100644 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java @@ -73,7 +73,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple } GLProfile glp = capsRequested.getGLProfile(); _EGLConfig _cfg = EGLConfigId2EGLConfig(glp, dpy, cfgID); - GLCapabilities caps = EGLConfig2Capabilities(glp, dpy, _cfg); + GLCapabilities caps = EGLConfig2Capabilities(glp, dpy, _cfg, false, capsRequested.isOnscreen(), capsRequested.isPBuffer()); return new EGLGraphicsConfiguration(absScreen, caps, capsRequested, new DefaultGLCapabilitiesChooser(), _cfg, cfgID); } @@ -116,7 +116,23 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple return configs[0]; } - public static GLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, _EGLConfig _config) { + public static boolean EGLConfigDrawableTypeVerify(int val, boolean onscreen, boolean usePBuffer) { + boolean res; + + if ( onscreen ) { + res = ( 0 != (val & EGL.EGL_WINDOW_BIT) ) ; + } else { + res = ( 0 != (val & EGL.EGL_PIXMAP_BIT) ) || usePBuffer ; + } + if ( usePBuffer ) { + res = res && ( 0 != (val & EGL.EGL_PBUFFER_BIT) ) ; + } + + return res; + } + + public static GLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, _EGLConfig _config, + boolean relaxed, boolean onscreen, boolean usePBuffer) { GLCapabilities caps = new GLCapabilities(glp); int[] val = new int[1]; @@ -162,24 +178,16 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple } */ } if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_SURFACE_TYPE, val, 0)) { - switch(val[0]) { - case EGL.EGL_WINDOW_BIT: - caps.setDoubleBuffered(true); - caps.setOnscreen(true); - caps.setPBuffer(false); - break; - case EGL.EGL_PBUFFER_BIT: - caps.setDoubleBuffered(false); - caps.setOnscreen(false); - caps.setPBuffer(true); - break; - case EGL.EGL_PIXMAP_BIT: - caps.setDoubleBuffered(false); - caps.setOnscreen(false); - caps.setPBuffer(false); - break; - default: - throw new GLException("Invalid EGL_SURFACE_TYPE 0x"+Integer.toHexString(val[0])); + if(EGLConfigDrawableTypeVerify(val[0], onscreen, usePBuffer)) { + caps.setDoubleBuffered(onscreen); + caps.setOnscreen(onscreen); + caps.setPBuffer(usePBuffer); + } else if(relaxed) { + caps.setDoubleBuffered( 0 != (val[0] & EGL.EGL_WINDOW_BIT) ); + caps.setOnscreen( 0 != (val[0] & EGL.EGL_WINDOW_BIT) ); + caps.setPBuffer ( 0 != (val[0] & EGL.EGL_PBUFFER_BIT) ); + } else { + return null; } } else { throw new GLException("Could not determine EGL_SURFACE_TYPE"); diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java index 4c6ff314d..473490afc 100644 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java @@ -124,7 +124,8 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor if (numConfigs[0] == 0) { throw new GLException("Graphics configuration fetch (eglGetConfigs) - no EGLConfig found"); } - GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0]); + GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0], + caps2.isOnscreen(), caps2.isPBuffer()); if(DEBUG) { System.err.println("EGL Get Configs: "+numConfigs[0]+", Caps "+caps.length); printCaps("eglGetConfigs", caps, System.err); @@ -214,7 +215,8 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor } if (numConfigs[0] > 0) { if(DEBUG) { - GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0]); + GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0], + capsChosen0.isOnscreen(), capsChosen0.isPBuffer()); System.err.println("EGL Choose Configs: "+numConfigs[0]+", Caps "+caps.length); printCaps("eglChooseConfig", caps, System.err); } @@ -227,7 +229,8 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor } val[0]=0; } - GLCapabilities capsChosen1 = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0]); + GLCapabilities capsChosen1 = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0], + false, capsChosen0.isOnscreen(), capsChosen0.isPBuffer()); if(DEBUG) { System.err.println("eglChooseConfig found: eglDisplay 0x"+Long.toHexString(eglDisplay)+ ", eglConfig ID 0x"+Integer.toHexString(val[0])+ @@ -244,10 +247,12 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor return null; } - protected static GLCapabilities[] eglConfigs2GLCaps(GLProfile glp, long eglDisplay, _EGLConfig[] configs, int num) { + protected static GLCapabilities[] eglConfigs2GLCaps(GLProfile glp, long eglDisplay, _EGLConfig[] configs, int num, + boolean onscreen, boolean usePBuffer) { GLCapabilities[] caps = new GLCapabilities[num]; for(int i=0; i<num; i++) { - caps[i] = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[i]); + caps[i] = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[i], + true, onscreen, usePBuffer); } return caps; } diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java index 09dbbeee6..b1ae3550a 100644 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java @@ -46,7 +46,6 @@ import com.sun.opengl.impl.*; import com.sun.nativewindow.impl.NullWindow; public class EGLPbufferDrawable extends EGLDrawable { - private int width, height; private int texFormat; protected static final boolean useTexture = false; // No yet .. @@ -63,8 +62,6 @@ public class EGLPbufferDrawable extends EGLDrawable { // get choosen ones .. caps = (GLCapabilities) getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); - this.width=width; - this.height=height; if(useTexture) { this.texFormat = caps.getAlphaBits() > 0 ? EGL.EGL_TEXTURE_RGBA : EGL.EGL_TEXTURE_RGB ; } else { @@ -110,13 +107,15 @@ public class EGLPbufferDrawable extends EGLDrawable { } protected long createSurface(long eglDpy, _EGLConfig eglNativeCfg, long surfaceHandle) { - int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(width, height, texFormat); + NullWindow nw = (NullWindow) getNativeWindow(); + int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(nw.getWidth(), nw.getHeight(), texFormat); long surf = EGL.eglCreatePbufferSurface(eglDpy, eglNativeCfg, attrs, 0); if (EGL.EGL_NO_SURFACE==surf) { - throw new GLException("Creation of window surface (eglCreatePbufferSurface) failed, dim "+width+"x"+height+", error 0x"+Integer.toHexString(EGL.eglGetError())); + throw new GLException("Creation of window surface (eglCreatePbufferSurface) failed, dim "+nw.getWidth()+"x"+nw.getHeight()+", error 0x"+Integer.toHexString(EGL.eglGetError())); } else if(DEBUG) { System.err.println("setSurface result: eglSurface 0x"+Long.toHexString(surf)); } + nw.setSurfaceHandle(surf); return surf; } |