diff options
author | sg215889 <[email protected]> | 2009-07-29 09:49:33 -0700 |
---|---|---|
committer | sg215889 <[email protected]> | 2009-07-29 09:49:33 -0700 |
commit | 8883fa885e68cd21e8b8cd3343db0580913aebdf (patch) | |
tree | 3f2b97b0a5c32088290ad9702f15494b8ecd71dd /src | |
parent | fdd78c172dfb76ba868359b359e344eaaf08d6f8 (diff) |
Fix: doxygen-all-pub.cfg; Add NativeWindow: surfaceSwap() and surfaceUpdated(); BroadcomEGL: Use custom surfaceSwap(); GLDrawableImpl's: Utilize NativeWindow's surfaceSwap() and surfaceUpdated(); Fix common enum of GL2ES1 and GL2GL3, merge them in GL
Diffstat (limited to 'src')
19 files changed, 135 insertions, 64 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java index c381f68f5..15ccc0f96 100644 --- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java +++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java @@ -71,8 +71,17 @@ public abstract class GLDrawableImpl implements GLDrawable { } public void swapBuffers() throws GLException { + GLCapabilities caps = (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); + if (caps.getDoubleBuffered()) { + if(!component.surfaceSwap()) { + swapBuffersImpl(); + } + } + component.surfaceUpdated(); } + protected abstract void swapBuffersImpl(); + public static String toHexString(long hex) { return GLContextImpl.toHexString(hex); } diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java index c7c2bcab2..36117f059 100644 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java @@ -64,7 +64,7 @@ public class EGLOnscreenDrawable extends EGLDrawable { return surf; } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { boolean didLock = false; try { if ( !isSurfaceLocked() ) { 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 bcf3294c1..a792762a4 100644 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java @@ -118,5 +118,6 @@ public class EGLPbufferDrawable extends EGLDrawable { return new EGLPbufferContext(this, shareWith); } + protected void swapBuffersImpl() { } } diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java index f87cc150b..4a3e0a8eb 100644 --- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java +++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java @@ -102,7 +102,7 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext { } } - public void swapBuffers() throws GLException { + protected void swapBuffers() { if (!CGL.flushBuffer(nsContext)) { throw new GLException("Error swapping buffers"); } diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java index 98687b5ef..56951ae10 100644 --- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java @@ -78,7 +78,7 @@ public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable { return component.getHeight(); } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { for (Iterator iter = createdContexts.iterator(); iter.hasNext(); ) { WeakReference ref = (WeakReference) iter.next(); MacOSXOnscreenCGLContext ctx = (MacOSXOnscreenCGLContext) ref.get(); diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 54101331d..0d031ffff 100644 --- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -87,7 +87,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { return pBuffer; } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { // FIXME: do we need to do anything if the pbuffer is double-buffered? } diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java index ecd4e1685..71d82e784 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java @@ -127,7 +127,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { } } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { } } diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java index 6a03406f9..f54e8f1a0 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -107,7 +107,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { return floatMode; } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { } private void createPbuffer(long parentHdc, WGLExt wglExt) { diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java index 3017d258b..01e259665 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java @@ -82,44 +82,41 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl { } } - public void swapBuffers() throws GLException { - GLCapabilities caps = (GLCapabilities)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); - if (caps.getDoubleBuffered()) { - boolean didLock = false; + protected void swapBuffersImpl() { + boolean didLock = false; - try { - if ( !isSurfaceLocked() ) { - // Usually the surface shall be locked within [makeCurrent .. swap .. release] - if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { - return; - } - didLock = true; + try { + if ( !isSurfaceLocked() ) { + // Usually the surface shall be locked within [makeCurrent .. swap .. release] + if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { + return; } + didLock = true; + } - long startTime = 0; - if (PROFILING) { - startTime = System.currentTimeMillis(); - } + long startTime = 0; + if (PROFILING) { + startTime = System.currentTimeMillis(); + } - if (!WGL.SwapBuffers(getNativeWindow().getSurfaceHandle()) && (WGL.GetLastError() != 0)) { - throw new GLException("Error swapping buffers"); - } + if (!WGL.SwapBuffers(getNativeWindow().getSurfaceHandle()) && (WGL.GetLastError() != 0)) { + throw new GLException("Error swapping buffers"); + } - if (PROFILING) { - long endTime = System.currentTimeMillis(); - profilingSwapBuffersTime += (endTime - startTime); - int ticks = PROFILING_TICKS; - if (++profilingSwapBuffersTicks == ticks) { - System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + ticks + " calls (" + - ((float) profilingSwapBuffersTime / (float) ticks) + " ms/call)"); - profilingSwapBuffersTime = 0; - profilingSwapBuffersTicks = 0; - } - } - } finally { - if (didLock) { - unlockSurface(); - } + if (PROFILING) { + long endTime = System.currentTimeMillis(); + profilingSwapBuffersTime += (endTime - startTime); + int ticks = PROFILING_TICKS; + if (++profilingSwapBuffersTicks == ticks) { + System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + ticks + " calls (" + + ((float) profilingSwapBuffersTime / (float) ticks) + " ms/call)"); + profilingSwapBuffersTime = 0; + profilingSwapBuffersTicks = 0; + } + } + } finally { + if (didLock) { + unlockSurface(); } } } diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java index 738714ecb..1abc36c58 100644 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java @@ -76,26 +76,23 @@ public abstract class X11GLXDrawable extends GLDrawableImpl { } } - public void swapBuffers() throws GLException { - GLCapabilities caps = (GLCapabilities)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); - if (caps.getDoubleBuffered()) { - boolean didLock = false; - try { - if ( !isSurfaceLocked() ) { - // Usually the surface shall be locked within [makeCurrent .. swap .. release] - if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { - return; - } - didLock=true; + protected void swapBuffersImpl() { + boolean didLock = false; + try { + if ( !isSurfaceLocked() ) { + // Usually the surface shall be locked within [makeCurrent .. swap .. release] + if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { + return; } + didLock=true; + } - GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle()); + GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle()); - } finally { - if(didLock) { - unlockSurface(); - } - } + } finally { + if(didLock) { + unlockSurface(); + } } } diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java index 51938df5f..768f6b8e8 100644 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java @@ -133,6 +133,6 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { getFactoryImpl().unlockToolkit(); } } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { } } diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java index eecd92a53..bee24fa47 100644 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java @@ -148,6 +148,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { return GLPbuffer.NV_FLOAT; } - public void swapBuffers() throws GLException { + protected void swapBuffersImpl() { } } diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java index c7d2acec0..48a04a3c9 100644 --- a/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java @@ -88,6 +88,12 @@ public class NullWindow implements NativeWindow { return lockedStack; } + public boolean surfaceSwap() { + return false; + } + + public void surfaceUpdated() { } + public long getDisplayHandle() { return displayHandle; } diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java index a4a529c54..5ad2804c1 100644 --- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java @@ -115,6 +115,12 @@ public abstract class JAWTWindow implements NativeWindow { return lockedStack; } + public boolean surfaceSwap() { + return false; + } + + public void surfaceUpdated() { } + public long getDisplayHandle() { return config.getScreen().getDevice().getHandle(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java index 2a9782c12..6a588538d 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java @@ -111,6 +111,24 @@ public interface NativeWindow { */ public Exception getLockedStack(); + /** + * Provide a mechanism to utilize custom (pre-) swap surface + * code. This method is called before the render toolkit (e.g. JOGL) + * swaps the buffer/surface. The implementation may itself apply the swapping, + * in which case true shall be returned. + * + * @return true if this method completed swapping the surface, + * otherwise false, in which case eg the GLDrawable + * implementation has to swap the code. + */ + public boolean surfaceSwap(); + + /** + * Method invoked after the render toolkit (e.g. JOGL) + * swapped/changed the buffer/surface. + */ + public void surfaceUpdated(); + /** * render all native window information invalid, * as if the native window was destroyed diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java index a1168d12d..e2903bd62 100755 --- a/src/newt/classes/com/sun/javafx/newt/Window.java +++ b/src/newt/classes/com/sun/javafx/newt/Window.java @@ -269,6 +269,12 @@ public abstract class Window implements NativeWindow y=0; } + public boolean surfaceSwap() { + return false; + } + + public void surfaceUpdated() {} + protected void clearEventMask() { eventMask=0; } diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java index 8ecfe6216..7a7ff0859 100644 --- a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java @@ -654,6 +654,19 @@ public class GLWindow extends Window implements GLAutoDrawable { return null; } + public boolean surfaceSwap() { + if(null!=drawable) return drawable.getNativeWindow().surfaceSwap(); + return super.surfaceSwap(); + } + + public void surfaceUpdated() { + if(null!=drawable) { + drawable.getNativeWindow().surfaceUpdated(); + } else { + super.surfaceUpdated(); + } + } + public long getWindowHandle() { if(null!=drawable) return drawable.getNativeWindow().getWindowHandle(); return super.getWindowHandle(); diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java index 10e70baa0..ddee07c49 100755 --- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java +++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java @@ -85,10 +85,10 @@ public class BCEGLWindow extends Window { void setSizeImpl(int width, int height) { if(0!=windowHandle) { // n/a in BroadcomEGL - System.err.println("setSize n/a in BroadcomEGL with realized window"); + System.err.println("BCEGLWindow.setSizeImpl n/a in BroadcomEGL with realized window"); } else { if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("BCEGLWindow.setSize() "+this.width+"x"+this.height+" -> "+width+"x"+height); + Exception e = new Exception("BCEGLWindow.setSizeImpl() "+this.width+"x"+this.height+" -> "+width+"x"+height); e.printStackTrace(); } this.width = width; @@ -107,6 +107,14 @@ public class BCEGLWindow extends Window { return false; } + public boolean surfaceSwap() { + if ( 0!=windowHandle ) { + SwapWindow(getDisplayHandle(), windowHandle); + return true; + } + return false; + } + //---------------------------------------------------------------------- // Internals only // @@ -114,6 +122,7 @@ public class BCEGLWindow extends Window { protected static native boolean initIDs(); private native long CreateWindow(long eglDisplayHandle, boolean chromaKey, int width, int height); private native void CloseWindow(long eglDisplayHandle, long eglWindowHandle); + private native void SwapWindow(long eglDisplayHandle, long eglWindowHandle); private long realizeWindow(boolean chromaKey, int width, int height) { diff --git a/src/newt/native/BroadcomEGL.c b/src/newt/native/BroadcomEGL.c index 716f7d9ee..764fa9b16 100755 --- a/src/newt/native/BroadcomEGL.c +++ b/src/newt/native/BroadcomEGL.c @@ -51,10 +51,10 @@ typedef unsigned int GLuint; -EGLDisplay EGLUtil_CreateDisplay( GLuint uiWidth, GLuint uiHeight ); +EGLDisplay EGLUtil_CreateDisplayByNative( GLuint uiWidth, GLuint uiHeight ); void EGLUtil_DestroyDisplay( EGLDisplay eglDisplay ); -EGLSurface EGLUtil_CreateWindow( EGLDisplay eglDisplay, /* bool */ GLuint bChromakey, GLuint *puiWidth, GLuint *puiHeight ); +EGLSurface EGLUtil_CreateWindowByNative( EGLDisplay eglDisplay, /* bool */ GLuint bChromakey, GLuint *puiWidth, GLuint *puiHeight ); void EGLUtil_DestroyWindow( EGLDisplay eglDisplay, EGLSurface eglSurface ); void EGLUtil_SwapWindow( EGLDisplay eglDisplay, EGLSurface eglSurface ); @@ -132,7 +132,6 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_Cre } window = EGLUtil_CreateWindowByNative( dpy, chromaKey, &uiWidth, &uiHeight ); - // EGLUtil_DestroyWindow( dpy, window ); if(NULL==window) { fprintf(stderr, "[RealizeWindow.Create] failed: NULL\n"); @@ -161,10 +160,20 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_Cre JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_CloseWindow (JNIEnv *env, jobject obj, jlong display, jlong window) { - EGLDisplay dpy = (EGLDisplay)(intptr_t)display; + EGLDisplay dpy = (EGLDisplay) (intptr_t) display; EGLSurface surf = (EGLSurface) (intptr_t) window; EGLUtil_DestroyWindow(dpy, surf); DBG_PRINT( "[CloseWindow]\n"); } +JNIEXPORT void JNICALL Java_com_sun_javafx_newt_opengl_broadcom_BCEGLWindow_SwapWindow + (JNIEnv *env, jobject obj, jlong display, jlong window) +{ + EGLDisplay dpy = (EGLDisplay) (intptr_t) display; + EGLSurface surf = (EGLSurface) (intptr_t) window; + EGLUtil_SwapWindow( dpy, surf ); + + DBG_PRINT( "[SwapWindow]\n"); +} + |