diff options
author | Sven Gothel <[email protected]> | 2009-10-05 02:54:59 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-10-05 02:54:59 -0700 |
commit | 76bf2e5a7f23def0a3bf2b688791b593ecb283ab (patch) | |
tree | 84b7b2a25cc38450dc83a78d1f1ed165195a599e /src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java | |
parent | 59257476777104ff3f117d87a8205161cb800abf (diff) |
GLDrawableFactory Cleanup (-> On- Offscreen and PBuffer)
- Base all PBuffer/Offscreen GLDrawable creators on
a prev. created 'NativeWindow + SurfaceChangeable' instance.
Simplifies implementation path.
This also removes the almost cyclic referencing of
GLWindow -> OffscreenWindow
GLWindow -> Drawable -> NullWindow -> OffscreenWindow
Now it is just
GLWindow -> OffscreenWindow
GLWindow -> Drawable -> OffscreenWindow
- createGLDrawable() shall be used for all types now,
especially if you want to pass the offscreen NativeWindow
and benefit from the surfaceChangedListener etc ..
- Add public createOffscreenDrawable(..)
- EGLDrawable:
- Query surface only if not 0
- [re]create surface only if needed,
using 'ownEGL*' flag for destruction only.
Diffstat (limited to 'src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java')
-rwxr-xr-x | src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java | 51 |
1 files changed, 21 insertions, 30 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 6901be23e..f109c9497 100755 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java @@ -44,8 +44,8 @@ import javax.media.nativewindow.egl.*; import javax.media.opengl.*; public abstract class EGLDrawable extends GLDrawableImpl { - protected boolean ownEGLDisplay = false; - protected boolean ownEGLSurface = false; + protected boolean ownEGLDisplay = false; // for destruction + protected boolean ownEGLSurface = false; // for destruction private EGLGraphicsConfiguration eglConfig; protected long eglDisplay; protected long eglSurface; @@ -78,24 +78,22 @@ public abstract class EGLDrawable extends GLDrawableImpl { protected abstract long createSurface(long eglDpy, _EGLConfig eglNativeCfg, long surfaceHandle); private void recreateSurface() { - if(ownEGLSurface) { - // create a new EGLSurface .. - if(EGL.EGL_NO_SURFACE!=eglSurface) { - EGL.eglDestroySurface(eglDisplay, eglSurface); - } + // create a new EGLSurface .. + if(EGL.EGL_NO_SURFACE!=eglSurface) { + EGL.eglDestroySurface(eglDisplay, eglSurface); + } - if(DEBUG) { - System.err.println("createSurface using eglDisplay 0x"+Long.toHexString(eglDisplay)+", "+eglConfig); - } + if(DEBUG) { + System.err.println("createSurface using eglDisplay 0x"+Long.toHexString(eglDisplay)+", "+eglConfig); + } - eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), component.getSurfaceHandle()); - if (EGL.EGL_NO_SURFACE==eglSurface) { - throw new GLException("Creation of window surface failed: "+eglConfig+", error 0x"+Integer.toHexString(EGL.eglGetError())); - } + eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), component.getSurfaceHandle()); + if (EGL.EGL_NO_SURFACE==eglSurface) { + throw new GLException("Creation of window surface failed: "+eglConfig+", error 0x"+Integer.toHexString(EGL.eglGetError())); + } - if(DEBUG) { - System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getSurfaceHandle())+" -> 0x"+Long.toHexString(eglSurface)); - } + if(DEBUG) { + System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getSurfaceHandle())+" -> 0x"+Long.toHexString(eglSurface)); } } @@ -121,8 +119,10 @@ public abstract class EGLDrawable extends GLDrawableImpl { if (null == eglConfig) { throw new GLException("Null EGLGraphicsConfiguration from "+aConfig); } + int[] tmp = new int[1]; - if (EGL.eglQuerySurface(eglDisplay, component.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0)) { + if ( 0 != component.getSurfaceHandle() && + EGL.eglQuerySurface(eglDisplay, component.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0) ) { // component holds static EGLSurface eglSurface = component.getSurfaceHandle(); if(DEBUG) { @@ -133,6 +133,8 @@ public abstract class EGLDrawable extends GLDrawableImpl { ownEGLSurface=true; eglConfig.updateGraphicsConfiguration(); + + recreateSurface(); } } else { throw new GLException("EGLGraphicsDevice hold by non EGLGraphicsConfiguration: "+aConfig); @@ -174,19 +176,8 @@ public abstract class EGLDrawable extends GLDrawableImpl { } else if(DEBUG) { System.err.println("Chosen eglConfig: "+eglConfig); } - /** - eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), component.getSurfaceHandle()); - while ( EGL.EGL_NO_SURFACE == eglSurface ) { - - blacklist EGLConfig entry - - retry .. - if ( no more EGLConfigs available ) { - break .. or .. exception - } - eglConfig.updateGraphicsConfiguration(); - eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), component.getSurfaceHandle()); - } */ + recreateSurface(); } - recreateSurface(); } finally { unlockSurface(); } |