aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/com')
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/windows/WindowsWindow.java19
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/x11/X11Window.java5
-rw-r--r--src/classes/com/sun/opengl/impl/NullWindow.java12
-rw-r--r--src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java3
-rw-r--r--src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java2
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java4
-rw-r--r--src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java10
-rw-r--r--src/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java4
-rw-r--r--src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java10
-rw-r--r--src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java16
-rw-r--r--src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java2
11 files changed, 56 insertions, 31 deletions
diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
index bfaf79d42..47dd15add 100755
--- a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
+++ b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
@@ -38,6 +38,8 @@ import com.sun.opengl.impl.*;
public class WindowsWindow extends Window {
+ private long hdc;
+
private static final String WINDOW_CLASS_NAME = "NewtWindow";
static {
NativeLibLoader.loadNEWT();
@@ -50,6 +52,13 @@ public class WindowsWindow extends Window {
public WindowsWindow() {
}
+ public long getSurfaceHandle() {
+ if (hdc == 0) {
+ hdc = GetDC(windowHandle);
+ }
+ return hdc;
+ }
+
protected void createNative() {
long wndClass = getWindowClass();
windowHandle = CreateWindow(WINDOW_CLASS_NAME, getHInstance(), visualID, x, y, width, height);
@@ -59,7 +68,11 @@ public class WindowsWindow extends Window {
}
protected void closeNative() {
- CloseWindow(windowHandle);
+ if (hdc != 0) {
+ ReleaseDC(windowHandle, hdc);
+ hdc = 0;
+ }
+ DestroyWindow(windowHandle);
}
public void setVisible(boolean visible) {
@@ -126,7 +139,9 @@ public class WindowsWindow extends Window {
private static native long RegisterWindowClass(String windowClassName, long hInstance);
private native long CreateWindow(String windowClassName, long hInstance, long visualID,
int x, int y, int width, int height);
- private native void CloseWindow(long windowHandle);
+ private native void DestroyWindow(long windowHandle);
+ private native long GetDC(long windowHandle);
+ private native void ReleaseDC(long windowHandle, long hdc);
private native void setVisible0(long windowHandle, boolean visible);
private static native void DispatchMessages(long windowHandle, int eventMask);
private native void setSize0(long windowHandle, int width, int height);
diff --git a/src/classes/com/sun/javafx/newt/x11/X11Window.java b/src/classes/com/sun/javafx/newt/x11/X11Window.java
index 299b78429..217ce5cdb 100755
--- a/src/classes/com/sun/javafx/newt/x11/X11Window.java
+++ b/src/classes/com/sun/javafx/newt/x11/X11Window.java
@@ -35,6 +35,7 @@ package com.sun.javafx.newt.x11;
import com.sun.javafx.newt.*;
import com.sun.opengl.impl.*;
+import javax.media.opengl.NativeWindowException;
public class X11Window extends Window {
private static final String WINDOW_CLASS_NAME = "NewtWindow";
@@ -52,6 +53,10 @@ 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 7bac93ee2..da64c2538 100644
--- a/src/classes/com/sun/opengl/impl/NullWindow.java
+++ b/src/classes/com/sun/opengl/impl/NullWindow.java
@@ -41,16 +41,12 @@ import javax.media.opengl.*;
public class NullWindow implements NativeWindow {
protected boolean locked;
protected int width, height, scrnIndex;
- protected long windowHandle, displayHandle;
+ protected long windowHandle, surfaceHandle, displayHandle;
public NullWindow() {
locked=false;
- width=0;
- height=0;
scrnIndex=-1;
- windowHandle=0;
- displayHandle=0;
}
protected void init(Object windowObject) throws NativeWindowException {
@@ -102,6 +98,12 @@ public class NullWindow implements NativeWindow {
public void setWindowHandle(long handle) {
windowHandle=handle;
}
+ public long getSurfaceHandle() {
+ return surfaceHandle;
+ }
+ public void setSurfaceHandle(long handle) {
+ surfaceHandle=handle;
+ }
public long getVisualID() {
return 0;
}
diff --git a/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java b/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java
index c976e6aa4..9d3917057 100644
--- a/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java
+++ b/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java
@@ -116,6 +116,9 @@ public abstract class JAWTWindow implements NativeWindow {
public long getWindowHandle() {
return drawable;
}
+ public long getSurfaceHandle() {
+ return drawable;
+ }
public long getVisualID() {
return visualID;
}
diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
index 5324a0c55..85447f00b 100644
--- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
@@ -54,7 +54,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
}
hdc = WGL.GetDC(hwnd);
NullWindow nw = (NullWindow) getNativeWindow();
- nw.setWindowHandle(hdc);
+ nw.setSurfaceHandle(hdc);
// Choose a (hopefully hardware-accelerated) OpenGL pixel format for this device context
GLCapabilities caps = new GLCapabilities();
caps.setDepthBits(16);
diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java
index 2c89e1dd0..3a8f75d8e 100755
--- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java
@@ -51,8 +51,8 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable {
public static WindowsExternalWGLDrawable create(GLDrawableFactory factory) {
long hdc = WGL.wglGetCurrentDC();
NullWindow nw = new NullWindow();
- nw.setWindowHandle(hdc);
- if (nw.getWindowHandle() == 0) {
+ nw.setSurfaceHandle(hdc);
+ if (nw.getSurfaceHandle() == 0) {
throw new GLException("Error: attempted to make an external GLDrawable without a drawable/context current");
}
return new WindowsExternalWGLDrawable(factory, nw);
diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
index 84928ae6c..9f47a03d6 100644
--- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
@@ -94,7 +94,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
System.out.println("LastError: " + WGL.GetLastError());
throw new GLException("Error creating device context for offscreen OpenGL context");
}
- nw.setWindowHandle(hdc);
+ nw.setSurfaceHandle(hdc);
hbitmap = WGL.CreateDIBSection(hdc, info, WGL.DIB_RGB_COLORS, 0, 0, 0);
if (hbitmap == 0) {
@@ -121,14 +121,14 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
getFactory().lockToolkit();
try {
NullWindow nw = (NullWindow) getNativeWindow();
- if (nw.getWindowHandle() != 0) {
+ if (nw.getSurfaceHandle() != 0) {
// Must destroy bitmap and device context
- WGL.SelectObject(nw.getWindowHandle(), origbitmap);
+ WGL.SelectObject(nw.getSurfaceHandle(), origbitmap);
WGL.DeleteObject(hbitmap);
- WGL.DeleteDC(nw.getWindowHandle());
+ WGL.DeleteDC(nw.getSurfaceHandle());
origbitmap = 0;
hbitmap = 0;
- nw.setWindowHandle(0);
+ nw.setSurfaceHandle(0);
setChosenGLCapabilities(null);
}
} finally {
diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java
index 767928f16..145858d5d 100644
--- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java
@@ -77,7 +77,7 @@ public class WindowsOnscreenWGLDrawable extends WindowsWGLDrawable {
public void swapBuffers() throws GLException {
boolean didLock = false;
- if (getNativeWindow().getWindowHandle() == 0) {
+ if (getNativeWindow().getSurfaceHandle() == 0) {
if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
return;
}
@@ -89,7 +89,7 @@ public class WindowsOnscreenWGLDrawable extends WindowsWGLDrawable {
startTime = System.currentTimeMillis();
}
- if (!WGL.SwapBuffers(getNativeWindow().getWindowHandle()) && (WGL.GetLastError() != 0)) {
+ if (!WGL.SwapBuffers(getNativeWindow().getSurfaceHandle()) && (WGL.GetLastError() != 0)) {
throw new GLException("Error swapping buffers");
}
diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
index a7af86001..7e55e715c 100644
--- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -71,7 +71,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
(capabilities.getPbufferFloatingPointBuffers() ? " [float]" : ""));
}
- createPbuffer(dummyDrawable.getNativeWindow().getWindowHandle(), wglExt);
+ createPbuffer(dummyDrawable.getNativeWindow().getSurfaceHandle(), wglExt);
}
public GLContext createContext(GLContext shareWith) {
@@ -82,16 +82,16 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
getFactory().lockToolkit();
try {
NullWindow nw = (NullWindow) getNativeWindow();
- if (nw.getWindowHandle() != 0) {
+ if (nw.getSurfaceHandle() != 0) {
// Must release DC and pbuffer
// NOTE that since the context is not current, glGetError() can
// not be called here, so we skip the use of any composable
// pipelines (see WindowsOnscreenWGLContext.makeCurrentImpl)
WGLExt wglExt = cachedWGLExt;
- if (wglExt.wglReleasePbufferDCARB(buffer, nw.getWindowHandle()) == 0) {
+ if (wglExt.wglReleasePbufferDCARB(buffer, nw.getSurfaceHandle()) == 0) {
throw new GLException("Error releasing pbuffer device context: error code " + WGL.GetLastError());
}
- nw.setWindowHandle(0);
+ nw.setSurfaceHandle(0);
if (!wglExt.wglDestroyPbufferARB(buffer)) {
throw new GLException("Error destroying pbuffer: error code " + WGL.GetLastError());
}
@@ -290,7 +290,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
NullWindow nw = (NullWindow) getNativeWindow();
// Set up instance variables
buffer = tmpBuffer;
- nw.setWindowHandle(tmpHdc);
+ nw.setSurfaceHandle(tmpHdc);
cachedWGLExt = wglExt;
cachedParentHdc = parentHdc;
diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
index 150c86526..87c6bde78 100644
--- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -109,15 +109,15 @@ public class WindowsWGLContext extends GLContextImpl {
* called by {@link #makeCurrentImpl()}.
*/
protected void create() {
- if (drawable.getNativeWindow().getWindowHandle() == 0) {
+ if (drawable.getNativeWindow().getSurfaceHandle() == 0) {
throw new GLException("Internal error: attempted to create OpenGL context without an associated drawable");
}
- hglrc = WGL.wglCreateContext(drawable.getNativeWindow().getWindowHandle());
+ hglrc = WGL.wglCreateContext(drawable.getNativeWindow().getSurfaceHandle());
if (hglrc == 0) {
- throw new GLException("Unable to create OpenGL context for device context " + toHexString(drawable.getNativeWindow().getWindowHandle()));
+ throw new GLException("Unable to create OpenGL context for device context " + toHexString(drawable.getNativeWindow().getSurfaceHandle()));
}
if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Created OpenGL context " + toHexString(hglrc) + " for " + this + ", device context " + toHexString(drawable.getNativeWindow().getWindowHandle()) + ", not yet sharing");
+ System.err.println(getThreadName() + ": !!! Created OpenGL context " + toHexString(hglrc) + " for " + this + ", device context " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) + ", not yet sharing");
}
// Windows can set up sharing of display lists after creation time
WindowsWGLContext other = (WindowsWGLContext) GLContextShareSet.getShareContext(this);
@@ -135,12 +135,12 @@ public class WindowsWGLContext extends GLContextImpl {
}
GLContextShareSet.contextCreated(this);
if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Created OpenGL context " + toHexString(hglrc) + " for " + this + ", device context " + toHexString(drawable.getNativeWindow().getWindowHandle()) + ", sharing with " + toHexString(hglrc2));
+ System.err.println(getThreadName() + ": !!! Created OpenGL context " + toHexString(hglrc) + " for " + this + ", device context " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) + ", sharing with " + toHexString(hglrc2));
}
}
protected int makeCurrentImpl() throws GLException {
- if (drawable.getNativeWindow().getWindowHandle() == 0) {
+ if (drawable.getNativeWindow().getSurfaceHandle() == 0) {
if (DEBUG) {
System.err.println("drawable not properly initialized");
}
@@ -156,11 +156,11 @@ public class WindowsWGLContext extends GLContextImpl {
}
if (WGL.wglGetCurrentContext() != hglrc) {
- if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getWindowHandle(), hglrc)) {
+ if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) {
throw new GLException("Error making context current: " + WGL.GetLastError());
} else {
if (DEBUG && VERBOSE) {
- System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + toHexString(drawable.getNativeWindow().getWindowHandle()) +
+ System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) +
", hglrc " + toHexString(hglrc) + ") succeeded");
}
}
diff --git a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java
index 322ae3983..b0063382c 100644
--- a/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java
@@ -106,7 +106,7 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
int pixelFormat = 0;
GLCapabilities chosenCaps = null;
GLCapabilities capabilities = getCapabilities();
- long hdc = getNativeWindow().getWindowHandle();
+ long hdc = getNativeWindow().getSurfaceHandle();
if (onscreen) {
if ((pixelFormat = WGL.GetPixelFormat(hdc)) != 0) {
// The Java2D/OpenGL pipeline probably already set a pixel