diff options
author | Sven Gothel <[email protected]> | 2008-06-26 08:52:58 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2008-06-26 08:52:58 +0000 |
commit | 3c73be50b6a5f983865bb7617739ce1370fb5566 (patch) | |
tree | 8cf2490bddfe56a2f9f27e32999a2948a4dd6936 /src | |
parent | f287efc004e6932cbb2efdf777798a381994ca48 (diff) |
Unifying NativeWindow's getWindowHandle() and getSurfaceHandle() usage for all platforms.
On platform's where no distinction of window and surface handle exists, e.g. X11,
the window handle is naturally returned by the default 'getSurfaceHandle()' implementation.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1696 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
11 files changed, 43 insertions, 41 deletions
diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java index c485a93b1..8b6688c3b 100755 --- a/src/classes/com/sun/javafx/newt/Window.java +++ b/src/classes/com/sun/javafx/newt/Window.java @@ -216,6 +216,10 @@ public abstract class Window implements NativeWindow return windowHandle; } + public long getSurfaceHandle() { + return windowHandle; // default: return window handle + } + public long getVisualID() { return visualID; } diff --git a/src/classes/com/sun/javafx/newt/x11/X11Window.java b/src/classes/com/sun/javafx/newt/x11/X11Window.java index 217ce5cdb..10fd1acd5 100755 --- a/src/classes/com/sun/javafx/newt/x11/X11Window.java +++ b/src/classes/com/sun/javafx/newt/x11/X11Window.java @@ -53,10 +53,6 @@ public class X11Window extends Window { public X11Window() { } - public long getSurfaceHandle() { - throw new NativeWindowException("Unsupported and unnecessary on the X11 platform"); - } - protected void createNative() { long w = CreateWindow(getDisplayHandle(), getScreenHandle(), getScreenIndex(), visualID, x, y, width, height); if (w == 0 || w!=windowHandle) { diff --git a/src/classes/com/sun/opengl/impl/NullWindow.java b/src/classes/com/sun/opengl/impl/NullWindow.java index da64c2538..e5c0b82ea 100644 --- a/src/classes/com/sun/opengl/impl/NullWindow.java +++ b/src/classes/com/sun/opengl/impl/NullWindow.java @@ -95,9 +95,6 @@ public class NullWindow implements NativeWindow { public long getWindowHandle() { return windowHandle; } - public void setWindowHandle(long handle) { - windowHandle=handle; - } public long getSurfaceHandle() { return surfaceHandle; } diff --git a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java index ad71774b5..ff5fbbdff 100644 --- a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java +++ b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java @@ -135,7 +135,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl try { // Try to allocate a context with this nsContext = CGL.createContext(share, - drawable.getNativeWindow().getWindowHandle(), + drawable.getNativeWindow().getSurfaceHandle(), pixelFormat, viewNotReady, 0); if (nsContext == 0) { @@ -232,7 +232,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl } protected int makeCurrentImpl() throws GLException { - if (drawable.getNativeWindow().getWindowHandle() == 0) { + if (drawable.getNativeWindow().getSurfaceHandle() == 0) { if (DEBUG) { System.err.println("drawable not properly initialized"); } diff --git a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 6efe175fe..d5291af39 100644 --- a/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -66,9 +66,9 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { try { NullWindow nw = (NullWindow) getNativeWindow(); - if (nw.getWindowHandle() != 0) { - impl.destroy(nw.getWindowHandle()); - nw.setWindowHandle(0); + if (nw.getSurfaceHandle() != 0) { + impl.destroy(nw.getSurfaceHandle()); + nw.setSurfaceHandle(0); if (DEBUG) { System.err.println("Destroyed pbuffer: " + nw); @@ -86,7 +86,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { } public long getPbuffer() { - return getNativeWindow().getWindowHandle(); + return getNativeWindow().getSurfaceHandle(); } public void swapBuffers() throws GLException { @@ -134,7 +134,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { if (pBuffer == 0) { throw new GLException("pbuffer creation error: CGL.createPBuffer() failed"); } - nw.setWindowHandle(pBuffer); + nw.setSurfaceHandle(pBuffer); } finally { getFactory().unlockToolkit(); } diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXDrawable.java index a982a4605..bbb33bd42 100755 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXDrawable.java @@ -85,7 +85,7 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { GLX.glXQueryContext(display, context, GLX.GLX_SCREEN, val, 0); int screen = val[0]; NullWindow nw = new NullWindow(); - nw.setWindowHandle(drawable); + nw.setSurfaceHandle(drawable); nw.setScreenIndex(screen); return new X11ExternalGLXDrawable(factory, nw); } finally { @@ -118,7 +118,7 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { } protected int makeCurrentImpl() throws GLException { - if (drawable.getNativeWindow().getWindowHandle() == 0) { + if (drawable.getNativeWindow().getSurfaceHandle() == 0) { // parent drawable not properly initialized // FIXME: signal error? if (DEBUG) { @@ -141,14 +141,14 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { } if (!GLX.glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(), - drawable.getNativeWindow().getWindowHandle(), + drawable.getNativeWindow().getSurfaceHandle(), readDrawable, context)) { throw new GLException("Error making context current"); } else { if (DEBUG && VERBOSE) { System.err.println(getThreadName() + ": glXMakeCurrent(display " + toHexString(drawable.getNativeWindow().getDisplayHandle()) + - ", drawable " + toHexString(drawable.getNativeWindow().getWindowHandle()) + + ", drawable " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) + ", context " + toHexString(context) + ") succeeded"); } } @@ -222,7 +222,7 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { if (DEBUG) { System.err.println("Created context " + toHexString(context) + - " for GLXDrawable " + toHexString(drawable.getNativeWindow().getWindowHandle())); + " for GLXDrawable " + toHexString(drawable.getNativeWindow().getSurfaceHandle())); } } } diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java b/src/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java index 2821a3049..457240503 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java @@ -124,7 +124,7 @@ public abstract class X11GLXContext extends GLContextImpl { } protected int makeCurrentImpl() throws GLException { - if (drawable.getNativeWindow().getWindowHandle() == 0) { + if (drawable.getNativeWindow().getSurfaceHandle() == 0) { if (DEBUG) { System.err.println("drawable not properly initialized"); } @@ -141,15 +141,15 @@ public abstract class X11GLXContext extends GLContextImpl { if (GLX.glXGetCurrentContext() != context) { if (!GLX.glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(), - drawable.getNativeWindow().getWindowHandle(), - drawable.getNativeWindow().getWindowHandle(), + drawable.getNativeWindow().getSurfaceHandle(), + drawable.getNativeWindow().getSurfaceHandle(), context)) { throw new GLException("Error making context current"); } else { if (DEBUG && (VERBOSE || created)) { System.err.println(getThreadName() + ": glXMakeCurrent(display " + toHexString(drawable.getNativeWindow().getDisplayHandle()) + - ", drawable " + toHexString(drawable.getNativeWindow().getWindowHandle()) + + ", drawable " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) + ", context " + toHexString(context) + ") succeeded"); } } diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java index 9d5e7ac16..446d6f4e5 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java @@ -85,7 +85,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { pixmap = 0; throw new GLException("glXCreateGLXPixmap failed"); } - nw.setWindowHandle(drawable); + nw.setSurfaceHandle(drawable); isDoubleBuffered = (X11GLXDrawableFactory.glXGetConfig(dpy, vis, GLX.GLX_DOUBLEBUFFER, new int[1], 0) != 0); if (DEBUG) { System.err.println("Created pixmap " + toHexString(pixmap) + @@ -103,7 +103,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable { try { NativeWindow nw = getNativeWindow(); long display = nw.getDisplayHandle(); - long drawable = nw.getWindowHandle(); + long drawable = nw.getSurfaceHandle(); if (DEBUG) { System.err.println("Destroying pixmap " + toHexString(pixmap) + ", GLXPixmap " + toHexString(drawable) + diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java index 120ec56bb..1741ba72a 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java @@ -69,7 +69,7 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable { try { boolean didLock = false; - if (component.getWindowHandle() == 0) { + if (component.getSurfaceHandle() == 0) { if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) { return; } @@ -77,7 +77,7 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable { didLock = true; } - GLX.glXSwapBuffers(component.getDisplayHandle(), component.getWindowHandle()); + GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle()); if (didLock) { unlockSurface(); diff --git a/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java index 0d09f6600..3f29095cb 100644 --- a/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java @@ -81,9 +81,9 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { getFactory().lockToolkit(); try { NullWindow nw = (NullWindow) getNativeWindow(); - if (nw.getWindowHandle() != 0) { - GLX.glXDestroyPbuffer(nw.getDisplayHandle(), nw.getWindowHandle()); - nw.setWindowHandle(0); + if (nw.getSurfaceHandle() != 0) { + GLX.glXDestroyPbuffer(nw.getDisplayHandle(), nw.getSurfaceHandle()); + nw.setSurfaceHandle(0); } nw.setDisplayHandle(0); } finally { @@ -164,7 +164,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { } // Set up instance variables - nw.setWindowHandle(drawable); + nw.setSurfaceHandle(drawable); this.fbConfig = fbConfig; // Pick innocent query values if multisampling or floating point buffers not available diff --git a/src/classes/javax/media/opengl/NativeWindow.java b/src/classes/javax/media/opengl/NativeWindow.java index b938c4cec..56562a4c9 100644 --- a/src/classes/javax/media/opengl/NativeWindow.java +++ b/src/classes/javax/media/opengl/NativeWindow.java @@ -69,20 +69,25 @@ public interface NativeWindow { public long getScreenHandle(); /** - * Returns the window handle for this NativeWindow. On X11 this - * returns a Window. On Windows platforms this returns an HWND. This - * might not be supported by all NativeWindow implementations, in - * particular those designed to work only with window surfaces. + * Returns the window handle for this NativeWindow. + * + * The window handle shall reflect the platform one + * for all window related operations, e.g. open, close, resize. + * + * On X11 this returns an entity of type Window. + * On Microsoft Windows this returns an entity of type HWND. */ public long getWindowHandle() throws NativeWindowException; /** - * Returns the handle to the surface for this NativeWindow. This - * method is in support of platforms on which there is a distinction - * between the window handle and window surface, in particular the - * Microsoft Windows platform, on which this method returns an HDC. - * This might not be supported on all NativeWindow implementations, - * in particular those designed to work only with window handles. + * Returns the handle to the surface for this NativeWindow. + * + * The surface handle shall reflect the platform one + * for all drawable surface operations, e.g. opengl, swap-buffer. + * + * On X11 this returns an entity of type Window, + * since there is no differentiation of surface and window there. + * On Microsoft Windows this returns an entity of type HDC. */ public long getSurfaceHandle() throws NativeWindowException; |