aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/com/sun')
-rwxr-xr-xsrc/classes/com/sun/javafx/audio/windows/waveout/TestSpatialization.java4
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/Display.java42
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/NewtFactory.java80
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/Screen.java44
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/Window.java143
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/windows/WindowsDisplay.java46
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/windows/WindowsScreen.java46
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/windows/WindowsWindow.java24
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/x11/X11Display.java59
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/x11/X11Screen.java59
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/x11/X11Window.java61
-rw-r--r--src/classes/com/sun/opengl/impl/GLContextImpl.java2
-rw-r--r--src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java4
-rw-r--r--src/classes/com/sun/opengl/impl/GLDrawableImpl.java14
-rw-r--r--src/classes/com/sun/opengl/impl/NativeLibLoader.java23
-rw-r--r--src/classes/com/sun/opengl/impl/awt/AWTNativeLibLoader.java71
-rw-r--r--src/classes/com/sun/opengl/impl/awt/JAWTWindow.java156
-rw-r--r--src/classes/com/sun/opengl/impl/awt/JAWT_PlatformInfo.java (renamed from src/classes/com/sun/opengl/impl/JAWT_PlatformInfo.java)4
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/awt/Java2D.java (renamed from src/classes/com/sun/opengl/impl/Java2D.java)4
-rw-r--r--src/classes/com/sun/opengl/impl/awt/Java2DGLContext.java (renamed from src/classes/com/sun/opengl/impl/Java2DGLContext.java)5
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/egl/EGLContext.java2
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/egl/EGLDrawable.java30
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java11
-rw-r--r--src/classes/com/sun/opengl/impl/macosx/awt/MacOSXJAWTWindow.java68
-rw-r--r--src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java4
-rw-r--r--src/classes/com/sun/opengl/impl/windows/awt/WindowsJAWTWindow.java68
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java175
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java80
-rw-r--r--src/classes/com/sun/opengl/impl/x11/awt/X11AWTGLDrawableFactory.java203
-rw-r--r--src/classes/com/sun/opengl/impl/x11/awt/X11JAWTWindow.java141
-rw-r--r--src/classes/com/sun/opengl/impl/x11/awt/X11SunJDKReflection.java (renamed from src/classes/com/sun/opengl/impl/x11/X11SunJDKReflection.java)4
31 files changed, 1211 insertions, 466 deletions
diff --git a/src/classes/com/sun/javafx/audio/windows/waveout/TestSpatialization.java b/src/classes/com/sun/javafx/audio/windows/waveout/TestSpatialization.java
index e4ade6375..2040c55d1 100755
--- a/src/classes/com/sun/javafx/audio/windows/waveout/TestSpatialization.java
+++ b/src/classes/com/sun/javafx/audio/windows/waveout/TestSpatialization.java
@@ -44,7 +44,9 @@ public class TestSpatialization {
try {
// FIXME: this is a hack to get the native library loaded
- GLDrawableFactory.getFactory();
+ try {
+ GLDrawableFactory.getFactory(GLDrawableFactory.PROFILE_GLES1, null);
+ } catch (Exception e) {}
// Initialize the audio subsystem
Audio audio = Audio.getInstance();
// Create a track
diff --git a/src/classes/com/sun/javafx/newt/Display.java b/src/classes/com/sun/javafx/newt/Display.java
index 7be9a1b12..5ec2c381a 100755
--- a/src/classes/com/sun/javafx/newt/Display.java
+++ b/src/classes/com/sun/javafx/newt/Display.java
@@ -33,16 +33,33 @@
package com.sun.javafx.newt;
-public class Display {
+public abstract class Display {
- public Display() {
- this(null);
+ protected static Display create(String type, String name) {
+ try {
+ Class displayClass = null;
+ if (NewtFactory.KD.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.kd.KDDisplay");
+ } else if (NewtFactory.WINDOWS.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.displays.WindowsDisplay");
+ } else if (NewtFactory.X11.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.x11.X11Display");
+ } else if (NewtFactory.MACOSX.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.macosx.MacOSXDisplay");
+ } else {
+ throw new RuntimeException("Unknown display type \"" + type + "\"");
+ }
+ Display display = (Display) displayClass.newInstance();
+ display.name=name;
+ display.handle=0;
+ display.initNative();
+ return display;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
- public Display(String name) {
- this.name=name;
- this.handle=-1;
- }
+ protected abstract void initNative();
public String getName() {
return name;
@@ -52,17 +69,6 @@ public class Display {
return handle;
}
- /**
- * native handle
- *
- * write once ..
- */
- public void setHandle(long handle) {
- if(this.handle<0) {
- this.handle=handle;
- }
- }
-
protected String name;
protected long handle;
}
diff --git a/src/classes/com/sun/javafx/newt/NewtFactory.java b/src/classes/com/sun/javafx/newt/NewtFactory.java
new file mode 100755
index 000000000..e0281eafa
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/NewtFactory.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public abstract class NewtFactory {
+ /** OpenKODE window type */
+ public static final String KD = "KD";
+
+ /** Microsoft Windows window type */
+ public static final String WINDOWS = "Windows";
+
+ /** X11 window type */
+ public static final String X11 = "X11";
+
+ /** Mac OS X window type */
+ public static final String MACOSX = "MacOSX";
+
+ /** Creates a Window of the default type for the current operating system. */
+ public static String getWindowType() {
+ String osName = System.getProperty("os.name");
+ String osNameLowerCase = osName.toLowerCase();
+ String windowType;
+ if (osNameLowerCase.startsWith("wind")) {
+ windowType = WINDOWS;
+ } else if (osNameLowerCase.startsWith("mac os x")) {
+ windowType = MACOSX;
+ } else {
+ windowType = X11;
+ }
+ return windowType;
+ }
+
+ public static Display createDisplay(String name) {
+ return Display.create(getWindowType(), name);
+ }
+
+ public static Screen createScreen(Display display, int index) {
+ return Screen.create(getWindowType(), display, index);
+ }
+
+ public static Window createWindow(Screen screen, long visualID) {
+ return Window.create(getWindowType(), screen, visualID);
+ }
+
+}
+
diff --git a/src/classes/com/sun/javafx/newt/Screen.java b/src/classes/com/sun/javafx/newt/Screen.java
index b698a0248..9252b30d4 100755
--- a/src/classes/com/sun/javafx/newt/Screen.java
+++ b/src/classes/com/sun/javafx/newt/Screen.java
@@ -33,17 +33,34 @@
package com.sun.javafx.newt;
-public class Screen {
+public abstract class Screen {
- public Screen(Display display) {
- this(display, 0);
+ protected static Screen create(String type, Display display, int idx) {
+ try {
+ Class screenClass = null;
+ if (NewtFactory.KD.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.kd.KDScreen");
+ } else if (NewtFactory.WINDOWS.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.screens.WindowsScreen");
+ } else if (NewtFactory.X11.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.x11.X11Screen");
+ } else if (NewtFactory.MACOSX.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.macosx.MacOSXScreen");
+ } else {
+ throw new RuntimeException("Unknown window type \"" + type + "\"");
+ }
+ Screen screen = (Screen) screenClass.newInstance();
+ screen.display = display;
+ screen.index = idx;
+ screen.handle = 0;
+ screen.initNative();
+ return screen;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
- public Screen(Display display, int idx) {
- this.display=display;
- this.index=idx;
- this.handle=-1;
- }
+ protected abstract void initNative();
public Display getDisplay() {
return display;
@@ -57,17 +74,6 @@ public class Screen {
return handle;
}
- /**
- * native handle
- *
- * write once ..
- */
- public void setHandle(long handle) {
- if(this.handle<0) {
- this.handle=handle;
- }
- }
-
protected Display display;
protected int index;
protected long handle;
diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java
index 27610cdf2..16984d1f3 100755
--- a/src/classes/com/sun/javafx/newt/Window.java
+++ b/src/classes/com/sun/javafx/newt/Window.java
@@ -33,101 +33,120 @@
package com.sun.javafx.newt;
+import javax.media.opengl.NativeWindow;
+import javax.media.opengl.NativeWindowException;
+
import java.util.ArrayList;
import java.util.Iterator;
-public abstract class Window {
+public abstract class Window implements NativeWindow
+{
public static final boolean DEBUG_MOUSE_EVENT = false;
public static final boolean DEBUG_KEY_EVENT = false;
+ public static final boolean DEBUG_IMPLEMENTATION = true;
- /** OpenKODE window type */
- public static final String KD = "KD";
-
- /** Microsoft Windows window type */
- public static final String WINDOWS = "Windows";
-
- /** X11 window type */
- public static final String X11 = "X11";
-
- /** Mac OS X window type */
- public static final String MACOSX = "MacOSX";
-
- /** Creates a Window of the default type for the current operating system. */
- public static Window create(Screen screen, long visualID) {
- String osName = System.getProperty("os.name");
- String osNameLowerCase = osName.toLowerCase();
- String windowType;
- if (osNameLowerCase.startsWith("wind")) {
- windowType = WINDOWS;
- } else if (osNameLowerCase.startsWith("mac os x")) {
- windowType = MACOSX;
- } else {
- windowType = X11;
- }
- Window window = create(windowType);
- window.initNative(screen, visualID);
- return window;
- }
-
-
- public static Window create(String type) {
+ protected static Window create(String type, Screen screen, long visualID) {
try {
Class windowClass = null;
- if (KD.equals(type)) {
+ if (NewtFactory.KD.equals(type)) {
windowClass = Class.forName("com.sun.javafx.newt.kd.KDWindow");
- } else if (WINDOWS.equals(type)) {
+ } else if (NewtFactory.WINDOWS.equals(type)) {
windowClass = Class.forName("com.sun.javafx.newt.windows.WindowsWindow");
- } else if (X11.equals(type)) {
+ } else if (NewtFactory.X11.equals(type)) {
windowClass = Class.forName("com.sun.javafx.newt.x11.X11Window");
- } else if (MACOSX.equals(type)) {
+ } else if (NewtFactory.MACOSX.equals(type)) {
windowClass = Class.forName("com.sun.javafx.newt.macosx.MacOSXWindow");
} else {
throw new RuntimeException("Unknown window type \"" + type + "\"");
}
- return (Window) windowClass.newInstance();
+ Window window = (Window) windowClass.newInstance();
+ window.screen = screen;
+ window.visualID = visualID;
+ window.windowHandle = 0;
+ window.locked = false;
+ window.initNative();
+ return window;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
+ protected abstract void initNative();
- /**
- * [ display, screen, window ]
- */
- public long[] getHandles() {
- long[] handles = new long[3];
- handles[0] = getScreen().getDisplay().getHandle();
- handles[1] = getScreen().getHandle();
- handles[2] = getWindowHandle();
- return handles;
+ public Screen getScreen() {
+ return screen;
}
- protected abstract void initNative(Screen screen, long visualID);
-
- public abstract void setVisible(boolean visible);
- public abstract void setSize(int width, int height);
- public abstract void setPosition(int x, int y);
- public abstract boolean isVisible();
- public abstract int getWidth();
- public abstract int getHeight();
- public abstract int getX();
- public abstract int getY();
- public abstract boolean setFullscreen(boolean fullscreen);
- public abstract boolean isFullscreen();
public abstract int getDisplayWidth();
public abstract int getDisplayHeight();
- public abstract Screen getScreen();
- public abstract long getWindowHandle();
-
public abstract void pumpMessages();
public String toString() {
- return "Window[handle "+getWindowHandle()+
+ return "Window[handle "+windowHandle+
", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
", visible "+isVisible()+"]";
}
+ protected Screen screen;
+ protected long visualID;
+ protected long windowHandle;
+ protected boolean locked;
+
+ //
+ // NativeWindow impl
+ //
+
+ public boolean lockSurface() throws NativeWindowException {
+ if (locked) {
+ throw new NativeWindowException("Surface already locked");
+ }
+ locked = true;
+ return true;
+ }
+
+ public void unlockSurface() {
+ if (!locked) {
+ throw new NativeWindowException("Surface already locked");
+ }
+ locked = false;
+ }
+
+ public boolean isSurfaceLocked() {
+ return locked;
+ }
+
+ public long getDisplayHandle() {
+ return screen.getDisplay().getHandle();
+ }
+
+ public long getScreenHandle() {
+ return screen.getHandle();
+ }
+
+ public int getScreenIndex() {
+ return screen.getIndex();
+ }
+
+ public long getWindowHandle() {
+ return windowHandle;
+ }
+
+ public long getVisualID() {
+ return visualID;
+ }
+
+ public abstract int getWidth();
+ public abstract int getHeight();
+ public abstract int getX();
+ public abstract int getY();
+ public abstract void setVisible(boolean visible);
+ public abstract void setSize(int width, int height);
+ public abstract void setPosition(int x, int y);
+ public abstract boolean isVisible();
+ public abstract boolean setFullscreen(boolean fullscreen);
+ public abstract boolean isFullscreen();
+
//
// MouseListener Support
//
diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsDisplay.java b/src/classes/com/sun/javafx/newt/windows/WindowsDisplay.java
new file mode 100755
index 000000000..ce2ac8c4a
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/windows/WindowsDisplay.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.windows;
+
+import com.sun.javafx.newt.*;
+import com.sun.opengl.impl.*;
+
+public class WindowsDisplay extends Display {
+ public WindowsDisplay() {
+ }
+
+ public void initNative() {
+ handle = 0;
+ }
+}
diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsScreen.java b/src/classes/com/sun/javafx/newt/windows/WindowsScreen.java
new file mode 100755
index 000000000..cf163ce48
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/windows/WindowsScreen.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.windows;
+
+import com.sun.javafx.newt.*;
+import com.sun.opengl.impl.*;
+
+public class WindowsScreen extends Screen {
+ public WindowsScreen() {
+ }
+
+ public void initNative() {
+ handle = 0;
+ }
+}
diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
index e170f9b56..c392cb20e 100755
--- a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
+++ b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
@@ -59,22 +59,14 @@ public class WindowsWindow extends Window {
public WindowsWindow() {
}
- public void initNative(Screen screen, long visualID) {
- this.screen = screen;
- this.visualID = visualID;
+ public void initNative() {
long wndClass = getWindowClass();
fullscreen=false;
visible=false;
- window = CreateWindow(WINDOW_CLASS_NAME, getHInstance(), visualID, x, y, width, height);
- if (window == 0) {
+ windowHandle = CreateWindow(WINDOW_CLASS_NAME, getHInstance(), visualID, x, y, width, height);
+ if (windowHandle == 0) {
throw new RuntimeException("Error creating window");
}
- screen.setHandle(0); // dummy
- screen.getDisplay().setHandle(0); // dummy
- }
-
- public Screen getScreen() {
- return screen;
}
public void setVisible(boolean visible) {
@@ -131,10 +123,6 @@ public class WindowsWindow extends Window {
return 480; // FIXME
}
- public long getWindowHandle() {
- return window;
- }
-
public void pumpMessages() {
DispatchMessages(window);
}
@@ -175,12 +163,6 @@ public class WindowsWindow extends Window {
private native void setSize0(long window, int width, int height);
private native boolean setFullScreen0(long window, boolean fullscreen);
- private void keyDown(long key) {
- }
-
- private void keyUp(long key) {
- }
-
private void sizeChanged(int newWidth, int newHeight) {
width = newWidth;
height = newHeight;
diff --git a/src/classes/com/sun/javafx/newt/x11/X11Display.java b/src/classes/com/sun/javafx/newt/x11/X11Display.java
new file mode 100755
index 000000000..5a4ed8eed
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/x11/X11Display.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.x11;
+
+import com.sun.javafx.newt.*;
+import com.sun.opengl.impl.*;
+
+public class X11Display extends Display {
+ static {
+ NativeLibLoader.loadCore();
+ }
+
+ public X11Display() {
+ }
+
+ public void initNative() {
+ handle = CreateDisplay(name);
+ if (handle == 0 ) {
+ throw new RuntimeException("Error creating display: "+name);
+ }
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ private native long CreateDisplay(String name);
+}
diff --git a/src/classes/com/sun/javafx/newt/x11/X11Screen.java b/src/classes/com/sun/javafx/newt/x11/X11Screen.java
new file mode 100755
index 000000000..279507fab
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/x11/X11Screen.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.x11;
+
+import com.sun.javafx.newt.*;
+import com.sun.opengl.impl.*;
+
+public class X11Screen extends Screen {
+ static {
+ NativeLibLoader.loadCore();
+ }
+
+ public X11Screen() {
+ }
+
+ public void initNative() {
+ handle = GetScreen(display.getHandle(), index);
+ if (handle == 0 ) {
+ throw new RuntimeException("Error creating screen: "+index);
+ }
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ private native long GetScreen(long dpy, int scrn_idx);
+}
diff --git a/src/classes/com/sun/javafx/newt/x11/X11Window.java b/src/classes/com/sun/javafx/newt/x11/X11Window.java
index 80021dca4..d89cd1169 100755
--- a/src/classes/com/sun/javafx/newt/x11/X11Window.java
+++ b/src/classes/com/sun/javafx/newt/x11/X11Window.java
@@ -37,10 +37,6 @@ import com.sun.javafx.newt.*;
import com.sun.opengl.impl.*;
public class X11Window extends Window {
- private Screen screen;
- private long visualID;
- private long dpy, scrn, window;
- private int scrn_idx;
private static final String WINDOW_CLASS_NAME = "NewtWindow";
// Default width and height -- will likely be re-set immediately by user
private int width = 100;
@@ -62,36 +58,28 @@ public class X11Window extends Window {
public X11Window() {
}
- public void initNative(Screen screen, long visualID) {
- this.screen = screen;
- this.visualID = visualID;
+ public void initNative() {
fullscreen=false;
visible=false;
- long w = CreateWindow(visualID, x, y, width, height);
- if (w == 0 || w!=window) {
+ long w = CreateWindow(getDisplayHandle(), getScreenHandle(), getScreenIndex(), visualID, x, y, width, height);
+ if (w == 0 || w!=windowHandle) {
throw new RuntimeException("Error creating window: "+w);
}
- screen.setHandle(scrn);
- screen.getDisplay().setHandle(dpy);
- }
-
- public Screen getScreen() {
- return screen;
}
public void setVisible(boolean visible) {
if(this.visible!=visible) {
this.visible=visible;
- setVisible0(dpy, window, visible);
+ setVisible0(getDisplayHandle(), windowHandle, visible);
}
}
public void setSize(int width, int height) {
- setSize0(dpy, window, width, height);
+ setSize0(getDisplayHandle(), windowHandle, width, height);
}
public void setPosition(int x, int y) {
- setPosition0(dpy, window, x, y);
+ setPosition0(getDisplayHandle(), windowHandle, x, y);
}
public boolean isVisible() {
@@ -120,16 +108,16 @@ public class X11Window extends Window {
this.fullscreen=fullscreen;
if(this.fullscreen) {
x = 0; y = 0;
- w = getDisplayWidth0(dpy, scrn_idx)/2;
- h = getDisplayHeight0(dpy, scrn_idx)/2;
+ w = getDisplayWidth0(getDisplayHandle(), getScreenIndex())/2;
+ h = getDisplayHeight0(getDisplayHandle(), getScreenIndex())/2;
} else {
x = nfs_x;
y = nfs_y;
w = nfs_width;
h = nfs_height;
}
- setPosition0(dpy, window, x, y);
- setSize0(dpy, window, w, h);
+ setPosition0(getDisplayHandle(), windowHandle, x, y);
+ setSize0(getDisplayHandle(), windowHandle, w, h);
}
return true;
}
@@ -138,20 +126,16 @@ public class X11Window extends Window {
return fullscreen;
}
- public long getWindowHandle() {
- return window;
- }
-
public void pumpMessages() {
- DispatchMessages(dpy, window);
+ DispatchMessages(getDisplayHandle(), windowHandle);
}
public int getDisplayWidth() {
- return getDisplayWidth0(dpy, scrn_idx);
+ return getDisplayWidth0(getDisplayHandle(), getScreenIndex());
}
public int getDisplayHeight() {
- return getDisplayHeight0(dpy, scrn_idx);
+ return getDisplayHeight0(getDisplayHandle(), getScreenIndex());
}
//----------------------------------------------------------------------
@@ -159,11 +143,12 @@ public class X11Window extends Window {
//
private static native boolean initIDs();
- private native long CreateWindow(long visualID, int x, int y, int width, int height);
- private native void setVisible0(long display, long window, boolean visible);
- private native void DispatchMessages(long display, long window);
- private native void setSize0(long display, long window, int width, int height);
- private native void setPosition0(long display, long window, int x, int y);
+ private native long CreateWindow(long display, long screen, int screen_index,
+ long visualID, int x, int y, int width, int height);
+ private native void setVisible0(long display, long windowHandle, boolean visible);
+ private native void DispatchMessages(long display, long windowHandle);
+ private native void setSize0(long display, long windowHandle, int width, int height);
+ private native void setPosition0(long display, long windowHandle, int x, int y);
private native int getDisplayWidth0(long display, int scrn_idx);
private native int getDisplayHeight0(long display, int scrn_idx);
@@ -185,11 +170,9 @@ public class X11Window extends Window {
}
}
- private void windowCreated(long dpy, int scrn_idx, long scrn, long window) {
- this.dpy = dpy;
- this.scrn_idx = scrn_idx;
- this.scrn = scrn;
- this.window = window;
+ private void windowCreated(long visualID, long windowHandle) {
+ this.visualID = visualID;
+ this.windowHandle = windowHandle;
}
private void windowClosed() {
diff --git a/src/classes/com/sun/opengl/impl/GLContextImpl.java b/src/classes/com/sun/opengl/impl/GLContextImpl.java
index 17169ebf2..eb9cf0e55 100644
--- a/src/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -326,7 +326,7 @@ public abstract class GLContextImpl extends GLContext {
/** Helper routine which resets a ProcAddressTable generated by the
GLEmitter by looking up anew all of its function pointers. */
protected void resetProcAddressTable(Object table) {
- ProcAddressHelper.resetProcAddressTable(table, GLDrawableFactoryImpl.getFactoryImpl());
+ ProcAddressHelper.resetProcAddressTable(table, (GLDrawableFactoryImpl)getGLDrawable().getFactory());
}
/** Indicates whether the underlying OpenGL context has been
diff --git a/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
index d0e9118ea..20616f34d 100644
--- a/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
@@ -72,10 +72,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory implements
super(profile);
}
- public static GLDrawableFactoryImpl getFactoryImpl() {
- return (GLDrawableFactoryImpl) getFactory();
- }
-
// Helper function for more lazily loading the GLU library;
// apparently can't use System.loadLibrary on UNIX because it uses
// RTLD_LOCAL and we need to call dlsym(RTLD_DEFAULT)
diff --git a/src/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/classes/com/sun/opengl/impl/GLDrawableImpl.java
index df1aab796..690bfd88c 100644
--- a/src/classes/com/sun/opengl/impl/GLDrawableImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLDrawableImpl.java
@@ -42,6 +42,8 @@ package com.sun.opengl.impl;
import javax.media.opengl.*;
public abstract class GLDrawableImpl implements GLDrawable {
+ protected GLDrawableFactory factory;
+ protected NativeWindow component;
private GLCapabilities chosenCapabilities;
/** For offscreen GLDrawables (pbuffers and "pixmap" drawables),
@@ -63,4 +65,16 @@ public abstract class GLDrawableImpl implements GLDrawable {
public void setChosenGLCapabilities(GLCapabilities caps) {
chosenCapabilities = caps;
}
+
+ public NativeWindow getNativeWindow() {
+ return component;
+ }
+
+ public GLDrawableFactory getFactory() {
+ return factory;
+ }
+
+ public String getProfile() {
+ return factory.getProfile();
+ }
}
diff --git a/src/classes/com/sun/opengl/impl/NativeLibLoader.java b/src/classes/com/sun/opengl/impl/NativeLibLoader.java
index ffe8df3e2..aaf782296 100644
--- a/src/classes/com/sun/opengl/impl/NativeLibLoader.java
+++ b/src/classes/com/sun/opengl/impl/NativeLibLoader.java
@@ -115,29 +115,6 @@ public class NativeLibLoader {
});
}
- /* FIXME: refactor Java SE dependencies
- public static void loadAWTImpl() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- // Make sure that awt.dll is loaded before loading jawt.dll. Otherwise
- // a Dialog with "awt.dll not found" might pop up.
- // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4481947.
- Toolkit.getDefaultToolkit();
-
- // Must pre-load JAWT on all non-Mac platforms to
- // ensure references from jogl_awt shared object
- // will succeed since JAWT shared object isn't in
- // default library path
- boolean isOSX = System.getProperty("os.name").equals("Mac OS X");
- String[] preload = { "jawt" };
-
- loadLibrary("jogl_awt", preload, !isOSX, false);
- return null;
- }
- });
- }
- */
-
public static void loadCgImpl() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
diff --git a/src/classes/com/sun/opengl/impl/awt/AWTNativeLibLoader.java b/src/classes/com/sun/opengl/impl/awt/AWTNativeLibLoader.java
new file mode 100644
index 000000000..5e39c445f
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/awt/AWTNativeLibLoader.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.impl.awt;
+
+import com.sun.opengl.impl.*;
+
+import java.awt.Toolkit;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+public class AWTNativeLibLoader extends NativeLibLoader {
+ public static void loadAWTImpl() {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ // Make sure that awt.dll is loaded before loading jawt.dll. Otherwise
+ // a Dialog with "awt.dll not found" might pop up.
+ // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4481947.
+ Toolkit.getDefaultToolkit();
+
+ // Must pre-load JAWT on all non-Mac platforms to
+ // ensure references from jogl_awt shared object
+ // will succeed since JAWT shared object isn't in
+ // default library path
+ boolean isOSX = System.getProperty("os.name").equals("Mac OS X");
+ String[] preload = { "jawt" };
+
+ loadLibrary("jogl_awt", preload, !isOSX, false);
+ return null;
+ }
+ });
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/awt/JAWTWindow.java b/src/classes/com/sun/opengl/impl/awt/JAWTWindow.java
new file mode 100644
index 000000000..068088f71
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/awt/JAWTWindow.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.impl.awt;
+
+import com.sun.opengl.impl.*;
+
+import java.awt.Component;
+import javax.media.opengl.*;
+import com.sun.opengl.impl.*;
+
+public abstract class JAWTWindow implements NativeWindow {
+ protected static final boolean DEBUG = Debug.debug("GLDrawable");
+
+ // lifetime: forever
+ protected Component component;
+ protected boolean locked;
+
+ // lifetime: valid while locked
+ protected long display;
+ protected long screen;
+ protected long drawable;
+ // lifetime: valid after lock, forever
+ protected long visualID;
+ protected int screenIndex;
+
+ public JAWTWindow(Object comp) {
+ init(comp);
+ }
+
+ protected void init(Object windowObject) throws NativeWindowException {
+ this.locked = false;
+ this.component = (Component)comp;
+ this.display= null;
+ this.screen= null;
+ this.screenIndex = -1;
+ this.drawable= null;
+ this.visualID = 0;
+ initNative();
+ }
+
+ public abstract boolean initNative() throws NativeWindowException;
+
+ public boolean lockSurface() throws NativeWindowException {
+ if (locked) {
+ throw new NativeWindowException("Surface already locked");
+ }
+ locked = true;
+ }
+
+ public void unlockSurface() {
+ if (!locked) {
+ throw new NativeWindowException("Surface already locked");
+ }
+ locked = false;
+ display= null;
+ screen= null;
+ drawable= null;
+ }
+
+ public boolean isSurfaceLocked() {
+ return locked;
+ }
+
+ public long getDisplayHandle() {
+ return display;
+ }
+ public long getScreenHandle() {
+ return screen;
+ }
+ public int getScreenIndex() {
+ return screenIndex;
+ }
+ public long getWindowHandle() {
+ return drawable;
+ }
+ public long getVisualID() {
+ return visualID;
+ }
+
+ public void setSize(int width, int height) {
+ component.setSize(width, height);
+ }
+
+ public int getWidth() {
+ return component.getWidth();
+ }
+
+ public int getHeight() {
+ return component.getHeight();
+ }
+
+ public int getX() {
+ return component.getX();
+ }
+ public int getY() {
+ return component.getY();
+ }
+
+ public void setPosition(int x, int y) {
+ component.setLocation(x,y);
+ }
+
+ public void setVisible(boolean visible) {
+ component.setVisible(visible);
+ }
+
+ public boolean isVisible() {
+ return component.isVisible();
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ return false; // FIXME
+ }
+
+ public boolean isFullscreen() {
+ return false; // FIXME
+ }
+
+}
diff --git a/src/classes/com/sun/opengl/impl/JAWT_PlatformInfo.java b/src/classes/com/sun/opengl/impl/awt/JAWT_PlatformInfo.java
index ca101eff9..cd80c1be9 100644
--- a/src/classes/com/sun/opengl/impl/JAWT_PlatformInfo.java
+++ b/src/classes/com/sun/opengl/impl/awt/JAWT_PlatformInfo.java
@@ -37,7 +37,9 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.impl;
+package com.sun.opengl.impl.awt;
+
+import com.sun.opengl.impl.*;
/** Marker class for all window system-specific JAWT data structures. */
diff --git a/src/classes/com/sun/opengl/impl/Java2D.java b/src/classes/com/sun/opengl/impl/awt/Java2D.java
index 713effa67..ed0a80f00 100755
--- a/src/classes/com/sun/opengl/impl/Java2D.java
+++ b/src/classes/com/sun/opengl/impl/awt/Java2D.java
@@ -37,7 +37,9 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.impl;
+package com.sun.opengl.impl.awt;
+
+import com.sun.opengl.impl.*;
import java.awt.*;
import java.awt.image.*;
diff --git a/src/classes/com/sun/opengl/impl/Java2DGLContext.java b/src/classes/com/sun/opengl/impl/awt/Java2DGLContext.java
index 86bcb6482..48461c116 100644
--- a/src/classes/com/sun/opengl/impl/Java2DGLContext.java
+++ b/src/classes/com/sun/opengl/impl/awt/Java2DGLContext.java
@@ -37,8 +37,9 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.impl;
+package com.sun.opengl.impl.awt;
+import com.sun.opengl.impl.*;
import java.awt.Graphics;
/** Provides a construct by which the shared GLJPanel code can
@@ -48,4 +49,4 @@ import java.awt.Graphics;
public interface Java2DGLContext {
public void setGraphics(Graphics g);
-} \ No newline at end of file
+}
diff --git a/src/classes/com/sun/opengl/impl/egl/EGLContext.java b/src/classes/com/sun/opengl/impl/egl/EGLContext.java
index 25ac2c726..ab0fbb304 100755
--- a/src/classes/com/sun/opengl/impl/egl/EGLContext.java
+++ b/src/classes/com/sun/opengl/impl/egl/EGLContext.java
@@ -122,7 +122,7 @@ public class EGLContext extends GLContextImpl {
}
}
- EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getFactory();
+ EGLDrawableFactory factory = (EGLDrawableFactory) drawable.getFactory();
boolean isGLES2 = EGLDrawableFactory.PROFILE_GLES2.equals(factory.getProfile());
int[] contextAttrs = null;
// FIXME: need to determine whether to specify the context
diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java
index 8ac790157..0227ba32f 100755
--- a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -35,12 +35,11 @@
package com.sun.opengl.impl.egl;
+import com.sun.opengl.impl.GLDrawableImpl;
+
import javax.media.opengl.*;
-public class EGLDrawable implements GLDrawable {
- private long windowHandle;
- private long screenHandle;
- private long displayHandle;
+public class EGLDrawable extends GLDrawableImpl {
private long display;
private GLCapabilities capabilities;
private GLCapabilitiesChooser chooser;
@@ -48,21 +47,16 @@ public class EGLDrawable implements GLDrawable {
private long surface;
private int[] tmp = new int[1];
- public EGLDrawable(long displayHandle,
- long screenHandle,
- long windowHandle,
+ public EGLDrawable(EGLDrawableFactory factory,
+ NativeWindow component,
GLCapabilities capabilities,
GLCapabilitiesChooser chooser) throws GLException {
- this.displayHandle = displayHandle;
- this.screenHandle = screenHandle;
- this.windowHandle = windowHandle;
+ this.factory = factory;
+ this.component = component;
this.capabilities = capabilities;
this.chooser = chooser;
- // Set things up
- EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getFactory();
-
- display = EGL.eglGetDisplay((displayHandle>0)?displayHandle:EGL.EGL_DEFAULT_DISPLAY);
+ display = EGL.eglGetDisplay((component.getDisplayHandle()>0)?component.getDisplayHandle():EGL.EGL_DEFAULT_DISPLAY);
if (display == EGL.EGL_NO_DISPLAY) {
throw new GLException("eglGetDisplay failed");
}
@@ -108,7 +102,7 @@ public class EGLDrawable implements GLDrawable {
public void setRealized(boolean realized) {
if (realized) {
// Create the window surface
- surface = EGL.eglCreateWindowSurface(display, config, windowHandle, null);
+ surface = EGL.eglCreateWindowSurface(display, config, component.getWindowHandle(), null);
if (surface == EGL.EGL_NO_SURFACE) {
throw new GLException("Creation of window surface (eglCreateWindowSurface) failed");
}
@@ -153,9 +147,9 @@ public class EGLDrawable implements GLDrawable {
}
public String toString() {
- return "EGLDrawable[ displayHandle " + displayHandle +
- ", screenHandle "+ screenHandle +
- ", windowHandle "+ windowHandle +
+ return "EGLDrawable[ displayHandle " + component.getDisplayHandle() +
+ ", screenHandle "+ component.getScreenHandle() +
+ ", windowHandle "+ component.getWindowHandle() +
", display " + display +
", config " + config +
", surface " + surface +
diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
index 516f6d5a9..bd0f83a3c 100755
--- a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -102,17 +102,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
return null;
}
- public GLDrawable getGLDrawable(Object target,
+ public GLDrawable createGLDrawable(NativeWindow target,
GLCapabilities capabilities,
GLCapabilitiesChooser chooser) {
- if( !(target instanceof long[]) ) {
- throw new GLException("target is not instanceof long[]");
- }
- long[] targetHandles = (long[])target;
- if(targetHandles.length!=3) {
- throw new GLException("target handle array != 3 [display, screen, window]");
- }
- return new EGLDrawable(targetHandles[0], targetHandles[1], targetHandles[2],
+ return new EGLDrawable(this, target,
capabilities,
chooser);
}
diff --git a/src/classes/com/sun/opengl/impl/macosx/awt/MacOSXJAWTWindow.java b/src/classes/com/sun/opengl/impl/macosx/awt/MacOSXJAWTWindow.java
new file mode 100644
index 000000000..5f676a138
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/macosx/awt/MacOSXJAWTWindow.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.impl.macosx.awt;
+
+import com.sun.opengl.impl.macosx.*;
+import com.sun.opengl.impl.awt.*;
+
+import javax.media.opengl.*;
+import com.sun.opengl.impl.*;
+
+public class MacOSXJAWTWindow extends JAWTWindow {
+
+ // Variables for lockSurface/unlockSurface
+ //private JAWT_DrawingSurface ds;
+ //private JAWT_DrawingSurfaceInfo dsi;
+ //private JAWT_MacOSXDrawingSurfaceInfo x11dsi;
+
+ public MacOSXJAWTWindow(Object comp) {
+ super(comp);
+ }
+
+ public int lockSurface() throws NativeWindowException {
+ super.lockSurface();
+ return 0;
+ }
+
+ public void unlockSurface() {
+ super.unlockSurface();
+ }
+}
+
diff --git a/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java
index ddccfda4f..1ce39ed33 100644
--- a/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java
@@ -70,7 +70,7 @@ public class WindowsGLDrawableFactory extends GLDrawableFactoryImpl {
return null;
}
- public GLDrawable getGLDrawable(Object target,
+ public GLDrawable createGLDrawable(NativeWindow target,
GLCapabilities capabilities,
GLCapabilitiesChooser chooser) {
if (target == null) {
@@ -86,7 +86,7 @@ public class WindowsGLDrawableFactory extends GLDrawableFactoryImpl {
if (chooser == null) {
chooser = new DefaultGLCapabilitiesChooser();
}
- return new WindowsOnscreenGLDrawable((Component) target, capabilities, chooser);
+ return new WindowsOnscreenGLDrawable(getProfile(), target, capabilities, chooser);
}
public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
diff --git a/src/classes/com/sun/opengl/impl/windows/awt/WindowsJAWTWindow.java b/src/classes/com/sun/opengl/impl/windows/awt/WindowsJAWTWindow.java
new file mode 100644
index 000000000..68ef2702b
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/windows/awt/WindowsJAWTWindow.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.impl.windows.awt;
+
+import com.sun.opengl.impl.windows.*;
+import com.sun.opengl.impl.awt.*;
+
+import javax.media.opengl.*;
+import com.sun.opengl.impl.*;
+
+public class WindowsJAWTWindow extends JAWTWindow {
+
+ // Variables for lockSurface/unlockSurface
+ //private JAWT_DrawingSurface ds;
+ //private JAWT_DrawingSurfaceInfo dsi;
+ //private JAWT_WindowsDrawingSurfaceInfo x11dsi;
+
+ public WindowsJAWTWindow(Object comp) {
+ super(comp);
+ }
+
+ public int lockSurface() throws NativeWindowException {
+ super.lockSurface();
+ return 0;
+ }
+
+ public void unlockSurface() {
+ super.unlockSurface();
+ }
+}
+
diff --git a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java
index dcb9a0b37..1505e60d6 100644
--- a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java
@@ -39,11 +39,6 @@
package com.sun.opengl.impl.x11;
-import java.awt.Component;
-import java.awt.Graphics;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
import java.nio.*;
import java.security.*;
import java.util.*;
@@ -59,9 +54,6 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl {
// in this case
private static boolean isVendorATI;
- // See whether we're running in headless mode
- private static boolean isHeadless;
-
// Map for rediscovering the GLCapabilities associated with a
// particular screen and visualID after the fact
private static Map visualToGLCapsMap = Collections.synchronizedMap(new HashMap());
@@ -101,8 +93,6 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl {
com.sun.opengl.impl.NativeLibLoader.loadCore();
DRIHack.end();
-
- isHeadless = GraphicsEnvironment.isHeadless();
}
public X11GLDrawableFactory(String profile) {
@@ -117,134 +107,18 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl {
public AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
AbstractGraphicsDevice absDevice) {
- if (capabilities == null) {
- capabilities = new GLCapabilities();
- }
- if (chooser == null) {
- chooser = new DefaultGLCapabilitiesChooser();
- }
- GraphicsDevice device = null;
- if (absDevice != null &&
- !(absDevice instanceof AWTGraphicsDevice)) {
- throw new IllegalArgumentException("This GLDrawableFactory accepts only AWTGraphicsDevice objects");
- }
-
- if ((absDevice == null) ||
- (((AWTGraphicsDevice) absDevice).getGraphicsDevice() == null)) {
- device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
- } else {
- device = ((AWTGraphicsDevice) absDevice).getGraphicsDevice();
- }
-
- int screen;
- if (isXineramaEnabled()) {
- screen = 0;
- } else {
- screen = X11SunJDKReflection.graphicsDeviceGetScreen(device);
- }
-
- // Until we have a rock-solid visual selection algorithm written
- // in pure Java, we're going to provide the underlying window
- // system's selection to the chooser as a hint
-
- int[] attribs = glCapabilities2AttribList(capabilities, isMultisampleAvailable(), false, 0, 0);
- XVisualInfo[] infos = null;
- GLCapabilities[] caps = null;
- int recommendedIndex = -1;
- lockToolkit();
- try {
- long display = getDisplayConnection();
- XVisualInfo recommendedVis = GLX.glXChooseVisual(display, screen, attribs, 0);
- if (DEBUG) {
- System.err.print("!!! glXChooseVisual recommended ");
- if (recommendedVis == null) {
- System.err.println("null visual");
- } else {
- System.err.println("visual id 0x" + Long.toHexString(recommendedVis.visualid()));
- }
- }
- int[] count = new int[1];
- XVisualInfo template = XVisualInfo.create();
- template.screen(screen);
- infos = GLX.XGetVisualInfo(display, GLX.VisualScreenMask, template, count, 0);
- if (infos == null) {
- throw new GLException("Error while enumerating available XVisualInfos");
- }
- caps = new GLCapabilities[infos.length];
- for (int i = 0; i < infos.length; i++) {
- caps[i] = xvi2GLCapabilities(display, infos[i]);
- // Attempt to find the visual chosen by glXChooseVisual
- if (recommendedVis != null && recommendedVis.visualid() == infos[i].visualid()) {
- recommendedIndex = i;
- }
- }
- } finally {
- unlockToolkit();
- }
- // Store these away for later
- for (int i = 0; i < infos.length; i++) {
- if (caps[i] != null) {
- visualToGLCapsMap.put(new ScreenAndVisualIDKey(screen, infos[i].visualid()),
- caps[i].clone());
- }
- }
- int chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
- if (chosen < 0 || chosen >= caps.length) {
- throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
- }
- XVisualInfo vis = infos[chosen];
- if (vis == null) {
- throw new GLException("GLCapabilitiesChooser chose an invalid visual");
- }
- // FIXME: need to look at glue code and see type of this field
- long visualID = vis.visualid();
- // FIXME: the storage for the infos array, as well as that for the
- // recommended visual, is leaked; should free them here with XFree()
-
- // Now figure out which GraphicsConfiguration corresponds to this
- // visual by matching the visual ID
- GraphicsConfiguration[] configs = device.getConfigurations();
- for (int i = 0; i < configs.length; i++) {
- GraphicsConfiguration config = configs[i];
- if (config != null) {
- if (X11SunJDKReflection.graphicsConfigurationGetVisualID(config) == visualID) {
- return new AWTGraphicsConfiguration(config);
- }
- }
- }
-
- // Either we weren't able to reflectively introspect on the
- // X11GraphicsConfig or something went wrong in the steps above;
- // we're going to return null without signaling an error condition
- // in this case (although we should distinguish between the two
- // and possibly report more of an error in the latter case)
return null;
}
- public GLDrawable getGLDrawable(Object target,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser) {
+ public GLDrawable createGLDrawable(NativeWindow target,
+ GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- if (!(target instanceof Component)) {
- throw new IllegalArgumentException("GLDrawables not supported for objects of type " +
- target.getClass().getName() + " (only Components are supported in this implementation)");
- }
- Component comp = (Component) target;
- X11OnscreenGLDrawable drawable = new X11OnscreenGLDrawable(comp);
- // Figure out the GLCapabilities of this component
- GraphicsConfiguration config = comp.getGraphicsConfiguration();
- if (config == null) {
- throw new IllegalArgumentException("GLDrawableFactory.chooseGraphicsConfiguration() was not used when creating this Component");
- }
- int visualID = X11SunJDKReflection.graphicsConfigurationGetVisualID(config);
- int screen;
- if (isXineramaEnabled()) {
- screen = 0;
- } else {
- screen = X11SunJDKReflection.graphicsDeviceGetScreen(config.getDevice());
- }
+ X11OnscreenGLDrawable drawable = new X11OnscreenGLDrawable(getProfile(), target);
+ int visualID = target.getVisualID();
+ int screen = target.getScreenIndex();
drawable.setChosenGLCapabilities((GLCapabilities) visualToGLCapsMap.get(new ScreenAndVisualIDKey(screen, visualID)));
return drawable;
}
@@ -551,29 +425,9 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl {
}
public void lockToolkit() {
- if (isHeadless) {
- // Workaround for running (to some degree) in headless
- // environments but still supporting rendering via pbuffers
- // For full correctness, would need to implement a Lock class
- return;
- }
-
- if (!Java2D.isOGLPipelineActive() || !Java2D.isQueueFlusherThread()) {
- JAWT.getJAWT().Lock();
- }
}
public void unlockToolkit() {
- if (isHeadless) {
- // Workaround for running (to some degree) in headless
- // environments but still supporting rendering via pbuffers
- // For full correctness, would need to implement a Lock class
- return;
- }
-
- if (!Java2D.isOGLPipelineActive() || !Java2D.isQueueFlusherThread()) {
- JAWT.getJAWT().Unlock();
- }
}
public void lockAWTForJava2D() {
@@ -682,23 +536,6 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl {
throw new GLException("Unimplemented on this platform");
}
- //---------------------------------------------------------------------------
- // Xinerama-related functionality
- //
-
- private boolean checkedXinerama;
- private boolean xineramaEnabled;
- protected synchronized boolean isXineramaEnabled() {
- if (!checkedXinerama) {
- checkedXinerama = true;
- lockToolkit();
- long display = getDisplayConnection();
- xineramaEnabled = GLX.XineramaEnabled(display);
- unlockToolkit();
- }
- return xineramaEnabled;
- }
-
//----------------------------------------------------------------------
// Gamma-related functionality
//
diff --git a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java
index b1a3ebac7..6ee4d453e 100644
--- a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java
@@ -39,23 +39,12 @@
package com.sun.opengl.impl.x11;
-import java.awt.Component;
-
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
public class X11OnscreenGLDrawable extends X11GLDrawable {
- public static final int LOCK_SURFACE_NOT_READY = 1;
- public static final int LOCK_SURFACE_CHANGED = 2;
- public static final int LOCK_SUCCESS = 3;
-
- protected Component component;
+ protected NativeWindow component;
- // Variables for lockSurface/unlockSurface
- private JAWT_DrawingSurface ds;
- private JAWT_DrawingSurfaceInfo dsi;
- private JAWT_X11DrawingSurfaceInfo x11dsi;
-
// Indicates whether the component (if an onscreen context) has been
// realized. Plausibly, before the component is realized the JAWT
// should return an error or NULL object from some of its
@@ -68,7 +57,7 @@ public class X11OnscreenGLDrawable extends X11GLDrawable {
// addNotify() is called on the component.
protected boolean realized;
- public X11OnscreenGLDrawable(Component component) {
+ public X11OnscreenGLDrawable(NativeWindow component) {
super(null, null);
this.component = component;
}
@@ -98,7 +87,7 @@ public class X11OnscreenGLDrawable extends X11GLDrawable {
try {
boolean didLock = false;
- if (drawable == 0) {
+ if (component.getWindowHandle() == 0) {
if (lockSurface() == LOCK_SURFACE_NOT_READY) {
return;
}
@@ -106,7 +95,7 @@ public class X11OnscreenGLDrawable extends X11GLDrawable {
didLock = true;
}
- GLX.glXSwapBuffers(display, drawable);
+ GLX.glXSwapBuffers(component.getDisplayHandle(), component.getWindowHandle());
if (didLock) {
unlockSurface();
@@ -120,67 +109,10 @@ public class X11OnscreenGLDrawable extends X11GLDrawable {
if (!realized) {
return LOCK_SURFACE_NOT_READY;
}
- if (drawable != 0) {
- throw new GLException("Surface already locked");
- }
- ds = JAWT.getJAWT().GetDrawingSurface(component);
- if (ds == null) {
- // Widget not yet realized
- return LOCK_SURFACE_NOT_READY;
- }
- int res = ds.Lock();
- if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) {
- throw new GLException("Unable to lock surface");
- }
- // See whether the surface changed and if so destroy the old
- // OpenGL context so it will be recreated (NOTE: removeNotify
- // should handle this case, but it may be possible that race
- // conditions can cause this code to be triggered -- should test
- // more)
- int ret = LOCK_SUCCESS;
- if ((res & JAWTFactory.JAWT_LOCK_SURFACE_CHANGED) != 0) {
- ret = LOCK_SURFACE_CHANGED;
- }
- dsi = ds.GetDrawingSurfaceInfo();
- if (dsi == null) {
- // Widget not yet realized
- ds.Unlock();
- JAWT.getJAWT().FreeDrawingSurface(ds);
- ds = null;
- return LOCK_SURFACE_NOT_READY;
- }
- x11dsi = (JAWT_X11DrawingSurfaceInfo) dsi.platformInfo();
- display = x11dsi.display();
- drawable = x11dsi.drawable();
- visualID = x11dsi.visualID();
- if (display == 0 || drawable == 0) {
- // Widget not yet realized
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- JAWT.getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
- x11dsi = null;
- display = 0;
- drawable = 0;
- visualID = 0;
- return LOCK_SURFACE_NOT_READY;
- }
- return ret;
+ return component.lockSurface();
}
public void unlockSurface() {
- if (drawable == 0) {
- throw new GLException("Surface already unlocked");
- }
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- JAWT.getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
- x11dsi = null;
- display = 0;
- drawable = 0;
- visualID = 0;
+ return component.lockSurface();
}
}
diff --git a/src/classes/com/sun/opengl/impl/x11/awt/X11AWTGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/x11/awt/X11AWTGLDrawableFactory.java
new file mode 100644
index 000000000..de61d2315
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/x11/awt/X11AWTGLDrawableFactory.java
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.impl.x11.awt;
+
+import com.sun.opengl.impl.x11.*;
+import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.nio.*;
+import java.security.*;
+import java.util.*;
+import javax.media.opengl.*;
+import com.sun.gluegen.runtime.*;
+import com.sun.opengl.impl.*;
+
+public class X11AWTGLDrawableFactory extends X11GLDrawableFactory {
+ // See whether we're running in headless mode
+ private static boolean isHeadless;
+
+ static {
+ // See DRIHack.java for an explanation of why this is necessary
+ DRIHack.begin();
+
+ com.sun.opengl.impl.NativeLibLoader.loadCore();
+
+ DRIHack.end();
+
+ isHeadless = GraphicsEnvironment.isHeadless();
+ }
+
+ public AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
+ AbstractGraphicsDevice absDevice) {
+ if (capabilities == null) {
+ capabilities = new GLCapabilities();
+ }
+ if (chooser == null) {
+ chooser = new DefaultGLCapabilitiesChooser();
+ }
+ GraphicsDevice device = null;
+ if (absDevice != null &&
+ !(absDevice instanceof AWTGraphicsDevice)) {
+ throw new IllegalArgumentException("This GLDrawableFactory accepts only AWTGraphicsDevice objects");
+ }
+
+ if ((absDevice == null) ||
+ (((AWTGraphicsDevice) absDevice).getGraphicsDevice() == null)) {
+ device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
+ } else {
+ device = ((AWTGraphicsDevice) absDevice).getGraphicsDevice();
+ }
+
+ int screen;
+ if (isXineramaEnabled()) {
+ screen = 0;
+ } else {
+ screen = X11SunJDKReflection.graphicsDeviceGetScreen(device);
+ }
+
+ // Until we have a rock-solid visual selection algorithm written
+ // in pure Java, we're going to provide the underlying window
+ // system's selection to the chooser as a hint
+
+ int[] attribs = glCapabilities2AttribList(capabilities, isMultisampleAvailable(), false, 0, 0);
+ XVisualInfo[] infos = null;
+ GLCapabilities[] caps = null;
+ int recommendedIndex = -1;
+ lockToolkit();
+ try {
+ long display = getDisplayConnection();
+ XVisualInfo recommendedVis = GLX.glXChooseVisual(display, screen, attribs, 0);
+ if (DEBUG) {
+ System.err.print("!!! glXChooseVisual recommended ");
+ if (recommendedVis == null) {
+ System.err.println("null visual");
+ } else {
+ System.err.println("visual id 0x" + Long.toHexString(recommendedVis.visualid()));
+ }
+ }
+ int[] count = new int[1];
+ XVisualInfo template = XVisualInfo.create();
+ template.screen(screen);
+ infos = GLX.XGetVisualInfo(display, GLX.VisualScreenMask, template, count, 0);
+ if (infos == null) {
+ throw new GLException("Error while enumerating available XVisualInfos");
+ }
+ caps = new GLCapabilities[infos.length];
+ for (int i = 0; i < infos.length; i++) {
+ caps[i] = xvi2GLCapabilities(display, infos[i]);
+ // Attempt to find the visual chosen by glXChooseVisual
+ if (recommendedVis != null && recommendedVis.visualid() == infos[i].visualid()) {
+ recommendedIndex = i;
+ }
+ }
+ } finally {
+ unlockToolkit();
+ }
+ // Store these away for later
+ for (int i = 0; i < infos.length; i++) {
+ if (caps[i] != null) {
+ visualToGLCapsMap.put(new ScreenAndVisualIDKey(screen, infos[i].visualid()),
+ caps[i].clone());
+ }
+ }
+ int chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
+ if (chosen < 0 || chosen >= caps.length) {
+ throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
+ }
+ XVisualInfo vis = infos[chosen];
+ if (vis == null) {
+ throw new GLException("GLCapabilitiesChooser chose an invalid visual");
+ }
+ // FIXME: need to look at glue code and see type of this field
+ long visualID = vis.visualid();
+ // FIXME: the storage for the infos array, as well as that for the
+ // recommended visual, is leaked; should free them here with XFree()
+
+ // Now figure out which GraphicsConfiguration corresponds to this
+ // visual by matching the visual ID
+ GraphicsConfiguration[] configs = device.getConfigurations();
+ for (int i = 0; i < configs.length; i++) {
+ GraphicsConfiguration config = configs[i];
+ if (config != null) {
+ if (X11SunJDKReflection.graphicsConfigurationGetVisualID(config) == visualID) {
+ return new AWTGraphicsConfiguration(config);
+ }
+ }
+ }
+
+ // Either we weren't able to reflectively introspect on the
+ // X11GraphicsConfig or something went wrong in the steps above;
+ // we're going to return null without signaling an error condition
+ // in this case (although we should distinguish between the two
+ // and possibly report more of an error in the latter case)
+ return null;
+ }
+
+ public void lockToolkit() {
+ if (isHeadless) {
+ // Workaround for running (to some degree) in headless
+ // environments but still supporting rendering via pbuffers
+ // For full correctness, would need to implement a Lock class
+ return;
+ }
+
+ if (!Java2D.isOGLPipelineActive() || !Java2D.isQueueFlusherThread()) {
+ JAWT.getJAWT().Lock();
+ }
+ }
+
+ public void unlockToolkit() {
+ if (isHeadless) {
+ // Workaround for running (to some degree) in headless
+ // environments but still supporting rendering via pbuffers
+ // For full correctness, would need to implement a Lock class
+ return;
+ }
+
+ if (!Java2D.isOGLPipelineActive() || !Java2D.isQueueFlusherThread()) {
+ JAWT.getJAWT().Unlock();
+ }
+ }
+
+
+}
diff --git a/src/classes/com/sun/opengl/impl/x11/awt/X11JAWTWindow.java b/src/classes/com/sun/opengl/impl/x11/awt/X11JAWTWindow.java
new file mode 100644
index 000000000..2115f383d
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/x11/awt/X11JAWTWindow.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.impl.x11.awt;
+
+import com.sun.opengl.impl.x11.*;
+import com.sun.opengl.impl.awt.*;
+
+import javax.media.opengl.*;
+import com.sun.opengl.impl.*;
+
+public class X11JAWTWindow extends JAWTWindow {
+
+ // Variables for lockSurface/unlockSurface
+ private JAWT_DrawingSurface ds;
+ private JAWT_DrawingSurfaceInfo dsi;
+ private JAWT_X11DrawingSurfaceInfo x11dsi;
+
+ //---------------------------------------------------------------------------
+ // Xinerama-related functionality
+ //
+
+ private boolean checkedXinerama;
+ private boolean xineramaEnabled;
+ protected synchronized boolean isXineramaEnabled() {
+ if (!checkedXinerama) {
+ checkedXinerama = true;
+ lockToolkit();
+ long display = getDisplayConnection();
+ xineramaEnabled = GLX.XineramaEnabled(display);
+ unlockToolkit();
+ }
+ return xineramaEnabled;
+ }
+
+ public X11JAWTWindow(Object comp) {
+ super(comp);
+ }
+
+ public int lockSurface() throws NativeWindowException {
+ super.lockSurface();
+ ds = JAWT.getJAWT().GetDrawingSurface(component);
+ if (ds == null) {
+ // Widget not yet realized
+ return LOCK_SURFACE_NOT_READY;
+ }
+ int res = ds.Lock();
+ if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) {
+ throw new NativeWindowException("Unable to lock surface");
+ }
+ // See whether the surface changed and if so destroy the old
+ // OpenGL context so it will be recreated (NOTE: removeNotify
+ // should handle this case, but it may be possible that race
+ // conditions can cause this code to be triggered -- should test
+ // more)
+ int ret = LOCK_SUCCESS;
+ if ((res & JAWTFactory.JAWT_LOCK_SURFACE_CHANGED) != 0) {
+ ret = LOCK_SURFACE_CHANGED;
+ }
+ dsi = ds.GetDrawingSurfaceInfo();
+ if (dsi == null) {
+ // Widget not yet realized
+ ds.Unlock();
+ JAWT.getJAWT().FreeDrawingSurface(ds);
+ ds = null;
+ return LOCK_SURFACE_NOT_READY;
+ }
+ x11dsi = (JAWT_X11DrawingSurfaceInfo) dsi.platformInfo();
+ display = x11dsi.display();
+ drawable = x11dsi.drawable();
+ visualID = x11dsi.visualID();
+ screen= null;
+ if (isXineramaEnabled()) {
+ screenIndex = 0;
+ } else {
+ screenIndex = X11SunJDKReflection.graphicsDeviceGetScreen(config.getDevice());
+ }
+ if (display == 0 || drawable == 0) {
+ // Widget not yet realized
+ ds.FreeDrawingSurfaceInfo(dsi);
+ ds.Unlock();
+ JAWT.getJAWT().FreeDrawingSurface(ds);
+ ds = null;
+ dsi = null;
+ x11dsi = null;
+ display = 0;
+ drawable = 0;
+ visualID = 0;
+ screen= null;
+ screenIndex = -1;
+ return LOCK_SURFACE_NOT_READY;
+ }
+ return ret;
+ }
+
+ public void unlockSurface() {
+ super.unlockSurface();
+ ds.FreeDrawingSurfaceInfo(dsi);
+ ds.Unlock();
+ JAWT.getJAWT().FreeDrawingSurface(ds);
+ ds = null;
+ dsi = null;
+ x11dsi = null;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11SunJDKReflection.java b/src/classes/com/sun/opengl/impl/x11/awt/X11SunJDKReflection.java
index 0760399ab..5e19bfbb5 100644
--- a/src/classes/com/sun/opengl/impl/x11/X11SunJDKReflection.java
+++ b/src/classes/com/sun/opengl/impl/x11/awt/X11SunJDKReflection.java
@@ -37,7 +37,9 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.impl.x11;
+package com.sun.opengl.impl.x11.awt;
+
+import com.sun.opengl.impl.x11.*;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;