From f3bc93b003c05684e48d75eee9107c16a9dc7283 Mon Sep 17 00:00:00 2001
From: Michael Bien java -Djava.awt.headless=true demos.es2.RedSquare -GL2
* Single thread (MacOSX) java -XstartOnFirstThread -Djava.awt.headless=true demos.es2.RedSquare -GL2
* Multiple threads & windows (Unix, Win32) java -Djava.awt.headless=true demos.es2.RedSquare -GL2 -GL2 -GL2 -GL2
-* Multiple threads & windows (MacOSX) java -XstartOnFirstThread -Djava.awt.headless=true com.sun.javafx.newt.util.MainThread demos.es2.RedSquare -GL2 -GL2 -GL2 -GL2
+* Multiple threads & windows (MacOSX) java -XstartOnFirstThread -Djava.awt.headless=true com.jogamp.javafx.newt.util.MainThread demos.es2.RedSquare -GL2 -GL2 -GL2 -GL2
-The serialization of the main Java class through ''com.sun.javafx.newt.util.MainThread''
+The serialization of the main Java class through ''com.jogamp.javafx.newt.util.MainThread''
may be used for all platforms, since it only takes effect on ''MacOSX''.
This allows you an almost platform independent invocation of your multithreaded Java applications.
-On ''MacOSX'', ''com.sun.javafx.newt.util.MainThread'' will occupy the main thread and
+On ''MacOSX'', ''com.jogamp.javafx.newt.util.MainThread'' will occupy the main thread and
serializes all native window related tasks through it.
This mechanism is thread safe utilizes reentrant locking.
diff --git a/doxygen/doxygen-all-dev.cfg b/doxygen/doxygen-all-dev.cfg
index 2425ff403..d047e7182 100644
--- a/doxygen/doxygen-all-dev.cfg
+++ b/doxygen/doxygen-all-dev.cfg
@@ -465,7 +465,7 @@ INPUT = ../src/newt/classes
INPUT += ../build/jogl/gensrc/classes
INPUT += ../build/nativewindow/gensrc/classes
INPUT += ../build/newt/gensrc/classes
-INPUT += ../../gluegen/src/java/com/sun/gluegen/runtime
+INPUT += ../../gluegen/src/java/com/jogamp/gluegen/runtime
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
diff --git a/doxygen/doxygen-all-pub.cfg b/doxygen/doxygen-all-pub.cfg
index 3cac3e651..a7f4711df 100644
--- a/doxygen/doxygen-all-pub.cfg
+++ b/doxygen/doxygen-all-pub.cfg
@@ -462,7 +462,7 @@ WARN_LOGFILE =
INPUT = ../src/jogl/classes/javax
INPUT += ../build-x86_64/jogl/gensrc/classes/javax
INPUT += ../src/jogl/classes/com/jogamp/opengl/util
-INPUT += ../src/newt/classes/com/sun/javafx/newt
+INPUT += ../src/newt/classes/com/jogamp/javafx/newt
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
diff --git a/make/build-jogl.xml b/make/build-jogl.xml
index 80b106467..c3bc96bd8 100644
--- a/make/build-jogl.xml
+++ b/make/build-jogl.xml
@@ -114,7 +114,7 @@
value="com/jogamp/opengl/impl/glu/gl2/** com/jogamp/opengl/impl/glu/nurbs/** com/jogamp/opengl/impl/glu/registry/** javax/media/opengl/glu/gl2/**"/>
limit() - position()
) in the passed ByteBuffer into
+ a newly-allocated direct ByteBuffer. The returned buffer will
+ have its byte order set to the host platform's native byte
+ order. The position of the newly-allocated buffer will be zero,
+ and the position of the passed buffer is unchanged (though its
+ mark is changed). */
+ public static ByteBuffer copyByteBuffer(ByteBuffer orig) {
+ ByteBuffer dest = newByteBuffer(orig.remaining());
+ dest.put(orig);
+ dest.rewind();
+ return dest;
+ }
+
+ //----------------------------------------------------------------------
+ // Conversion routines
+ //
+
+ public static ByteBuffer nativeOrder(ByteBuffer buf) {
+ if (!isCDCFP) {
+ try {
+ if (byteOrderClass == null) {
+ byteOrderClass = Class.forName("java.nio.ByteOrder");
+ orderMethod = ByteBuffer.class.getMethod("order", new Class[] { byteOrderClass });
+ Method nativeOrderMethod = byteOrderClass.getMethod("nativeOrder", null);
+ nativeOrderObject = nativeOrderMethod.invoke(null, null);
+ }
+ } catch (Throwable t) {
+ // Must be running on CDC / FP
+ isCDCFP = true;
+ }
+
+ if (!isCDCFP) {
+ try {
+ orderMethod.invoke(buf, new Object[] { nativeOrderObject });
+ } catch (Throwable t) {
+ }
+ }
+ }
+ return buf;
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only below this point
+ //
+
+ // NOTE that this work must be done reflectively at the present time
+ // because this code must compile and run correctly on both CDC/FP and J2SE
+ private static boolean isCDCFP;
+ private static Class byteOrderClass;
+ private static Object nativeOrderObject;
+ private static Method orderMethod;
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/LockingNativeWindowFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/LockingNativeWindowFactory.java
new file mode 100644
index 000000000..fd2478ab2
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/LockingNativeWindowFactory.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2009 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.jogamp.nativewindow.impl;
+
+import javax.media.nativewindow.*;
+
+public class LockingNativeWindowFactory extends NativeWindowFactoryImpl {
+ // Provides a generic basic and recursive locking mechanism for your discretion.
+ private ToolkitLock toolkitLock = new ToolkitLock() {
+ private Thread owner;
+ private int recursionCount;
+
+ public synchronized void lock() {
+ Thread cur = Thread.currentThread();
+ if (owner == cur) {
+ ++recursionCount;
+ return;
+ }
+ while (owner != null) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ owner = cur;
+ }
+
+ public synchronized void unlock() {
+ if (owner != Thread.currentThread()) {
+ throw new RuntimeException("Not owner");
+ }
+ if (recursionCount > 0) {
+ --recursionCount;
+ return;
+ }
+ owner = null;
+ notifyAll();
+ }
+ };
+
+ public ToolkitLock getToolkitLock() {
+ return toolkitLock;
+ }
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NWReflection.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/NWReflection.java
new file mode 100644
index 000000000..22bdedac9
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/NWReflection.java
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+
+package com.jogamp.nativewindow.impl;
+
+import java.lang.reflect.*;
+import javax.media.nativewindow.*;
+
+public final class NWReflection {
+ public static final boolean DEBUG = Debug.debug("NWReflection");
+
+ public static final boolean isClassAvailable(String clazzName) {
+ try {
+ Class clazz = Class.forName(clazzName, false, NWReflection.class.getClassLoader());
+ return null!=clazz;
+ } catch (Throwable e) { }
+ return false;
+ }
+
+ public static final Class getClass(String clazzName, boolean initialize) {
+ try {
+ return Class.forName(clazzName, initialize, NWReflection.class.getClassLoader());
+ } catch (Throwable e) { }
+ return null;
+ }
+
+ public static final Constructor getConstructor(String clazzName, Class[] cstrArgTypes) {
+ Class factoryClass = null;
+ Constructor factory = null;
+
+ try {
+ factoryClass = getClass(clazzName, true);
+ if (factoryClass == null) {
+ throw new NativeWindowException(clazzName + " not available");
+ }
+ return getConstructor(factoryClass, cstrArgTypes);
+ } catch (Throwable e) {
+ if (DEBUG) {
+ e.printStackTrace();
+ }
+ throw new NativeWindowException(e);
+ }
+ }
+
+ public static final Constructor getConstructor(Class clazz, Class[] cstrArgTypes) {
+ Constructor factory = null;
+
+ try {
+ try {
+ factory = clazz.getDeclaredConstructor( cstrArgTypes );
+ } catch(NoSuchMethodException nsme) {
+ throw new NativeWindowException("Constructor: '" + clazz + "("+cstrArgTypes+")' not found");
+ }
+ return factory;
+ } catch (Throwable e) {
+ if (DEBUG) {
+ e.printStackTrace();
+ }
+ throw new NativeWindowException(e);
+ }
+ }
+
+ public static final Constructor getConstructor(String clazzName) {
+ return getConstructor(clazzName, new Class[0]);
+ }
+
+ public static final Object createInstance(Class clazz, Class[] cstrArgTypes, Object[] cstrArgs) {
+ Constructor factory = null;
+
+ try {
+ factory = getConstructor(clazz, cstrArgTypes);
+ return factory.newInstance( cstrArgs ) ;
+ } catch (Exception e) {
+ throw new NativeWindowException(e);
+ }
+ }
+
+ public static final Object createInstance(Class clazz, Object[] cstrArgs) {
+ Class[] cstrArgTypes = new Class[cstrArgs.length];
+ for(int i=0; ilimit() - position()
) in the passed ByteBuffer into
- a newly-allocated direct ByteBuffer. The returned buffer will
- have its byte order set to the host platform's native byte
- order. The position of the newly-allocated buffer will be zero,
- and the position of the passed buffer is unchanged (though its
- mark is changed). */
- public static ByteBuffer copyByteBuffer(ByteBuffer orig) {
- ByteBuffer dest = newByteBuffer(orig.remaining());
- dest.put(orig);
- dest.rewind();
- return dest;
- }
-
- //----------------------------------------------------------------------
- // Conversion routines
- //
-
- public static ByteBuffer nativeOrder(ByteBuffer buf) {
- if (!isCDCFP) {
- try {
- if (byteOrderClass == null) {
- byteOrderClass = Class.forName("java.nio.ByteOrder");
- orderMethod = ByteBuffer.class.getMethod("order", new Class[] { byteOrderClass });
- Method nativeOrderMethod = byteOrderClass.getMethod("nativeOrder", null);
- nativeOrderObject = nativeOrderMethod.invoke(null, null);
- }
- } catch (Throwable t) {
- // Must be running on CDC / FP
- isCDCFP = true;
- }
-
- if (!isCDCFP) {
- try {
- orderMethod.invoke(buf, new Object[] { nativeOrderObject });
- } catch (Throwable t) {
- }
- }
- }
- return buf;
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- // NOTE that this work must be done reflectively at the present time
- // because this code must compile and run correctly on both CDC/FP and J2SE
- private static boolean isCDCFP;
- private static Class byteOrderClass;
- private static Object nativeOrderObject;
- private static Method orderMethod;
-}
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/LockingNativeWindowFactory.java b/src/nativewindow/classes/com/sun/nativewindow/impl/LockingNativeWindowFactory.java
deleted file mode 100644
index 880fd8c7d..000000000
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/LockingNativeWindowFactory.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2009 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.nativewindow.impl;
-
-import javax.media.nativewindow.*;
-
-public class LockingNativeWindowFactory extends NativeWindowFactoryImpl {
- // Provides a generic basic and recursive locking mechanism for your discretion.
- private ToolkitLock toolkitLock = new ToolkitLock() {
- private Thread owner;
- private int recursionCount;
-
- public synchronized void lock() {
- Thread cur = Thread.currentThread();
- if (owner == cur) {
- ++recursionCount;
- return;
- }
- while (owner != null) {
- try {
- wait();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- owner = cur;
- }
-
- public synchronized void unlock() {
- if (owner != Thread.currentThread()) {
- throw new RuntimeException("Not owner");
- }
- if (recursionCount > 0) {
- --recursionCount;
- return;
- }
- owner = null;
- notifyAll();
- }
- };
-
- public ToolkitLock getToolkitLock() {
- return toolkitLock;
- }
-}
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java
deleted file mode 100644
index d86fbdc55..000000000
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.nativewindow.impl;
-
-import java.lang.reflect.*;
-import javax.media.nativewindow.*;
-
-public final class NWReflection {
- public static final boolean DEBUG = Debug.debug("NWReflection");
-
- public static final boolean isClassAvailable(String clazzName) {
- try {
- Class clazz = Class.forName(clazzName, false, NWReflection.class.getClassLoader());
- return null!=clazz;
- } catch (Throwable e) { }
- return false;
- }
-
- public static final Class getClass(String clazzName, boolean initialize) {
- try {
- return Class.forName(clazzName, initialize, NWReflection.class.getClassLoader());
- } catch (Throwable e) { }
- return null;
- }
-
- public static final Constructor getConstructor(String clazzName, Class[] cstrArgTypes) {
- Class factoryClass = null;
- Constructor factory = null;
-
- try {
- factoryClass = getClass(clazzName, true);
- if (factoryClass == null) {
- throw new NativeWindowException(clazzName + " not available");
- }
- return getConstructor(factoryClass, cstrArgTypes);
- } catch (Throwable e) {
- if (DEBUG) {
- e.printStackTrace();
- }
- throw new NativeWindowException(e);
- }
- }
-
- public static final Constructor getConstructor(Class clazz, Class[] cstrArgTypes) {
- Constructor factory = null;
-
- try {
- try {
- factory = clazz.getDeclaredConstructor( cstrArgTypes );
- } catch(NoSuchMethodException nsme) {
- throw new NativeWindowException("Constructor: '" + clazz + "("+cstrArgTypes+")' not found");
- }
- return factory;
- } catch (Throwable e) {
- if (DEBUG) {
- e.printStackTrace();
- }
- throw new NativeWindowException(e);
- }
- }
-
- public static final Constructor getConstructor(String clazzName) {
- return getConstructor(clazzName, new Class[0]);
- }
-
- public static final Object createInstance(Class clazz, Class[] cstrArgTypes, Object[] cstrArgs) {
- Constructor factory = null;
-
- try {
- factory = getConstructor(clazz, cstrArgTypes);
- return factory.newInstance( cstrArgs ) ;
- } catch (Exception e) {
- throw new NativeWindowException(e);
- }
- }
-
- public static final Object createInstance(Class clazz, Object[] cstrArgs) {
- Class[] cstrArgTypes = new Class[cstrArgs.length];
- for(int i=0; iInsets
object with the
+ * specified top, left, bottom, and right insets.
+ * @param top the inset from the top.
+ * @param left the inset from the left.
+ * @param bottom the inset from the bottom.
+ * @param right the inset from the right.
+ */
+ public Insets(int top, int left, int bottom, int right) {
+ this.top = top;
+ this.left = left;
+ this.bottom = bottom;
+ this.right = right;
+ }
+
+ /**
+ * Checks whether two insets objects are equal. Two instances
+ * of Insets
are equal if the four integer values
+ * of the fields top
, left
,
+ * bottom
, and right
are all equal.
+ * @return true
if the two insets are equal;
+ * otherwise false
.
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof Insets) {
+ Insets insets = (Insets)obj;
+ return ((top == insets.top) && (left == insets.left) &&
+ (bottom == insets.bottom) && (right == insets.right));
+ }
+ return false;
+ }
+
+ /**
+ * Returns the hash code for this Insets.
+ *
+ * @return a hash code for this Insets.
+ */
+ public int hashCode() {
+ int sum1 = left + bottom;
+ int sum2 = right + top;
+ int val1 = sum1 * (sum1 + 1)/2 + left;
+ int val2 = sum2 * (sum2 + 1)/2 + top;
+ int sum3 = val1 + val2;
+ return sum3 * (sum3 + 1)/2 + val2;
+ }
+
+ public String toString() {
+ return getClass().getName() + "[top=" + top + ",left=" + left +
+ ",bottom=" + bottom + ",right=" + right + "]";
+ }
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException ex) {
+ throw new InternalError();
+ }
+ }
+
+}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/KeyEvent.java b/src/newt/classes/com/jogamp/javafx/newt/KeyEvent.java
new file mode 100644
index 000000000..8ae92464c
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/KeyEvent.java
@@ -0,0 +1,738 @@
+/*
+ * 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.jogamp.javafx.newt;
+
+public class KeyEvent extends InputEvent
+{
+ KeyEvent(boolean sysEvent, int eventType, Window source, long when, int modifiers, int keyCode, char keyChar) {
+ super(sysEvent, eventType, source, when, modifiers);
+ this.keyCode=keyCode;
+ this.keyChar=keyChar;
+ }
+ public KeyEvent(int eventType, Window source, long when, int modifiers, int keyCode, char keyChar) {
+ this(false, eventType, source, when, modifiers, keyCode, keyChar);
+ }
+
+ public char getKeyChar() {
+ return keyChar;
+ }
+ public int getKeyCode() {
+ return keyCode;
+ }
+
+ public String toString() {
+ return "KeyEvent["+getEventTypeString(getEventType())+
+ ", code "+keyCode+"("+toHexString(keyCode)+"), char <"+keyChar+"> ("+toHexString((int)keyChar)+"), isActionKey "+isActionKey()+", "+super.toString()+"]";
+ }
+
+ public static String getEventTypeString(int type) {
+ switch(type) {
+ case EVENT_KEY_PRESSED: return "EVENT_KEY_PRESSED";
+ case EVENT_KEY_RELEASED: return "EVENT_KEY_RELEASED";
+ case EVENT_KEY_TYPED: return "EVENT_KEY_TYPED";
+ default: return "unknown (" + type + ")";
+ }
+ }
+
+ public boolean isActionKey() {
+ switch (keyCode) {
+ case VK_HOME:
+ case VK_END:
+ case VK_PAGE_UP:
+ case VK_PAGE_DOWN:
+ case VK_UP:
+ case VK_DOWN:
+ case VK_LEFT:
+ case VK_RIGHT:
+
+ case VK_F1:
+ case VK_F2:
+ case VK_F3:
+ case VK_F4:
+ case VK_F5:
+ case VK_F6:
+ case VK_F7:
+ case VK_F8:
+ case VK_F9:
+ case VK_F10:
+ case VK_F11:
+ case VK_F12:
+ case VK_F13:
+ case VK_F14:
+ case VK_F15:
+ case VK_F16:
+ case VK_F17:
+ case VK_F18:
+ case VK_F19:
+ case VK_F20:
+ case VK_F21:
+ case VK_F22:
+ case VK_F23:
+ case VK_F24:
+ case VK_PRINTSCREEN:
+ case VK_CAPS_LOCK:
+ case VK_PAUSE:
+ case VK_INSERT:
+
+ case VK_HELP:
+ case VK_WINDOWS:
+ return true;
+ }
+ return false;
+ }
+
+ private int keyCode;
+ private char keyChar;
+
+ public static final int EVENT_KEY_PRESSED = 300;
+ public static final int EVENT_KEY_RELEASED= 301;
+ public static final int EVENT_KEY_TYPED = 302;
+
+ /* Virtual key codes. */
+
+ public static final int VK_ENTER = '\n';
+ public static final int VK_BACK_SPACE = '\b';
+ public static final int VK_TAB = '\t';
+ public static final int VK_CANCEL = 0x03;
+ public static final int VK_CLEAR = 0x0C;
+ public static final int VK_SHIFT = 0x10;
+ public static final int VK_CONTROL = 0x11;
+ public static final int VK_ALT = 0x12;
+ public static final int VK_PAUSE = 0x13;
+ public static final int VK_CAPS_LOCK = 0x14;
+ public static final int VK_ESCAPE = 0x1B;
+ public static final int VK_SPACE = 0x20;
+ public static final int VK_PAGE_UP = 0x21;
+ public static final int VK_PAGE_DOWN = 0x22;
+ public static final int VK_END = 0x23;
+ public static final int VK_HOME = 0x24;
+
+ /**
+ * Constant for the non-numpad left arrow key.
+ * @see #VK_KP_LEFT
+ */
+ public static final int VK_LEFT = 0x25;
+
+ /**
+ * Constant for the non-numpad up arrow key.
+ * @see #VK_KP_UP
+ */
+ public static final int VK_UP = 0x26;
+
+ /**
+ * Constant for the non-numpad right arrow key.
+ * @see #VK_KP_RIGHT
+ */
+ public static final int VK_RIGHT = 0x27;
+
+ /**
+ * Constant for the non-numpad down arrow key.
+ * @see #VK_KP_DOWN
+ */
+ public static final int VK_DOWN = 0x28;
+
+ /**
+ * Constant for the comma key, ","
+ */
+ public static final int VK_COMMA = 0x2C;
+
+ /**
+ * Constant for the minus key, "-"
+ * @since 1.2
+ */
+ public static final int VK_MINUS = 0x2D;
+
+ /**
+ * Constant for the period key, "."
+ */
+ public static final int VK_PERIOD = 0x2E;
+
+ /**
+ * Constant for the forward slash key, "/"
+ */
+ public static final int VK_SLASH = 0x2F;
+
+ /** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
+ public static final int VK_0 = 0x30;
+ public static final int VK_1 = 0x31;
+ public static final int VK_2 = 0x32;
+ public static final int VK_3 = 0x33;
+ public static final int VK_4 = 0x34;
+ public static final int VK_5 = 0x35;
+ public static final int VK_6 = 0x36;
+ public static final int VK_7 = 0x37;
+ public static final int VK_8 = 0x38;
+ public static final int VK_9 = 0x39;
+
+ /**
+ * Constant for the semicolon key, ";"
+ */
+ public static final int VK_SEMICOLON = 0x3B;
+
+ /**
+ * Constant for the equals key, "="
+ */
+ public static final int VK_EQUALS = 0x3D;
+
+ /** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
+ public static final int VK_A = 0x41;
+ public static final int VK_B = 0x42;
+ public static final int VK_C = 0x43;
+ public static final int VK_D = 0x44;
+ public static final int VK_E = 0x45;
+ public static final int VK_F = 0x46;
+ public static final int VK_G = 0x47;
+ public static final int VK_H = 0x48;
+ public static final int VK_I = 0x49;
+ public static final int VK_J = 0x4A;
+ public static final int VK_K = 0x4B;
+ public static final int VK_L = 0x4C;
+ public static final int VK_M = 0x4D;
+ public static final int VK_N = 0x4E;
+ public static final int VK_O = 0x4F;
+ public static final int VK_P = 0x50;
+ public static final int VK_Q = 0x51;
+ public static final int VK_R = 0x52;
+ public static final int VK_S = 0x53;
+ public static final int VK_T = 0x54;
+ public static final int VK_U = 0x55;
+ public static final int VK_V = 0x56;
+ public static final int VK_W = 0x57;
+ public static final int VK_X = 0x58;
+ public static final int VK_Y = 0x59;
+ public static final int VK_Z = 0x5A;
+
+ /**
+ * Constant for the open bracket key, "["
+ */
+ public static final int VK_OPEN_BRACKET = 0x5B;
+
+ /**
+ * Constant for the back slash key, "\"
+ */
+ public static final int VK_BACK_SLASH = 0x5C;
+
+ /**
+ * Constant for the close bracket key, "]"
+ */
+ public static final int VK_CLOSE_BRACKET = 0x5D;
+
+ public static final int VK_NUMPAD0 = 0x60;
+ public static final int VK_NUMPAD1 = 0x61;
+ public static final int VK_NUMPAD2 = 0x62;
+ public static final int VK_NUMPAD3 = 0x63;
+ public static final int VK_NUMPAD4 = 0x64;
+ public static final int VK_NUMPAD5 = 0x65;
+ public static final int VK_NUMPAD6 = 0x66;
+ public static final int VK_NUMPAD7 = 0x67;
+ public static final int VK_NUMPAD8 = 0x68;
+ public static final int VK_NUMPAD9 = 0x69;
+ public static final int VK_MULTIPLY = 0x6A;
+ public static final int VK_ADD = 0x6B;
+
+ /**
+ * This constant is obsolete, and is included only for backwards
+ * compatibility.
+ * @see #VK_SEPARATOR
+ */
+ public static final int VK_SEPARATER = 0x6C;
+
+ /**
+ * Constant for the Numpad Separator key.
+ * @since 1.4
+ */
+ public static final int VK_SEPARATOR = VK_SEPARATER;
+
+ public static final int VK_SUBTRACT = 0x6D;
+ public static final int VK_DECIMAL = 0x6E;
+ public static final int VK_DIVIDE = 0x6F;
+ public static final int VK_DELETE = 0x7F; /* ASCII DEL */
+ public static final int VK_NUM_LOCK = 0x90;
+ public static final int VK_SCROLL_LOCK = 0x91;
+
+ /** Constant for the F1 function key. */
+ public static final int VK_F1 = 0x70;
+
+ /** Constant for the F2 function key. */
+ public static final int VK_F2 = 0x71;
+
+ /** Constant for the F3 function key. */
+ public static final int VK_F3 = 0x72;
+
+ /** Constant for the F4 function key. */
+ public static final int VK_F4 = 0x73;
+
+ /** Constant for the F5 function key. */
+ public static final int VK_F5 = 0x74;
+
+ /** Constant for the F6 function key. */
+ public static final int VK_F6 = 0x75;
+
+ /** Constant for the F7 function key. */
+ public static final int VK_F7 = 0x76;
+
+ /** Constant for the F8 function key. */
+ public static final int VK_F8 = 0x77;
+
+ /** Constant for the F9 function key. */
+ public static final int VK_F9 = 0x78;
+
+ /** Constant for the F10 function key. */
+ public static final int VK_F10 = 0x79;
+
+ /** Constant for the F11 function key. */
+ public static final int VK_F11 = 0x7A;
+
+ /** Constant for the F12 function key. */
+ public static final int VK_F12 = 0x7B;
+
+ /**
+ * Constant for the F13 function key.
+ * @since 1.2
+ */
+ /* F13 - F24 are used on IBM 3270 keyboard; use random range for constants. */
+ public static final int VK_F13 = 0xF000;
+
+ /**
+ * Constant for the F14 function key.
+ * @since 1.2
+ */
+ public static final int VK_F14 = 0xF001;
+
+ /**
+ * Constant for the F15 function key.
+ * @since 1.2
+ */
+ public static final int VK_F15 = 0xF002;
+
+ /**
+ * Constant for the F16 function key.
+ * @since 1.2
+ */
+ public static final int VK_F16 = 0xF003;
+
+ /**
+ * Constant for the F17 function key.
+ * @since 1.2
+ */
+ public static final int VK_F17 = 0xF004;
+
+ /**
+ * Constant for the F18 function key.
+ * @since 1.2
+ */
+ public static final int VK_F18 = 0xF005;
+
+ /**
+ * Constant for the F19 function key.
+ * @since 1.2
+ */
+ public static final int VK_F19 = 0xF006;
+
+ /**
+ * Constant for the F20 function key.
+ * @since 1.2
+ */
+ public static final int VK_F20 = 0xF007;
+
+ /**
+ * Constant for the F21 function key.
+ * @since 1.2
+ */
+ public static final int VK_F21 = 0xF008;
+
+ /**
+ * Constant for the F22 function key.
+ * @since 1.2
+ */
+ public static final int VK_F22 = 0xF009;
+
+ /**
+ * Constant for the F23 function key.
+ * @since 1.2
+ */
+ public static final int VK_F23 = 0xF00A;
+
+ /**
+ * Constant for the F24 function key.
+ * @since 1.2
+ */
+ public static final int VK_F24 = 0xF00B;
+
+ public static final int VK_PRINTSCREEN = 0x9A;
+ public static final int VK_INSERT = 0x9B;
+ public static final int VK_HELP = 0x9C;
+ public static final int VK_META = 0x9D;
+
+ public static final int VK_BACK_QUOTE = 0xC0;
+ public static final int VK_QUOTE = 0xDE;
+
+ /**
+ * Constant for the numeric keypad up arrow key.
+ * @see #VK_UP
+ * @since 1.2
+ */
+ public static final int VK_KP_UP = 0xE0;
+
+ /**
+ * Constant for the numeric keypad down arrow key.
+ * @see #VK_DOWN
+ * @since 1.2
+ */
+ public static final int VK_KP_DOWN = 0xE1;
+
+ /**
+ * Constant for the numeric keypad left arrow key.
+ * @see #VK_LEFT
+ * @since 1.2
+ */
+ public static final int VK_KP_LEFT = 0xE2;
+
+ /**
+ * Constant for the numeric keypad right arrow key.
+ * @see #VK_RIGHT
+ * @since 1.2
+ */
+ public static final int VK_KP_RIGHT = 0xE3;
+
+ /* For European keyboards */
+ /** @since 1.2 */
+ public static final int VK_DEAD_GRAVE = 0x80;
+ /** @since 1.2 */
+ public static final int VK_DEAD_ACUTE = 0x81;
+ /** @since 1.2 */
+ public static final int VK_DEAD_CIRCUMFLEX = 0x82;
+ /** @since 1.2 */
+ public static final int VK_DEAD_TILDE = 0x83;
+ /** @since 1.2 */
+ public static final int VK_DEAD_MACRON = 0x84;
+ /** @since 1.2 */
+ public static final int VK_DEAD_BREVE = 0x85;
+ /** @since 1.2 */
+ public static final int VK_DEAD_ABOVEDOT = 0x86;
+ /** @since 1.2 */
+ public static final int VK_DEAD_DIAERESIS = 0x87;
+ /** @since 1.2 */
+ public static final int VK_DEAD_ABOVERING = 0x88;
+ /** @since 1.2 */
+ public static final int VK_DEAD_DOUBLEACUTE = 0x89;
+ /** @since 1.2 */
+ public static final int VK_DEAD_CARON = 0x8a;
+ /** @since 1.2 */
+ public static final int VK_DEAD_CEDILLA = 0x8b;
+ /** @since 1.2 */
+ public static final int VK_DEAD_OGONEK = 0x8c;
+ /** @since 1.2 */
+ public static final int VK_DEAD_IOTA = 0x8d;
+ /** @since 1.2 */
+ public static final int VK_DEAD_VOICED_SOUND = 0x8e;
+ /** @since 1.2 */
+ public static final int VK_DEAD_SEMIVOICED_SOUND = 0x8f;
+
+ /** @since 1.2 */
+ public static final int VK_AMPERSAND = 0x96;
+ /** @since 1.2 */
+ public static final int VK_ASTERISK = 0x97;
+ /** @since 1.2 */
+ public static final int VK_QUOTEDBL = 0x98;
+ /** @since 1.2 */
+ public static final int VK_LESS = 0x99;
+
+ /** @since 1.2 */
+ public static final int VK_GREATER = 0xa0;
+ /** @since 1.2 */
+ public static final int VK_BRACELEFT = 0xa1;
+ /** @since 1.2 */
+ public static final int VK_BRACERIGHT = 0xa2;
+
+ /**
+ * Constant for the "@" key.
+ * @since 1.2
+ */
+ public static final int VK_AT = 0x0200;
+
+ /**
+ * Constant for the ":" key.
+ * @since 1.2
+ */
+ public static final int VK_COLON = 0x0201;
+
+ /**
+ * Constant for the "^" key.
+ * @since 1.2
+ */
+ public static final int VK_CIRCUMFLEX = 0x0202;
+
+ /**
+ * Constant for the "$" key.
+ * @since 1.2
+ */
+ public static final int VK_DOLLAR = 0x0203;
+
+ /**
+ * Constant for the Euro currency sign key.
+ * @since 1.2
+ */
+ public static final int VK_EURO_SIGN = 0x0204;
+
+ /**
+ * Constant for the "!" key.
+ * @since 1.2
+ */
+ public static final int VK_EXCLAMATION_MARK = 0x0205;
+
+ /**
+ * Constant for the inverted exclamation mark key.
+ * @since 1.2
+ */
+ public static final int VK_INVERTED_EXCLAMATION_MARK = 0x0206;
+
+ /**
+ * Constant for the "(" key.
+ * @since 1.2
+ */
+ public static final int VK_LEFT_PARENTHESIS = 0x0207;
+
+ /**
+ * Constant for the "#" key.
+ * @since 1.2
+ */
+ public static final int VK_NUMBER_SIGN = 0x0208;
+
+ /**
+ * Constant for the "+" key.
+ * @since 1.2
+ */
+ public static final int VK_PLUS = 0x0209;
+
+ /**
+ * Constant for the ")" key.
+ * @since 1.2
+ */
+ public static final int VK_RIGHT_PARENTHESIS = 0x020A;
+
+ /**
+ * Constant for the "_" key.
+ * @since 1.2
+ */
+ public static final int VK_UNDERSCORE = 0x020B;
+
+ /**
+ * Constant for the Microsoft Windows "Windows" key.
+ * It is used for both the left and right version of the key.
+ * @see #getKeyLocation()
+ * @since 1.5
+ */
+ public static final int VK_WINDOWS = 0x020C;
+
+ /**
+ * Constant for the Microsoft Windows Context Menu key.
+ * @since 1.5
+ */
+ public static final int VK_CONTEXT_MENU = 0x020D;
+
+ /* for input method support on Asian Keyboards */
+
+ /* not clear what this means - listed in Microsoft Windows API */
+ public static final int VK_FINAL = 0x0018;
+
+ /** Constant for the Convert function key. */
+ /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */
+ public static final int VK_CONVERT = 0x001C;
+
+ /** Constant for the Don't Convert function key. */
+ /* Japanese PC 106 keyboard: muhenkan */
+ public static final int VK_NONCONVERT = 0x001D;
+
+ /** Constant for the Accept or Commit function key. */
+ /* Japanese Solaris keyboard: kakutei */
+ public static final int VK_ACCEPT = 0x001E;
+
+ /* not clear what this means - listed in Microsoft Windows API */
+ public static final int VK_MODECHANGE = 0x001F;
+
+ /* replaced by VK_KANA_LOCK for Microsoft Windows and Solaris;
+ might still be used on other platforms */
+ public static final int VK_KANA = 0x0015;
+
+ /* replaced by VK_INPUT_METHOD_ON_OFF for Microsoft Windows and Solaris;
+ might still be used for other platforms */
+ public static final int VK_KANJI = 0x0019;
+
+ /**
+ * Constant for the Alphanumeric function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: eisuu */
+ public static final int VK_ALPHANUMERIC = 0x00F0;
+
+ /**
+ * Constant for the Katakana function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: katakana */
+ public static final int VK_KATAKANA = 0x00F1;
+
+ /**
+ * Constant for the Hiragana function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: hiragana */
+ public static final int VK_HIRAGANA = 0x00F2;
+
+ /**
+ * Constant for the Full-Width Characters function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: zenkaku */
+ public static final int VK_FULL_WIDTH = 0x00F3;
+
+ /**
+ * Constant for the Half-Width Characters function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: hankaku */
+ public static final int VK_HALF_WIDTH = 0x00F4;
+
+ /**
+ * Constant for the Roman Characters function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: roumaji */
+ public static final int VK_ROMAN_CHARACTERS = 0x00F5;
+
+ /**
+ * Constant for the All Candidates function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */
+ public static final int VK_ALL_CANDIDATES = 0x0100;
+
+ /**
+ * Constant for the Previous Candidate function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */
+ public static final int VK_PREVIOUS_CANDIDATE = 0x0101;
+
+ /**
+ * Constant for the Code Input function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */
+ public static final int VK_CODE_INPUT = 0x0102;
+
+ /**
+ * Constant for the Japanese-Katakana function key.
+ * This key switches to a Japanese input method and selects its Katakana input mode.
+ * @since 1.2
+ */
+ /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */
+ public static final int VK_JAPANESE_KATAKANA = 0x0103;
+
+ /**
+ * Constant for the Japanese-Hiragana function key.
+ * This key switches to a Japanese input method and selects its Hiragana input mode.
+ * @since 1.2
+ */
+ /* Japanese Macintosh keyboard */
+ public static final int VK_JAPANESE_HIRAGANA = 0x0104;
+
+ /**
+ * Constant for the Japanese-Roman function key.
+ * This key switches to a Japanese input method and selects its Roman-Direct input mode.
+ * @since 1.2
+ */
+ /* Japanese Macintosh keyboard */
+ public static final int VK_JAPANESE_ROMAN = 0x0105;
+
+ /**
+ * Constant for the locking Kana function key.
+ * This key locks the keyboard into a Kana layout.
+ * @since 1.3
+ */
+ /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */
+ public static final int VK_KANA_LOCK = 0x0106;
+
+ /**
+ * Constant for the input method on/off key.
+ * @since 1.3
+ */
+ /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */
+ public static final int VK_INPUT_METHOD_ON_OFF = 0x0107;
+
+ /* for Sun keyboards */
+ /** @since 1.2 */
+ public static final int VK_CUT = 0xFFD1;
+ /** @since 1.2 */
+ public static final int VK_COPY = 0xFFCD;
+ /** @since 1.2 */
+ public static final int VK_PASTE = 0xFFCF;
+ /** @since 1.2 */
+ public static final int VK_UNDO = 0xFFCB;
+ /** @since 1.2 */
+ public static final int VK_AGAIN = 0xFFC9;
+ /** @since 1.2 */
+ public static final int VK_FIND = 0xFFD0;
+ /** @since 1.2 */
+ public static final int VK_PROPS = 0xFFCA;
+ /** @since 1.2 */
+ public static final int VK_STOP = 0xFFC8;
+
+ /**
+ * Constant for the Compose function key.
+ * @since 1.2
+ */
+ public static final int VK_COMPOSE = 0xFF20;
+
+ /**
+ * Constant for the AltGraph function key.
+ * @since 1.2
+ */
+ public static final int VK_ALT_GRAPH = 0xFF7E;
+
+ /**
+ * Constant for the Begin key.
+ * @since 1.5
+ */
+ public static final int VK_BEGIN = 0xFF58;
+
+ /**
+ * This value is used to indicate that the keyCode is unknown.
+ * KEY_TYPED events do not have a keyCode value; this value
+ * is used instead.
+ */
+ public static final int VK_UNDEFINED = 0x0;
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/KeyListener.java b/src/newt/classes/com/jogamp/javafx/newt/KeyListener.java
new file mode 100644
index 000000000..7921a0a97
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/KeyListener.java
@@ -0,0 +1,42 @@
+/*
+ * 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.jogamp.javafx.newt;
+
+public interface KeyListener extends EventListener
+{
+ public void keyPressed(KeyEvent e);
+ public void keyReleased(KeyEvent e);
+ public void keyTyped(KeyEvent e) ;
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/MouseEvent.java b/src/newt/classes/com/jogamp/javafx/newt/MouseEvent.java
new file mode 100644
index 000000000..82989e216
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/MouseEvent.java
@@ -0,0 +1,110 @@
+/*
+ * 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.jogamp.javafx.newt;
+
+public class MouseEvent extends InputEvent
+{
+ public static final int BUTTON1 = 1;
+ public static final int BUTTON2 = 2;
+ public static final int BUTTON3 = 3;
+ public static final int BUTTON4 = 4;
+ public static final int BUTTON5 = 5;
+ public static final int BUTTON6 = 6;
+ public static final int BUTTON_NUMBER = 6;
+
+ protected MouseEvent(boolean sysEvent, int eventType, Window source, long when,
+ int modifiers, int x, int y, int clickCount, int button,
+ int rotation)
+ {
+ super(sysEvent, eventType, source, when, modifiers);
+ this.x=x;
+ this.y=y;
+ this.clickCount=clickCount;
+ this.button=button;
+ this.wheelRotation = rotation;
+ }
+ public MouseEvent(int eventType, Window source, long when, int modifiers,
+ int x, int y, int clickCount, int button, int rotation) {
+ this(false, eventType, source, when, modifiers, x, y, clickCount, button,
+ rotation);
+ }
+
+ public int getButton() {
+ return button;
+ }
+ public int getClickCount() {
+ return clickCount;
+ }
+ public int getX() {
+ return x;
+ }
+ public int getY() {
+ return y;
+ }
+ public int getWheelRotation() {
+ return wheelRotation;
+ }
+
+ public String toString() {
+ return "MouseEvent["+getEventTypeString(getEventType())+
+ ", "+x+"/"+y+", button "+button+", count "+clickCount+
+ ", wheel rotation "+wheelRotation+
+ ", "+super.toString()+"]";
+ }
+
+ public static String getEventTypeString(int type) {
+ switch(type) {
+ case EVENT_MOUSE_CLICKED: return "EVENT_MOUSE_CLICKED";
+ case EVENT_MOUSE_ENTERED: return "EVENT_MOUSE_ENTERED";
+ case EVENT_MOUSE_EXITED: return "EVENT_MOUSE_EXITED";
+ case EVENT_MOUSE_PRESSED: return "EVENT_MOUSE_PRESSED";
+ case EVENT_MOUSE_RELEASED: return "EVENT_MOUSE_RELEASED";
+ case EVENT_MOUSE_MOVED: return "EVENT_MOUSE_MOVED";
+ case EVENT_MOUSE_DRAGGED: return "EVENT_MOUSE_DRAGGED";
+ case EVENT_MOUSE_WHEEL_MOVED: return "EVENT_MOUSE_WHEEL_MOVED";
+ default: return "unknown (" + type + ")";
+ }
+ }
+
+ private int x, y, clickCount, button, wheelRotation;
+
+ public static final int EVENT_MOUSE_CLICKED = 200;
+ public static final int EVENT_MOUSE_ENTERED = 201;
+ public static final int EVENT_MOUSE_EXITED = 202;
+ public static final int EVENT_MOUSE_PRESSED = 203;
+ public static final int EVENT_MOUSE_RELEASED = 204;
+ public static final int EVENT_MOUSE_MOVED = 205;
+ public static final int EVENT_MOUSE_DRAGGED = 206;
+ public static final int EVENT_MOUSE_WHEEL_MOVED = 207;
+}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/MouseListener.java b/src/newt/classes/com/jogamp/javafx/newt/MouseListener.java
new file mode 100644
index 000000000..a0d42f738
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/MouseListener.java
@@ -0,0 +1,47 @@
+/*
+ * 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.jogamp.javafx.newt;
+
+public interface MouseListener extends EventListener
+{
+ public void mouseClicked(MouseEvent e);
+ public void mouseEntered(MouseEvent e);
+ public void mouseExited(MouseEvent e);
+ public void mousePressed(MouseEvent e);
+ public void mouseReleased(MouseEvent e);
+ public void mouseMoved(MouseEvent e);
+ public void mouseDragged(MouseEvent e);
+ public void mouseWheelMoved(MouseEvent e);
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/NewtFactory.java b/src/newt/classes/com/jogamp/javafx/newt/NewtFactory.java
new file mode 100755
index 000000000..aae51aaf6
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/NewtFactory.java
@@ -0,0 +1,181 @@
+/*
+ * 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.jogamp.javafx.newt;
+
+import javax.media.nativewindow.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import com.jogamp.nativewindow.impl.jvm.JVMUtil;
+
+public abstract class NewtFactory {
+ // Work-around for initialization order problems on Mac OS X
+ // between native Newt and (apparently) Fmod
+ static {
+ JVMUtil.initSingleton();
+ Window.init(NativeWindowFactory.getNativeWindowType(true));
+ }
+
+ static Class getCustomClass(String packageName, String classBaseName) {
+ Class clazz = null;
+ if(packageName!=null || classBaseName!=null) {
+ String clazzName = packageName + "." + classBaseName ;
+ try {
+ clazz = Class.forName(clazzName);
+ } catch (Throwable t) {}
+ }
+ return clazz;
+ }
+
+ private static boolean useEDT = true;
+
+ /**
+ * Toggles the usage of an EventDispatchThread while creating a Display.
+ * Currently only valid is
+ * This implementation does not make the OpenGL context current
+ */
+public class GLWindow extends Window implements GLAutoDrawable {
+ private static List/*GLWindow*/ glwindows = new ArrayList();
+
+ private boolean ownerOfWinScrDpy;
+ private Window window;
+ private boolean runPumpMessages;
+
+ /** Constructor. Do not call this directly -- use {@link
+ create()} instead. */
+ protected GLWindow(Window window, boolean ownerOfWinScrDpy) {
+ this.ownerOfWinScrDpy = ownerOfWinScrDpy;
+ this.window = window;
+ this.window.setAutoDrawableClient(true);
+ this.runPumpMessages = ( null == getScreen().getDisplay().getEDT() ) ;
+ window.addWindowListener(new WindowListener() {
+ public void windowResized(WindowEvent e) {
+ sendReshape = true;
+ }
+
+ public void windowMoved(WindowEvent e) {
+ }
+
+ public void windowGainedFocus(WindowEvent e) {
+ }
+
+ public void windowLostFocus(WindowEvent e) {
+ }
+
+ public void windowDestroyNotify(WindowEvent e) {
+ sendDestroy = true;
+ }
+ });
+
+ List newglw = (List) ((ArrayList) glwindows).clone();
+ newglw.add(this);
+ glwindows=newglw;
+ }
+
+ /** Creates a new GLWindow on the local display, screen 0, with a
+ dummy visual ID, and with the default GLCapabilities. */
+ public static GLWindow create() {
+ return create(null, null, false);
+ }
+
+ public static GLWindow create(boolean undecorated) {
+ return create(null, null, undecorated);
+ }
+
+ /** Creates a new GLWindow referring to the given window. */
+ public static GLWindow create(Window window) {
+ return create(window, null, false);
+ }
+ public static GLWindow create(GLCapabilities caps) {
+ return create(null, caps, false);
+ }
+
+ /** Creates a new GLWindow on the local display, screen 0, with a
+ dummy visual ID, and with the given GLCapabilities. */
+ public static GLWindow create(GLCapabilities caps, boolean undecorated) {
+ return create(null, caps, undecorated);
+ }
+
+ /** Either or: window (prio), or caps and undecorated (2nd choice) */
+ private static GLWindow create(Window window,
+ GLCapabilities caps,
+ boolean undecorated) {
+ Display display;
+ boolean ownerOfWinScrDpy=false;
+ if (window == null) {
+ if (caps == null) {
+ caps = new GLCapabilities(null); // default ..
+ }
+ ownerOfWinScrDpy = true;
+ display = NewtFactory.createDisplay(null); // local display
+ Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ window = NewtFactory.createWindow(screen, caps, undecorated);
+ }
+
+ return new GLWindow(window, ownerOfWinScrDpy);
+ }
+
+ /**
+ * EXPERIMENTAL
+ *
+ * The idea was that in a single threaded environment with one {@link Display} and many {@link Window}'s,
+ * a performance benefit was expected while disabling the implicit {@link Display#pumpMessages} and
+ * do it once via {@link GLWindow#runCurrentThreadPumpMessage()}
+ *
+ * Best performance has been achieved with one GLWindow per thread.
+ *
+ * This class provides a startup singleton main thread,
+ * from which a new thread with the users main class is launched.
+ *
+ * If your platform is not Mac OS X, but you want to test your code without modifying
+ * this class, you have to set the system property
+ *
+ * The code is compatible with all other platform, which support multithreaded windowing handling.
+ * Since those platforms won't trigger the main thread serialization, the main method
+ * will be simply executed, in case you haven't set
+ *
+ * Test case on Mac OS X (or any other platform):
+
- * Currently only valid is
- * This implementation does not make the OpenGL context current
- */
-public class GLWindow extends Window implements GLAutoDrawable {
- private static List/*GLWindow*/ glwindows = new ArrayList();
-
- private boolean ownerOfWinScrDpy;
- private Window window;
- private boolean runPumpMessages;
-
- /** Constructor. Do not call this directly -- use {@link
- create()} instead. */
- protected GLWindow(Window window, boolean ownerOfWinScrDpy) {
- this.ownerOfWinScrDpy = ownerOfWinScrDpy;
- this.window = window;
- this.window.setAutoDrawableClient(true);
- this.runPumpMessages = ( null == getScreen().getDisplay().getEDT() ) ;
- window.addWindowListener(new WindowListener() {
- public void windowResized(WindowEvent e) {
- sendReshape = true;
- }
-
- public void windowMoved(WindowEvent e) {
- }
-
- public void windowGainedFocus(WindowEvent e) {
- }
-
- public void windowLostFocus(WindowEvent e) {
- }
-
- public void windowDestroyNotify(WindowEvent e) {
- sendDestroy = true;
- }
- });
-
- List newglw = (List) ((ArrayList) glwindows).clone();
- newglw.add(this);
- glwindows=newglw;
- }
-
- /** Creates a new GLWindow on the local display, screen 0, with a
- dummy visual ID, and with the default GLCapabilities. */
- public static GLWindow create() {
- return create(null, null, false);
- }
-
- public static GLWindow create(boolean undecorated) {
- return create(null, null, undecorated);
- }
-
- /** Creates a new GLWindow referring to the given window. */
- public static GLWindow create(Window window) {
- return create(window, null, false);
- }
- public static GLWindow create(GLCapabilities caps) {
- return create(null, caps, false);
- }
-
- /** Creates a new GLWindow on the local display, screen 0, with a
- dummy visual ID, and with the given GLCapabilities. */
- public static GLWindow create(GLCapabilities caps, boolean undecorated) {
- return create(null, caps, undecorated);
- }
-
- /** Either or: window (prio), or caps and undecorated (2nd choice) */
- private static GLWindow create(Window window,
- GLCapabilities caps,
- boolean undecorated) {
- Display display;
- boolean ownerOfWinScrDpy=false;
- if (window == null) {
- if (caps == null) {
- caps = new GLCapabilities(null); // default ..
- }
- ownerOfWinScrDpy = true;
- display = NewtFactory.createDisplay(null); // local display
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- window = NewtFactory.createWindow(screen, caps, undecorated);
- }
-
- return new GLWindow(window, ownerOfWinScrDpy);
- }
-
- /**
- * EXPERIMENTAL
- *
- * The idea was that in a single threaded environment with one {@link Display} and many {@link Window}'s,
- * a performance benefit was expected while disabling the implicit {@link Display#pumpMessages} and
- * do it once via {@link GLWindow#runCurrentThreadPumpMessage()}
- *
- * Best performance has been achieved with one GLWindow per thread.
- *
- * This class provides a startup singleton main thread,
- * from which a new thread with the users main class is launched.
- *
- * If your platform is not Mac OS X, but you want to test your code without modifying
- * this class, you have to set the system property
- *
- * The code is compatible with all other platform, which support multithreaded windowing handling.
- * Since those platforms won't trigger the main thread serialization, the main method
- * will be simply executed, in case you haven't set
- *
- * Test case on Mac OS X (or any other platform):
-
- * Currently only valid is
- * This implementation does not make the OpenGL context current
- */
-public class GLWindow extends Window implements GLAutoDrawable {
- private static List/*GLWindow*/ glwindows = new ArrayList();
-
- private boolean ownerOfWinScrDpy;
- private Window window;
- private boolean runPumpMessages;
-
- /** Constructor. Do not call this directly -- use {@link
- create()} instead. */
- protected GLWindow(Window window, boolean ownerOfWinScrDpy) {
- this.ownerOfWinScrDpy = ownerOfWinScrDpy;
- this.window = window;
- this.window.setAutoDrawableClient(true);
- this.runPumpMessages = ( null == getScreen().getDisplay().getEDT() ) ;
- window.addWindowListener(new WindowListener() {
- public void windowResized(WindowEvent e) {
- sendReshape = true;
- }
-
- public void windowMoved(WindowEvent e) {
- }
-
- public void windowGainedFocus(WindowEvent e) {
- }
-
- public void windowLostFocus(WindowEvent e) {
- }
-
- public void windowDestroyNotify(WindowEvent e) {
- sendDestroy = true;
- }
- });
-
- List newglw = (List) ((ArrayList) glwindows).clone();
- newglw.add(this);
- glwindows=newglw;
- }
-
- /** Creates a new GLWindow on the local display, screen 0, with a
- dummy visual ID, and with the default GLCapabilities. */
- public static GLWindow create() {
- return create(null, null, false);
- }
-
- public static GLWindow create(boolean undecorated) {
- return create(null, null, undecorated);
- }
-
- /** Creates a new GLWindow referring to the given window. */
- public static GLWindow create(Window window) {
- return create(window, null, false);
- }
- public static GLWindow create(GLCapabilities caps) {
- return create(null, caps, false);
- }
-
- /** Creates a new GLWindow on the local display, screen 0, with a
- dummy visual ID, and with the given GLCapabilities. */
- public static GLWindow create(GLCapabilities caps, boolean undecorated) {
- return create(null, caps, undecorated);
- }
-
- /** Either or: window (prio), or caps and undecorated (2nd choice) */
- private static GLWindow create(Window window,
- GLCapabilities caps,
- boolean undecorated) {
- Display display;
- boolean ownerOfWinScrDpy=false;
- if (window == null) {
- if (caps == null) {
- caps = new GLCapabilities(null); // default ..
- }
- ownerOfWinScrDpy = true;
- display = NewtFactory.createDisplay(null); // local display
- Screen screen = NewtFactory.createScreen(display, 0); // screen 0
- window = NewtFactory.createWindow(screen, caps, undecorated);
- }
-
- return new GLWindow(window, ownerOfWinScrDpy);
- }
-
- /**
- * EXPERIMENTAL
- *
- * The idea was that in a single threaded environment with one {@link Display} and many {@link Window}'s,
- * a performance benefit was expected while disabling the implicit {@link Display#pumpMessages} and
- * do it once via {@link GLWindow#runCurrentThreadPumpMessage()}
- *
- * Best performance has been achieved with one GLWindow per thread.
- *
- * This class provides a startup singleton main thread,
- * from which a new thread with the users main class is launched.
- *
- * If your platform is not Mac OS X, but you want to test your code without modifying
- * this class, you have to set the system property
- *
- * The code is compatible with all other platform, which support multithreaded windowing handling.
- * Since those platforms won't trigger the main thread serialization, the main method
- * will be simply executed, in case you haven't set
- *
- * Test case on Mac OS X (or any other platform):
-
+ * Currently only valid is
+ * This implementation does not make the OpenGL context current
+ */
+public class GLWindow extends Window implements GLAutoDrawable {
+ private static List/*GLWindow*/ glwindows = new ArrayList();
+
+ private boolean ownerOfWinScrDpy;
+ private Window window;
+ private boolean runPumpMessages;
+
+ /** Constructor. Do not call this directly -- use {@link
+ create()} instead. */
+ protected GLWindow(Window window, boolean ownerOfWinScrDpy) {
+ this.ownerOfWinScrDpy = ownerOfWinScrDpy;
+ this.window = window;
+ this.window.setAutoDrawableClient(true);
+ this.runPumpMessages = ( null == getScreen().getDisplay().getEDT() ) ;
+ window.addWindowListener(new WindowListener() {
+ public void windowResized(WindowEvent e) {
+ sendReshape = true;
+ }
+
+ public void windowMoved(WindowEvent e) {
+ }
+
+ public void windowGainedFocus(WindowEvent e) {
+ }
+
+ public void windowLostFocus(WindowEvent e) {
+ }
+
+ public void windowDestroyNotify(WindowEvent e) {
+ sendDestroy = true;
+ }
+ });
+
+ List newglw = (List) ((ArrayList) glwindows).clone();
+ newglw.add(this);
+ glwindows=newglw;
+ }
+
+ /** Creates a new GLWindow on the local display, screen 0, with a
+ dummy visual ID, and with the default GLCapabilities. */
+ public static GLWindow create() {
+ return create(null, null, false);
+ }
+
+ public static GLWindow create(boolean undecorated) {
+ return create(null, null, undecorated);
+ }
+
+ /** Creates a new GLWindow referring to the given window. */
+ public static GLWindow create(Window window) {
+ return create(window, null, false);
+ }
+ public static GLWindow create(GLCapabilities caps) {
+ return create(null, caps, false);
+ }
+
+ /** Creates a new GLWindow on the local display, screen 0, with a
+ dummy visual ID, and with the given GLCapabilities. */
+ public static GLWindow create(GLCapabilities caps, boolean undecorated) {
+ return create(null, caps, undecorated);
+ }
+
+ /** Either or: window (prio), or caps and undecorated (2nd choice) */
+ private static GLWindow create(Window window,
+ GLCapabilities caps,
+ boolean undecorated) {
+ Display display;
+ boolean ownerOfWinScrDpy=false;
+ if (window == null) {
+ if (caps == null) {
+ caps = new GLCapabilities(null); // default ..
+ }
+ ownerOfWinScrDpy = true;
+ display = NewtFactory.createDisplay(null); // local display
+ Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ window = NewtFactory.createWindow(screen, caps, undecorated);
+ }
+
+ return new GLWindow(window, ownerOfWinScrDpy);
+ }
+
+ /**
+ * EXPERIMENTAL
+ *
+ * The idea was that in a single threaded environment with one {@link Display} and many {@link Window}'s,
+ * a performance benefit was expected while disabling the implicit {@link Display#pumpMessages} and
+ * do it once via {@link GLWindow#runCurrentThreadPumpMessage()}
+ *
+ * Best performance has been achieved with one GLWindow per thread.
+ *
+ * This class provides a startup singleton main thread,
+ * from which a new thread with the users main class is launched.
+ *
+ * If your platform is not Mac OS X, but you want to test your code without modifying
+ * this class, you have to set the system property
+ *
+ * The code is compatible with all other platform, which support multithreaded windowing handling.
+ * Since those platforms won't trigger the main thread serialization, the main method
+ * will be simply executed, in case you haven't set
+ *
+ * Test case on Mac OS X (or any other platform):
+
@@ -280,7 +279,7 @@ public abstract class GLDrawableFactory {
* Returns true if it is possible to create an external GLDrawable
* object via {@link #createExternalGLDrawable}.
*/
- public abstract boolean canCreateExternalGLDrawable();
+ public abstract boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device);
/**
* Creates a {@link GLDrawable} object representing an existing
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 43b2e1e1d..e8de00629 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -494,7 +494,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
backend = new J2DOGLBackend();
} else {
if (!hardwareAccelerationDisabled &&
- factory.canCreateGLPbuffer()) {
+ factory.canCreateGLPbuffer(null)) {
backend = new PbufferBackend();
} else {
if (softwareRenderingDisabled) {
@@ -1509,7 +1509,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
}
}
if (joglContext == null) {
- if (factory.canCreateExternalGLDrawable()) {
+ AbstractGraphicsDevice device = j2dContext.getGLDrawable().getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice();
+ if (factory.canCreateExternalGLDrawable(device)) {
joglDrawable = factory.createExternalGLDrawable();
// FIXME: Need to share with j2d context, due to FBO resource ..
// - ORIG: joglContext = joglDrawable.createContext(shareWith);
@@ -1518,7 +1519,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
System.err.println("-- Created External Drawable: "+joglDrawable);
System.err.println("-- Created Context: "+joglContext);
}
- } else if (factory.canCreateContextOnJava2DSurface()) {
+ } else if (factory.canCreateContextOnJava2DSurface(device)) {
// Mac OS X code path
// FIXME: Need to share with j2d context, due to FBO resource ..
// - ORIG: joglContext = factory.createContextOnJava2DSurface(g, shareWith);
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java
index 9fc986180..95fd6c72b 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java
@@ -113,11 +113,11 @@ public class X11Util {
return 0;
}
long dpy = namedDpy.getHandle();
- X11Lib.XCloseDisplay(dpy);
if(DEBUG) {
- Exception e = new Exception("X11Util.Display: Closed TLS Display("+name+") with handle 0x"+Long.toHexString(dpy)+" in thread "+Thread.currentThread().getName());
+ Exception e = new Exception("X11Util.Display: Closing TLS Display("+name+") with handle 0x"+Long.toHexString(dpy)+" in thread "+Thread.currentThread().getName());
e.printStackTrace();
}
+ X11Lib.XCloseDisplay(dpy);
return dpy;
}
--
cgit v1.2.3
From 2ae28d54858ff684bc2368e0476a7a357dc63432 Mon Sep 17 00:00:00 2001
From: Sven Gothel Provides a virtual machine- and operating system-independent
mechanism for creating {@link GLDrawable}s.
@@ -116,7 +116,7 @@ public class MainThread {
// start user app ..
try {
- Class mainClass = NWReflection.getClass(mainClassName, true);
+ Class mainClass = ReflectionUtil.getClass(mainClassName, true);
if(null==mainClass) {
throw new RuntimeException(new ClassNotFoundException("MainThread couldn't find main class "+mainClassName));
}
@@ -159,7 +159,7 @@ public class MainThread {
System.arraycopy(args, 1, mainClassArgs, 0, args.length-1);
}
- NativeLibLoader.loadNEWT();
+ NEWTJNILibLoader.loadNEWT();
shouldStop = false;
tasks = new ArrayList();
diff --git a/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java b/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java
index 05cab1a0a..281022901 100755
--- a/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java
@@ -45,7 +45,7 @@ public class WindowsDisplay extends Display {
private static long hInstance;
static {
- NativeLibLoader.loadNEWT();
+ NEWTJNILibLoader.loadNEWT();
if (!WindowsWindow.initIDs()) {
throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs");
diff --git a/src/newt/classes/com/jogamp/newt/x11/X11Display.java b/src/newt/classes/com/jogamp/newt/x11/X11Display.java
index 5fd6d9640..c8faefbf1 100755
--- a/src/newt/classes/com/jogamp/newt/x11/X11Display.java
+++ b/src/newt/classes/com/jogamp/newt/x11/X11Display.java
@@ -41,7 +41,7 @@ import com.jogamp.nativewindow.impl.x11.X11Util;
public class X11Display extends Display {
static {
- NativeLibLoader.loadNEWT();
+ NEWTJNILibLoader.loadNEWT();
if (!initIDs()) {
throw new NativeWindowException("Failed to initialize X11Display jmethodIDs");
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index 33c5324e2..296172f6e 100755
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -159,11 +159,11 @@ static void _FatalError(JNIEnv *env, const char* msg, ...)
va_end(ap);
fprintf(stderr, buffer);
+ fprintf(stderr, "\n");
(*env)->FatalError(env, buffer);
}
-static const char * const ClazzNameRuntimeException =
- "java/lang/RuntimeException";
+static const char * const ClazzNameRuntimeException = "java/lang/RuntimeException";
static jclass runtimeExceptionClz=NULL;
static const char * const ClazzNameNewtWindow =
@@ -200,6 +200,7 @@ static void _throwNewRuntimeException(Display * unlockDisplay, JNIEnv *env, cons
*/
+static JNIEnv * x11ErrorHandlerJNIEnv = NULL;
static XErrorHandler origErrorHandler = NULL ;
static int displayDispatchErrorHandler(Display *dpy, XErrorEvent *e)
@@ -213,15 +214,16 @@ static int displayDispatchErrorHandler(Display *dpy, XErrorEvent *e)
{
fprintf(stderr, " BadWindow (%p): Window probably already removed\n", e->resourceid);
} else {
- return origErrorHandler(dpy, e);
+ _throwNewRuntimeException(NULL, x11ErrorHandlerJNIEnv, "NEWT X11 Error: Display %p, Code 0x%X", dpy, e->error_code);
}
return 0;
}
-static void displayDispatchErrorHandlerEnable(int onoff) {
+static void displayDispatchErrorHandlerEnable(int onoff, JNIEnv * env) {
if(onoff) {
if(NULL==origErrorHandler) {
+ x11ErrorHandlerJNIEnv = env;
origErrorHandler = XSetErrorHandler(displayDispatchErrorHandler);
}
} else {
@@ -329,13 +331,13 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_x11_X11Display_CompleteDisplay
javaObjectAtom = (jlong) XInternAtom(dpy, "JOGL_JAVA_OBJECT", False);
if(None==javaObjectAtom) {
- _throwNewRuntimeException(dpy, env, "could not create Atom JOGL_JAVA_OBJECT, bail out!\n");
+ _throwNewRuntimeException(dpy, env, "could not create Atom JOGL_JAVA_OBJECT, bail out!");
return;
}
windowDeleteAtom = (jlong) XInternAtom(dpy, "WM_DELETE_WINDOW", False);
if(None==windowDeleteAtom) {
- _throwNewRuntimeException(dpy, env, "could not create Atom WM_DELETE_WINDOW, bail out!\n");
+ _throwNewRuntimeException(dpy, env, "could not create Atom WM_DELETE_WINDOW, bail out!");
return;
}
@@ -371,7 +373,7 @@ static void setJavaWindowProperty(JNIEnv *env, Display *dpy, Window window, jlon
{
jobject test = (jobject) getPtrOut32Long(jogl_java_object_data);
if( ! (jwindow==test) ) {
- _throwNewRuntimeException(dpy, env, "Internal Error .. Encoded Window ref not the same %p != %p !\n", jwindow, test);
+ _throwNewRuntimeException(dpy, env, "Internal Error .. Encoded Window ref not the same %p != %p !", jwindow, test);
return;
}
}
@@ -415,7 +417,7 @@ static jobject getJavaWindowProperty(JNIEnv *env, Display *dpy, Window window, j
#ifdef VERBOSE_ON
if(JNI_FALSE == (*env)->IsInstanceOf(env, jwindow, newtWindowClz)) {
- _throwNewRuntimeException(dpy, env, "fetched Atom JOGL_JAVA_OBJECT window is not a NEWT Window: javaWindow 0x%X !\n", jwindow);
+ _throwNewRuntimeException(dpy, env, "fetched Atom JOGL_JAVA_OBJECT window is not a NEWT Window: javaWindow 0x%X !", jwindow);
}
#endif
return jwindow;
@@ -457,20 +459,20 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_x11_X11Display_DispatchMessages
num_events--;
if( 0==evt.xany.window ) {
- _throwNewRuntimeException(dpy, env, "event window NULL, bail out!\n");
+ _throwNewRuntimeException(dpy, env, "event window NULL, bail out!");
return ;
}
if(dpy!=evt.xany.display) {
- _throwNewRuntimeException(dpy, env, "wrong display, bail out!\n");
+ _throwNewRuntimeException(dpy, env, "wrong display, bail out!");
return ;
}
- displayDispatchErrorHandlerEnable(1);
+ displayDispatchErrorHandlerEnable(1, env);
jwindow = getJavaWindowProperty(env, dpy, evt.xany.window, javaObjectAtom);
- displayDispatchErrorHandlerEnable(0);
+ displayDispatchErrorHandlerEnable(0, env);
if(NULL==jwindow) {
fprintf(stderr, "Warning: NEWT X11 DisplayDispatch %p, Couldn't handle event %d for invalid X11 window %p\n",
@@ -685,7 +687,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_x11_X11Window_CreateWindow
}
if(visualID<0) {
- _throwNewRuntimeException(NULL, env, "invalid VisualID ..\n");
+ _throwNewRuntimeException(NULL, env, "invalid VisualID ..");
return 0;
}
@@ -712,7 +714,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_x11_X11Window_CreateWindow
if (visual==NULL)
{
- _throwNewRuntimeException(dpy, env, "could not query Visual by given VisualID, bail out!\n");
+ _throwNewRuntimeException(dpy, env, "could not query Visual by given VisualID, bail out!");
return 0;
}
@@ -797,11 +799,11 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_x11_X11Window_CloseWindow
jwindow = getJavaWindowProperty(env, dpy, w, javaObjectAtom);
if(NULL==jwindow) {
- _throwNewRuntimeException(dpy, env, "could not fetch Java Window object, bail out!\n");
+ _throwNewRuntimeException(dpy, env, "could not fetch Java Window object, bail out!");
return;
}
if ( JNI_FALSE == (*env)->IsSameObject(env, jwindow, obj) ) {
- _throwNewRuntimeException(dpy, env, "Internal Error .. Window global ref not the same!\n");
+ _throwNewRuntimeException(dpy, env, "Internal Error .. Window global ref not the same!");
return;
}
(*env)->DeleteGlobalRef(env, jwindow);
--
cgit v1.2.3
From ca6818d87ee86b2cc9961e47ad9f899e1fd90f78 Mon Sep 17 00:00:00 2001
From: Michael Bien AWTWindow(Frame frame)
,
+ * to support an external created AWT Frame, ie the browsers embedded frame.
+ */
+ public static Window createWindow(Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), cstrArguments, screen, caps, undecorated);
+ }
+
+ /**
+ * Create a Window entity using the given implementation type, incl native creation
+ */
+ public static Window createWindow(String type, Screen screen, Capabilities caps) {
+ return Window.create(type, 0, screen, caps, false);
+ }
+
+ public static Window createWindow(String type, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(type, 0, screen, caps, undecorated);
+ }
+
+ public static Window createWindow(String type, long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(type, parentWindowHandle, screen, caps, undecorated);
+ }
+
+ public static Window createWindow(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(type, cstrArguments, screen, caps, undecorated);
+ }
+
+ /**
+ * Instantiate a Display entity using the native handle.
+ */
+ public static Display wrapDisplay(String name, AbstractGraphicsDevice device) {
+ return Display.wrapHandle(NativeWindowFactory.getNativeWindowType(true), name, device);
+ }
+
+ /**
+ * Instantiate a Screen entity using the native handle.
+ */
+ public static Screen wrapScreen(Display display, AbstractGraphicsScreen screen) {
+ return Screen.wrapHandle(NativeWindowFactory.getNativeWindowType(true), display, screen);
+ }
+
+ /**
+ * Instantiate a Window entity using the native handle.
+ */
+ public static Window wrapWindow(Screen screen, AbstractGraphicsConfiguration config,
+ long windowHandle, boolean fullscreen, boolean visible,
+ int x, int y, int width, int height) {
+ return Window.wrapHandle(NativeWindowFactory.getNativeWindowType(true), screen, config,
+ windowHandle, fullscreen, visible, x, y, width, height);
+ }
+
+ private static final boolean instanceOf(Object obj, String clazzName) {
+ Class clazz = obj.getClass();
+ do {
+ if(clazz.getName().equals(clazzName)) {
+ return true;
+ }
+ clazz = clazz.getSuperclass();
+ } while (clazz!=null);
+ return false;
+ }
+
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/OffscreenWindow.java b/src/newt/classes/com/jogamp/javafx/newt/OffscreenWindow.java
new file mode 100644
index 000000000..015e9b8d2
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/OffscreenWindow.java
@@ -0,0 +1,108 @@
+/*
+ * 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.jogamp.javafx.newt;
+
+import javax.media.nativewindow.*;
+
+public class OffscreenWindow extends Window implements SurfaceChangeable {
+
+ long surfaceHandle = 0;
+
+ public OffscreenWindow() {
+ }
+
+ static long nextWindowHandle = 0x100; // start here - a marker
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ if(0!=parentWindowHandle) {
+ throw new NativeWindowException("OffscreenWindow does not support window parenting");
+ }
+ if(caps.isOnscreen()) {
+ throw new NativeWindowException("Capabilities is onscreen");
+ }
+ AbstractGraphicsScreen aScreen = screen.getGraphicsScreen();
+ config = GraphicsConfigurationFactory.getFactory(aScreen.getDevice()).chooseGraphicsConfiguration(caps, null, aScreen);
+ if (config == null) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+
+ synchronized(OffscreenWindow.class) {
+ windowHandle = nextWindowHandle++;
+ }
+ }
+
+ protected void closeNative() {
+ // nop
+ }
+
+ public void invalidate() {
+ super.invalidate();
+ surfaceHandle = 0;
+ }
+
+ public synchronized void destroy() {
+ surfaceHandle = 0;
+ }
+
+ public void setSurfaceHandle(long handle) {
+ surfaceHandle = handle ;
+ }
+
+ public long getSurfaceHandle() {
+ return surfaceHandle;
+ }
+
+ public void setVisible(boolean visible) {
+ if(!visible) {
+ this.visible = visible;
+ }
+ }
+
+ public void setSize(int width, int height) {
+ if(!visible) {
+ this.width = width;
+ this.height = height;
+ }
+ }
+
+ public void setPosition(int x, int y) {
+ // nop
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ // nop
+ return false;
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/PaintEvent.java b/src/newt/classes/com/jogamp/javafx/newt/PaintEvent.java
new file mode 100755
index 000000000..8543246a7
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/PaintEvent.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2009 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.jogamp.javafx.newt;
+
+/**
+ *
+ * @author tdv
+ */
+public class PaintEvent extends Event {
+
+ // bounds of the damage region
+ private int x, y, width, height;
+ public PaintEvent(int eventType, Window source,
+ long when, int x, int y, int w, int h)
+ {
+ super(true, eventType, source, when);
+ this.x = x;
+ this.y = y;
+ this.width = w;
+ this.height = h;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public int getX() {
+ return x;
+ }
+
+ public int getY() {
+ return y;
+ }
+
+ public String toString() {
+ return "ExposeEvent[modifiers: x="+x+" y="+y+" w="+width+" h="+height +"]";
+ }
+
+}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/PaintListener.java b/src/newt/classes/com/jogamp/javafx/newt/PaintListener.java
new file mode 100755
index 000000000..adfd78f18
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/PaintListener.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2009 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.jogamp.javafx.newt;
+
+/**
+ *
+ * @author tdv
+ */
+public interface PaintListener {
+ public void exposed(PaintEvent e);
+}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/Screen.java b/src/newt/classes/com/jogamp/javafx/newt/Screen.java
new file mode 100755
index 000000000..b02a7ef00
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/Screen.java
@@ -0,0 +1,147 @@
+/*
+ * 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.jogamp.javafx.newt;
+
+import com.jogamp.javafx.newt.impl.*;
+
+import javax.media.nativewindow.*;
+import java.security.*;
+
+public abstract class Screen {
+
+ private static Class getScreenClass(String type)
+ throws ClassNotFoundException
+ {
+ Class screenClass = NewtFactory.getCustomClass(type, "Screen");
+ if(null==screenClass) {
+ if (NativeWindowFactory.TYPE_EGL.equals(type)) {
+ screenClass = Class.forName("com.jogamp.javafx.newt.opengl.kd.KDScreen");
+ } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
+ screenClass = Class.forName("com.jogamp.javafx.newt.windows.WindowsScreen");
+ } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
+ screenClass = Class.forName("com.jogamp.javafx.newt.macosx.MacScreen");
+ } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
+ screenClass = Class.forName("com.jogamp.javafx.newt.x11.X11Screen");
+ } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
+ screenClass = Class.forName("com.jogamp.javafx.newt.awt.AWTScreen");
+ } else {
+ throw new RuntimeException("Unknown window type \"" + type + "\"");
+ }
+ }
+ return screenClass;
+ }
+
+ protected static Screen create(String type, Display display, int idx) {
+ try {
+ if(usrWidth<0 || usrHeight<0) {
+ usrWidth = Debug.getIntProperty("newt.ws.swidth", true, localACC);
+ usrHeight = Debug.getIntProperty("newt.ws.sheight", true, localACC);
+ System.out.println("User screen size "+usrWidth+"x"+usrHeight);
+ }
+ Class screenClass = getScreenClass(type);
+ Screen screen = (Screen) screenClass.newInstance();
+ screen.display = display;
+ screen.createNative(idx);
+ if(null==screen.aScreen) {
+ throw new RuntimeException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen");
+ }
+ return screen;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public synchronized void destroy() {
+ closeNative();
+ display = null;
+ aScreen = null;
+ }
+
+ protected static Screen wrapHandle(String type, Display display, AbstractGraphicsScreen aScreen) {
+ try {
+ Class screenClass = getScreenClass(type);
+ Screen screen = (Screen) screenClass.newInstance();
+ screen.display = display;
+ screen.aScreen = aScreen;
+ return screen;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected abstract void createNative(int index);
+ protected abstract void closeNative();
+
+ protected void setScreenSize(int w, int h) {
+ System.out.println("Detected screen size "+w+"x"+h);
+ width=w; height=h;
+ }
+
+ public Display getDisplay() {
+ return display;
+ }
+
+ public int getIndex() {
+ return aScreen.getIndex();
+ }
+
+ public AbstractGraphicsScreen getGraphicsScreen() {
+ return aScreen;
+ }
+
+ /**
+ * The actual implementation shall return the detected display value,
+ * if not we return 800.
+ * This can be overwritten with the user property 'newt.ws.swidth',
+ */
+ public int getWidth() {
+ return (usrWidth>0) ? usrWidth : (width>0) ? width : 480;
+ }
+
+ /**
+ * The actual implementation shall return the detected display value,
+ * if not we return 480.
+ * This can be overwritten with the user property 'newt.ws.sheight',
+ */
+ public int getHeight() {
+ return (usrHeight>0) ? usrHeight : (height>0) ? height : 480;
+ }
+
+ protected Display display;
+ protected AbstractGraphicsScreen aScreen;
+ protected int width=-1, height=-1; // detected values: set using setScreenSize
+ protected static int usrWidth=-1, usrHeight=-1; // property values: newt.ws.swidth and newt.ws.sheight
+ private static AccessControlContext localACC = AccessController.getContext();
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/Window.java b/src/newt/classes/com/jogamp/javafx/newt/Window.java
new file mode 100755
index 000000000..2d9341e13
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/Window.java
@@ -0,0 +1,929 @@
+/*
+ * 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.jogamp.javafx.newt;
+
+import com.jogamp.javafx.newt.impl.Debug;
+import com.jogamp.javafx.newt.util.EventDispatchThread;
+
+import javax.media.nativewindow.*;
+import com.jogamp.nativewindow.impl.NWReflection;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.lang.reflect.Method;
+
+public abstract class Window implements NativeWindow
+{
+ public static final boolean DEBUG_MOUSE_EVENT = Debug.debug("Window.MouseEvent");
+ public static final boolean DEBUG_KEY_EVENT = Debug.debug("Window.KeyEvent");
+ public static final boolean DEBUG_WINDOW_EVENT = Debug.debug("Window.WindowEvent");
+ public static final boolean DEBUG_IMPLEMENTATION = Debug.debug("Window");
+
+ // Workaround for initialization order problems on Mac OS X
+ // between native Newt and (apparently) Fmod -- if Fmod is
+ // initialized first then the connection to the window server
+ // breaks, leading to errors from deep within the AppKit
+ static void init(String type) {
+ if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
+ try {
+ getWindowClass(type);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private static Class getWindowClass(String type)
+ throws ClassNotFoundException
+ {
+ Class windowClass = NewtFactory.getCustomClass(type, "Window");
+ if(null==windowClass) {
+ if (NativeWindowFactory.TYPE_EGL.equals(type)) {
+ windowClass = Class.forName("com.jogamp.javafx.newt.opengl.kd.KDWindow");
+ } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
+ windowClass = Class.forName("com.jogamp.javafx.newt.windows.WindowsWindow");
+ } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
+ windowClass = Class.forName("com.jogamp.javafx.newt.macosx.MacWindow");
+ } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
+ windowClass = Class.forName("com.jogamp.javafx.newt.x11.X11Window");
+ } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
+ windowClass = Class.forName("com.jogamp.javafx.newt.awt.AWTWindow");
+ } else {
+ throw new NativeWindowException("Unknown window type \"" + type + "\"");
+ }
+ }
+ return windowClass;
+ }
+
+ protected static Window create(String type, final long parentWindowHandle, Screen screen, final Capabilities caps, boolean undecorated) {
+ try {
+ Class windowClass;
+ if(caps.isOnscreen()) {
+ windowClass = getWindowClass(type);
+ } else {
+ windowClass = OffscreenWindow.class;
+ }
+ Window window = (Window) windowClass.newInstance();
+ window.invalidate();
+ window.screen = screen;
+ window.setUndecorated(undecorated||0!=parentWindowHandle);
+ EventDispatchThread edt = screen.getDisplay().getEDT();
+ if(null!=edt) {
+ final Window f_win = window;
+ edt.invokeAndWait(new Runnable() {
+ public void run() {
+ f_win.createNative(parentWindowHandle, caps);
+ }
+ } );
+ } else {
+ window.createNative(parentWindowHandle, caps);
+ }
+ return window;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new NativeWindowException(t);
+ }
+ }
+
+ protected static Window create(String type, Object[] cstrArguments, Screen screen, final Capabilities caps, boolean undecorated) {
+ try {
+ Class windowClass = getWindowClass(type);
+ Class[] cstrArgumentTypes = getCustomConstructorArgumentTypes(windowClass);
+ if(null==cstrArgumentTypes) {
+ throw new NativeWindowException("WindowClass "+windowClass+" doesn't support custom arguments in constructor");
+ }
+ int argsChecked = verifyConstructorArgumentTypes(cstrArgumentTypes, cstrArguments);
+ if ( argsChecked < cstrArguments.length ) {
+ throw new NativeWindowException("WindowClass "+windowClass+" constructor mismatch at argument #"+argsChecked+"; Constructor: "+getTypeStrList(cstrArgumentTypes)+", arguments: "+getArgsStrList(cstrArguments));
+ }
+ Window window = (Window) NWReflection.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ;
+ window.invalidate();
+ window.screen = screen;
+ window.setUndecorated(undecorated);
+ EventDispatchThread edt = screen.getDisplay().getEDT();
+ if(null!=edt) {
+ final Window f_win = window;
+ edt.invokeAndWait(new Runnable() {
+ public void run() {
+ f_win.createNative(0, caps);
+ }
+ } );
+ } else {
+ window.createNative(0, caps);
+ }
+ return window;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new NativeWindowException(t);
+ }
+ }
+
+ protected static Window wrapHandle(String type, Screen screen, AbstractGraphicsConfiguration config,
+ long windowHandle, boolean fullscreen, boolean visible,
+ int x, int y, int width, int height)
+ {
+ try {
+ Class windowClass = getWindowClass(type);
+ Window window = (Window) windowClass.newInstance();
+ window.invalidate();
+ window.screen = screen;
+ window.config = config;
+ window.windowHandle = windowHandle;
+ window.fullscreen=fullscreen;
+ window.visible=visible;
+ window.x=x;
+ window.y=y;
+ window.width=width;
+ window.height=height;
+ return window;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new NativeWindowException(t);
+ }
+ }
+
+ public static String toHexString(int hex) {
+ return "0x" + Integer.toHexString(hex);
+ }
+
+ public static String toHexString(long hex) {
+ return "0x" + Long.toHexString(hex);
+ }
+
+ protected Screen screen;
+
+ protected AbstractGraphicsConfiguration config;
+ protected long windowHandle;
+ protected boolean fullscreen, visible;
+ protected int width, height, x, y;
+ protected int eventMask;
+
+ protected String title = "Newt Window";
+ protected boolean undecorated = false;
+
+ /**
+ * Create native windowHandle, ie creates a new native invisible window.
+ *
+ * The parentWindowHandle may be null, in which case no window parenting
+ * is requested.
+ *
+ * Shall use the capabilities to determine the graphics configuration
+ * and shall set the chosen capabilities.
+ */
+ protected abstract void createNative(long parentWindowHandle, Capabilities caps);
+
+ protected abstract void closeNative();
+
+ public Screen getScreen() {
+ return screen;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append(getClass().getName()+"[config "+config+
+ ", windowHandle "+toHexString(getWindowHandle())+
+ ", surfaceHandle "+toHexString(getSurfaceHandle())+
+ ", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
+ ", visible "+isVisible()+
+ ", undecorated "+undecorated+
+ ", fullscreen "+fullscreen+
+ ", "+screen+
+ ", wrappedWindow "+getWrappedWindow());
+
+ sb.append(", SurfaceUpdatedListeners num "+surfaceUpdatedListeners.size()+" [");
+ for (Iterator iter = surfaceUpdatedListeners.iterator(); iter.hasNext(); ) {
+ sb.append(iter.next()+", ");
+ }
+ sb.append("], WindowListeners num "+windowListeners.size()+" [");
+ for (Iterator iter = windowListeners.iterator(); iter.hasNext(); ) {
+ sb.append(iter.next()+", ");
+ }
+ sb.append("], MouseListeners num "+mouseListeners.size()+" [");
+ for (Iterator iter = mouseListeners.iterator(); iter.hasNext(); ) {
+ sb.append(iter.next()+", ");
+ }
+ sb.append("], KeyListeners num "+keyListeners.size()+" [");
+ for (Iterator iter = keyListeners.iterator(); iter.hasNext(); ) {
+ sb.append(iter.next()+", ");
+ }
+ sb.append("] ]");
+ return sb.toString();
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public void setUndecorated(boolean value) {
+ undecorated = value;
+ }
+
+ public boolean isUndecorated() {
+ return undecorated;
+ }
+
+ public void requestFocus() {
+ }
+
+ //
+ // NativeWindow impl
+ //
+ private Thread owner;
+ private int recursionCount;
+ protected Exception lockedStack = null;
+
+ /** Recursive and blocking lockSurface() implementation */
+ public synchronized int lockSurface() {
+ // We leave the ToolkitLock lock to the specializtion's discretion,
+ // ie the implicit JAWTWindow in case of AWTWindow
+ Thread cur = Thread.currentThread();
+ if (owner == cur) {
+ ++recursionCount;
+ return LOCK_SUCCESS;
+ }
+ while (owner != null) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ owner = cur;
+ lockedStack = new Exception("NEWT Surface previously locked by "+Thread.currentThread());
+ screen.getDisplay().lockDisplay();
+ return LOCK_SUCCESS;
+ }
+
+ /** Recursive and unblocking unlockSurface() implementation */
+ public synchronized void unlockSurface() throws NativeWindowException {
+ Thread cur = Thread.currentThread();
+ if (owner != cur) {
+ lockedStack.printStackTrace();
+ throw new NativeWindowException(cur+": Not owner, owner is "+owner);
+ }
+ if (recursionCount > 0) {
+ --recursionCount;
+ return;
+ }
+ owner = null;
+ lockedStack = null;
+ screen.getDisplay().unlockDisplay();
+ notifyAll();
+ // We leave the ToolkitLock unlock to the specializtion's discretion,
+ // ie the implicit JAWTWindow in case of AWTWindow
+ }
+
+ public synchronized boolean isSurfaceLocked() {
+ return null!=owner;
+ }
+
+ public synchronized Thread getSurfaceLockOwner() {
+ return owner;
+ }
+
+ public synchronized Exception getLockedStack() {
+ return lockedStack;
+ }
+
+ public synchronized void destroy() {
+ destroy(false);
+ }
+
+ /** @param deep If true, the linked Screen and Display will be destroyed as well. */
+ public synchronized void destroy(boolean deep) {
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.destroy() start (deep "+deep+" - "+Thread.currentThread());
+ }
+ synchronized(surfaceUpdatedListeners) {
+ surfaceUpdatedListeners = new ArrayList();
+ }
+ synchronized(windowListeners) {
+ windowListeners = new ArrayList();
+ }
+ synchronized(mouseListeners) {
+ mouseListeners = new ArrayList();
+ }
+ synchronized(keyListeners) {
+ keyListeners = new ArrayList();
+ }
+ Screen scr = screen;
+ Display dpy = (null!=screen) ? screen.getDisplay() : null;
+ EventDispatchThread edt = (null!=dpy) ? dpy.getEDT() : null;
+ if(null!=edt) {
+ final Window f_win = this;
+ edt.invokeAndWait(new Runnable() {
+ public void run() {
+ f_win.closeNative();
+ }
+ } );
+ } else {
+ closeNative();
+ }
+ invalidate();
+ if(deep) {
+ if(null!=scr) {
+ scr.destroy();
+ }
+ if(null!=dpy) {
+ dpy.destroy();
+ }
+ }
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.destroy() end "+Thread.currentThread());
+ }
+ }
+
+ public void invalidate() {
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ Exception e = new Exception("!!! Window Invalidate "+Thread.currentThread());
+ e.printStackTrace();
+ }
+ screen = null;
+ windowHandle = 0;
+ fullscreen=false;
+ visible=false;
+ eventMask = 0;
+
+ // Default position and dimension will be re-set immediately by user
+ width = 100;
+ height = 100;
+ x=0;
+ y=0;
+ }
+
+ public boolean surfaceSwap() {
+ return false;
+ }
+
+ protected void clearEventMask() {
+ eventMask=0;
+ }
+
+ public long getDisplayHandle() {
+ return screen.getDisplay().getHandle();
+ }
+
+ public int getScreenIndex() {
+ return screen.getIndex();
+ }
+
+ public long getWindowHandle() {
+ return windowHandle;
+ }
+
+ public long getSurfaceHandle() {
+ return windowHandle; // default: return window handle
+ }
+
+ public AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ return config;
+ }
+
+ /**
+ * Returns the width of the client area of this window
+ * @return width of the client area
+ */
+ public int getWidth() {
+ return width;
+ }
+
+ /**
+ * Returns the height of the client area of this window
+ * @return height of the client area
+ */
+ public int getHeight() {
+ return height;
+ }
+
+ /**
+ * Returns the insets for this native window (the difference between the
+ * size of the toplevel window with the decorations and the client area).
+ *
+ * @return insets for this platform window
+ */
+ // this probably belongs to NativeWindow interface
+ public Insets getInsets() {
+ return new Insets(0,0,0,0);
+ }
+
+ /** If this Window actually wraps one from another toolkit such as
+ the AWT, this will return a non-null value. */
+ public Object getWrappedWindow() {
+ return null;
+ }
+
+ //
+ // Additional methods
+ //
+
+ public int getX() {
+ return x;
+ }
+
+ public int getY() {
+ return y;
+ }
+
+ public boolean isVisible() {
+ return visible;
+ }
+
+ public boolean isFullscreen() {
+ return fullscreen;
+ }
+
+ private boolean autoDrawableMember = false;
+
+ /** If the implementation is capable of detecting a device change
+ return true and clear the status/reason of the change. */
+ public boolean hasDeviceChanged() {
+ return false;
+ }
+
+ /**
+ * If set to true,
+ * certain action will be performed by the owning
+ * AutoDrawable, ie the destroy() call within windowDestroyNotify()
+ */
+ public void setAutoDrawableClient(boolean b) {
+ autoDrawableMember = b;
+ }
+
+ protected void windowDestroyNotify() {
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.windowDestroyeNotify start "+Thread.currentThread());
+ }
+
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY);
+
+ if(!autoDrawableMember) {
+ destroy();
+ }
+
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.windowDestroyeNotify end "+Thread.currentThread());
+ }
+ }
+
+ protected void windowDestroyed() {
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.windowDestroyed "+Thread.currentThread());
+ }
+ invalidate();
+ }
+
+ public abstract void setVisible(boolean visible);
+ /**
+ * Sets the size of the client area of the window, excluding decorations
+ * Total size of the window will be
+ * {@code width+insets.left+insets.right, height+insets.top+insets.bottom}
+ * @param width of the client area of the window
+ * @param height of the client area of the window
+ */
+ public abstract void setSize(int width, int height);
+ /**
+ * Sets the location of the top left corner of the window, including
+ * decorations (so the client area will be placed at
+ * {@code x+insets.left,y+insets.top}.
+ * @param x coord of the top left corner
+ * @param y coord of the top left corner
+ */
+ public abstract void setPosition(int x, int y);
+ public abstract boolean setFullscreen(boolean fullscreen);
+
+ //
+ // SurfaceUpdatedListener Support
+ //
+ private ArrayList surfaceUpdatedListeners = new ArrayList();
+
+ public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ if(l == null) {
+ return;
+ }
+ synchronized(surfaceUpdatedListeners) {
+ ArrayList newSurfaceUpdatedListeners = (ArrayList) surfaceUpdatedListeners.clone();
+ newSurfaceUpdatedListeners.add(l);
+ surfaceUpdatedListeners = newSurfaceUpdatedListeners;
+ }
+ }
+
+ public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ if (l == null) {
+ return;
+ }
+ synchronized(surfaceUpdatedListeners) {
+ ArrayList newSurfaceUpdatedListeners = (ArrayList) surfaceUpdatedListeners.clone();
+ newSurfaceUpdatedListeners.remove(l);
+ surfaceUpdatedListeners = newSurfaceUpdatedListeners;
+ }
+ }
+
+ public SurfaceUpdatedListener[] getSurfaceUpdatedListener() {
+ synchronized(surfaceUpdatedListeners) {
+ return (SurfaceUpdatedListener[]) surfaceUpdatedListeners.toArray();
+ }
+ }
+
+ public void surfaceUpdated(Object updater, NativeWindow window, long when) {
+ ArrayList listeners = null;
+ synchronized(surfaceUpdatedListeners) {
+ listeners = surfaceUpdatedListeners;
+ }
+ for(Iterator i = listeners.iterator(); i.hasNext(); ) {
+ SurfaceUpdatedListener l = (SurfaceUpdatedListener) i.next();
+ l.surfaceUpdated(updater, window, when);
+ }
+ }
+
+ //
+ // MouseListener Support
+ //
+
+ public void addMouseListener(MouseListener l) {
+ if(l == null) {
+ return;
+ }
+ synchronized(mouseListeners) {
+ ArrayList newMouseListeners = (ArrayList) mouseListeners.clone();
+ newMouseListeners.add(l);
+ mouseListeners = newMouseListeners;
+ }
+ }
+
+ public void removeMouseListener(MouseListener l) {
+ if (l == null) {
+ return;
+ }
+ synchronized(mouseListeners) {
+ ArrayList newMouseListeners = (ArrayList) mouseListeners.clone();
+ newMouseListeners.remove(l);
+ mouseListeners = newMouseListeners;
+ }
+ }
+
+ public MouseListener[] getMouseListeners() {
+ synchronized(mouseListeners) {
+ return (MouseListener[]) mouseListeners.toArray();
+ }
+ }
+
+ private ArrayList mouseListeners = new ArrayList();
+ private int mouseButtonPressed = 0; // current pressed mouse button number
+ private long lastMousePressed = 0; // last time when a mouse button was pressed
+ private int lastMouseClickCount = 0; // last mouse button click count
+ public static final int ClickTimeout = 300;
+
+ protected void sendMouseEvent(int eventType, int modifiers,
+ int x, int y, int button, int rotation) {
+ if(x<0||y<0||x>=width||y>=height) {
+ return; // .. invalid ..
+ }
+ if(DEBUG_MOUSE_EVENT) {
+ System.out.println("sendMouseEvent: "+MouseEvent.getEventTypeString(eventType)+
+ ", mod "+modifiers+", pos "+x+"/"+y+", button "+button);
+ }
+ if(button<0||button>MouseEvent.BUTTON_NUMBER) {
+ throw new NativeWindowException("Invalid mouse button number" + button);
+ }
+ long when = System.currentTimeMillis();
+ MouseEvent eClicked = null;
+ MouseEvent e = null;
+
+ if(MouseEvent.EVENT_MOUSE_PRESSED==eventType) {
+ if(when-lastMousePressed
+ * before calling the various input EventListener callbacks (MouseListener, KeyListener,
+ * etc.).
+ * This design decision is made to favor a more performant and simplified
+ * implementation, as well as the event dispatcher shall be allowed
+ * not having a notion about OpenGL.
+ *
+ * Enable or disables running the {@link Display#pumpMessages} in the {@link #display()} call.
+ * The default behavior is to run {@link Display#pumpMessages}.
+ * This could not have been verified. No measurable difference could have been recognized.
+ *
+ * Enabling local pump messages while using the EDT,
+ * {@link com.jogamp.javafx.newt.NewtFactory#setUseEDT(boolean)},
+ * will result in an exception.
+ *
+ * @deprecated EXPERIMENTAL, semantic is about to be removed after further verification.
+ */
+ public void setRunPumpMessages(boolean onoff) {
+ if( onoff && null!=getScreen().getDisplay().getEDT() ) {
+ throw new GLException("GLWindow.setRunPumpMessages(true) - Can't do with EDT on");
+ }
+ runPumpMessages = onoff;
+ }
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ shouldNotCallThis();
+ }
+
+ protected void closeNative() {
+ shouldNotCallThis();
+ }
+
+ protected void dispose(boolean regenerate, boolean sendEvent) {
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ Exception e1 = new Exception("GLWindow.dispose("+regenerate+") "+Thread.currentThread()+", 1");
+ e1.printStackTrace();
+ }
+
+ if(sendEvent) {
+ sendDisposeEvent();
+ }
+
+ if (context != null) {
+ context.destroy();
+ }
+ if (drawable != null) {
+ drawable.setRealized(false);
+ }
+
+ if(regenerate) {
+ if(null==window) {
+ throw new GLException("GLWindow.dispose(true): null window");
+ }
+
+ // recreate GLDrawable, to reflect the new graphics configurations
+ NativeWindow nw;
+ if (window.getWrappedWindow() != null) {
+ nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
+ } else {
+ nw = window;
+ }
+ drawable = factory.createGLDrawable(nw);
+ drawable.setRealized(true);
+ context = drawable.createContext(null);
+ sendReshape = true; // ensure a reshape event is send ..
+ }
+
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ System.out.println("GLWindow.dispose("+regenerate+") "+Thread.currentThread()+", fin: "+this);
+ }
+ }
+
+ public synchronized void destroy() {
+ destroy(true);
+ }
+
+ /** @param sendDisposeEvent should be false in a [time,reliable] critical shutdown */
+ public synchronized void destroy(boolean sendDisposeEvent) {
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ Exception e1 = new Exception("GLWindow.destroy "+Thread.currentThread()+", 1: "+this);
+ e1.printStackTrace();
+ }
+
+ List newglw = (List) ((ArrayList) glwindows).clone();
+ newglw.remove(this);
+ glwindows=newglw;
+
+ dispose(false, sendDisposeEvent);
+
+ if(null!=window) {
+ if(ownerOfWinScrDpy) {
+ window.destroy(true);
+ }
+ }
+
+ drawable = null;
+ context = null;
+ window = null;
+
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ System.out.println("GLWindow.destroy "+Thread.currentThread()+", fin: "+this);
+ }
+ }
+
+ public boolean getPerfLogEnabled() { return perfLog; }
+
+ public void enablePerfLog(boolean v) {
+ perfLog = v;
+ }
+
+ public void setVisible(boolean visible) {
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ System.out.println(Thread.currentThread()+" GLWindow.setVisible("+visible+") START ; isVisible "+this.visible+" ; has context "+(null!=context));
+ }
+ this.visible=visible;
+ window.setVisible(visible);
+ if (visible && context == null) {
+ NativeWindow nw;
+ if (window.getWrappedWindow() != null) {
+ nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
+ } else {
+ nw = window;
+ }
+ GLCapabilities glCaps = (GLCapabilities) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
+ drawable = factory.createGLDrawable(nw);
+ drawable.setRealized(true);
+ context = drawable.createContext(null);
+ sendReshape = true; // ensure a reshape event is send ..
+ }
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ System.out.println(Thread.currentThread()+" GLWindow.setVisible("+visible+") END ; has context "+(null!=context));
+ }
+ }
+
+ public Screen getScreen() {
+ return window.getScreen();
+ }
+
+ public void setTitle(String title) {
+ window.setTitle(title);
+ }
+
+ public String getTitle() {
+ return window.getTitle();
+ }
+
+ public void setUndecorated(boolean value) {
+ window.setUndecorated(value);
+ }
+
+ public boolean isUndecorated() {
+ return window.isUndecorated();
+ }
+
+ public void setSize(int width, int height) {
+ window.setSize(width, height);
+ }
+
+ public void setPosition(int x, int y) {
+ window.setPosition(x, y);
+ }
+
+ public Insets getInsets() {
+ return window.getInsets();
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ return window.setFullscreen(fullscreen);
+ }
+
+ public boolean isVisible() {
+ return window.isVisible();
+ }
+
+ public int getX() {
+ return window.getX();
+ }
+
+ public int getY() {
+ return window.getY();
+ }
+
+ public int getWidth() {
+ return window.getWidth();
+ }
+
+ public int getHeight() {
+ return window.getHeight();
+ }
+
+ public boolean isFullscreen() {
+ return window.isFullscreen();
+ }
+
+ public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ window.addSurfaceUpdatedListener(l);
+ }
+ public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ window.removeSurfaceUpdatedListener(l);
+ }
+ public SurfaceUpdatedListener[] getSurfaceUpdatedListener() {
+ return window.getSurfaceUpdatedListener();
+ }
+ public void surfaceUpdated(Object updater, NativeWindow window0, long when) {
+ window.surfaceUpdated(updater, window, when);
+ }
+
+ public void addMouseListener(MouseListener l) {
+ window.addMouseListener(l);
+ }
+
+ public void removeMouseListener(MouseListener l) {
+ window.removeMouseListener(l);
+ }
+
+ public MouseListener[] getMouseListeners() {
+ return window.getMouseListeners();
+ }
+
+ public void addKeyListener(KeyListener l) {
+ window.addKeyListener(l);
+ }
+
+ public void removeKeyListener(KeyListener l) {
+ window.removeKeyListener(l);
+ }
+
+ public KeyListener[] getKeyListeners() {
+ return window.getKeyListeners();
+ }
+
+ public void addWindowListener(WindowListener l) {
+ window.addWindowListener(l);
+ }
+
+ public void removeWindowListener(WindowListener l) {
+ window.removeWindowListener(l);
+ }
+
+ public WindowListener[] getWindowListeners() {
+ return window.getWindowListeners();
+ }
+
+ public String toString() {
+ return "NEWT-GLWindow[ \n\tDrawable: "+drawable+", \n\tWindow: "+window+", \n\tHelper: "+helper+", \n\tFactory: "+factory+"]";
+ }
+
+ //----------------------------------------------------------------------
+ // OpenGL-related methods and state
+ //
+
+ private GLDrawableFactory factory;
+ private GLDrawable drawable;
+ private GLContext context;
+ private GLDrawableHelper helper = new GLDrawableHelper();
+ // To make reshape events be sent immediately before a display event
+ private boolean sendReshape=false;
+ private boolean sendDestroy=false;
+ private boolean perfLog = false;
+
+ public GLDrawableFactory getFactory() {
+ return factory;
+ }
+
+ public void setContext(GLContext newCtx) {
+ context = newCtx;
+ }
+
+ public GLContext getContext() {
+ return context;
+ }
+
+ public GL getGL() {
+ if (context == null) {
+ return null;
+ }
+ return context.getGL();
+ }
+
+ public GL setGL(GL gl) {
+ if (context != null) {
+ context.setGL(gl);
+ return gl;
+ }
+ return null;
+ }
+
+ public void addGLEventListener(GLEventListener listener) {
+ helper.addGLEventListener(listener);
+ }
+
+ public void removeGLEventListener(GLEventListener listener) {
+ helper.removeGLEventListener(listener);
+ }
+
+ public void display() {
+ display(false);
+ }
+
+ public void display(boolean forceReshape) {
+ if(window!=null && drawable!=null && context != null) {
+ if(runPumpMessages) {
+ window.getScreen().getDisplay().pumpMessages();
+ }
+ if(window.hasDeviceChanged() && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED) {
+ dispose(true, true);
+ }
+ if (sendDestroy) {
+ destroy();
+ sendDestroy=false;
+ } else {
+ if(forceReshape) {
+ sendReshape = true;
+ }
+ helper.invokeGL(drawable, context, displayAction, initAction);
+ }
+ }
+ }
+
+ private void sendDisposeEvent() {
+ if(drawable!=null && context != null) {
+ helper.invokeGL(drawable, context, disposeAction, null);
+ }
+ }
+
+ /** This implementation uses a static value */
+ public void setAutoSwapBufferMode(boolean onOrOff) {
+ helper.setAutoSwapBufferMode(onOrOff);
+ }
+
+ /** This implementation uses a static value */
+ public boolean getAutoSwapBufferMode() {
+ return helper.getAutoSwapBufferMode();
+ }
+
+ public void swapBuffers() {
+ if(drawable!=null && context != null) {
+ if (context != GLContext.getCurrent()) {
+ // Assume we should try to make the context current before swapping the buffers
+ helper.invokeGL(drawable, context, swapBuffersAction, initAction);
+ } else {
+ drawable.swapBuffers();
+ }
+ }
+ }
+
+ class InitAction implements Runnable {
+ public void run() {
+ helper.init(GLWindow.this);
+ startTime = System.currentTimeMillis();
+ curTime = startTime;
+ if(perfLog) {
+ lastCheck = startTime;
+ totalFrames = 0; lastFrames = 0;
+ }
+ }
+ }
+ private InitAction initAction = new InitAction();
+
+ class DisposeAction implements Runnable {
+ public void run() {
+ helper.dispose(GLWindow.this);
+ }
+ }
+ private DisposeAction disposeAction = new DisposeAction();
+
+ class DisplayAction implements Runnable {
+ public void run() {
+ if (sendReshape) {
+ int width = getWidth();
+ int height = getHeight();
+ getGL().glViewport(0, 0, width, height);
+ helper.reshape(GLWindow.this, 0, 0, width, height);
+ sendReshape = false;
+ }
+
+ helper.display(GLWindow.this);
+
+ curTime = System.currentTimeMillis();
+ totalFrames++;
+
+ if(perfLog) {
+ long dt0, dt1;
+ lastFrames++;
+ dt0 = curTime-lastCheck;
+ if ( dt0 > 5000 ) {
+ dt1 = curTime-startTime;
+ System.out.println(dt0/1000 +"s: "+ lastFrames + "f, " + (lastFrames*1000)/dt0 + " fps, "+dt0/lastFrames+" ms/f; "+
+ "total: "+ dt1/1000+"s, "+(totalFrames*1000)/dt1 + " fps, "+dt1/totalFrames+" ms/f");
+ lastCheck=curTime;
+ lastFrames=0;
+ }
+ }
+ }
+ }
+ private DisplayAction displayAction = new DisplayAction();
+
+ public long getStartTime() { return startTime; }
+ public long getCurrentTime() { return curTime; }
+ public long getDuration() { return curTime-startTime; }
+ public int getTotalFrames() { return totalFrames; }
+
+ private long startTime = 0;
+ private long curTime = 0;
+ private long lastCheck = 0;
+ private int totalFrames = 0, lastFrames = 0;
+
+ class SwapBuffersAction implements Runnable {
+ public void run() {
+ drawable.swapBuffers();
+ }
+ }
+ private SwapBuffersAction swapBuffersAction = new SwapBuffersAction();
+
+ //----------------------------------------------------------------------
+ // GLDrawable methods
+ //
+
+ public NativeWindow getNativeWindow() {
+ return null!=drawable ? drawable.getNativeWindow() : null;
+ }
+
+ public synchronized int lockSurface() throws NativeWindowException {
+ if(null!=drawable) return drawable.getNativeWindow().lockSurface();
+ return NativeWindow.LOCK_SURFACE_NOT_READY;
+ }
+
+ public synchronized void unlockSurface() {
+ if(null!=drawable) drawable.getNativeWindow().unlockSurface();
+ else throw new NativeWindowException("NEWT-GLWindow not locked");
+ }
+
+ public synchronized boolean isSurfaceLocked() {
+ if(null!=drawable) return drawable.getNativeWindow().isSurfaceLocked();
+ return false;
+ }
+
+ public synchronized Exception getLockedStack() {
+ if(null!=drawable) return drawable.getNativeWindow().getLockedStack();
+ return null;
+ }
+
+ public boolean surfaceSwap() {
+ if(null!=drawable) return drawable.getNativeWindow().surfaceSwap();
+ return super.surfaceSwap();
+ }
+
+ public long getWindowHandle() {
+ if(null!=drawable) return drawable.getNativeWindow().getWindowHandle();
+ return super.getWindowHandle();
+ }
+
+ public long getSurfaceHandle() {
+ if(null!=drawable) return drawable.getNativeWindow().getSurfaceHandle();
+ return super.getSurfaceHandle();
+ }
+
+ //----------------------------------------------------------------------
+ // GLDrawable methods that are not really needed
+ //
+
+ public GLContext createContext(GLContext shareWith) {
+ return drawable.createContext(shareWith);
+ }
+
+ public void setRealized(boolean realized) {
+ }
+
+ public GLCapabilities getChosenGLCapabilities() {
+ if (drawable == null) {
+ throw new GLException("No drawable yet");
+ }
+
+ return drawable.getChosenGLCapabilities();
+ }
+
+ public GLProfile getGLProfile() {
+ if (drawable == null) {
+ throw new GLException("No drawable yet");
+ }
+
+ return drawable.getGLProfile();
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only below this point
+ //
+
+ private void shouldNotCallThis() {
+ throw new NativeWindowException("Should not call this");
+ }
+}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Display.java b/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Display.java
new file mode 100644
index 000000000..c0c1ee5fd
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Display.java
@@ -0,0 +1,81 @@
+/*
+ * 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.jogamp.javafx.newt.opengl.broadcom.egl;
+
+import com.jogamp.javafx.newt.impl.*;
+import com.jogamp.opengl.impl.egl.*;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.egl.*;
+
+public class Display extends com.jogamp.javafx.newt.Display {
+
+ static {
+ NativeLibLoader.loadNEWT();
+
+ if (!Window.initIDs()) {
+ throw new NativeWindowException("Failed to initialize BCEGL Window jmethodIDs");
+ }
+ }
+
+ public static void initSingleton() {
+ // just exist to ensure static init has been run
+ }
+
+
+ public Display() {
+ }
+
+ protected void createNative() {
+ long handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight);
+ if (handle == EGL.EGL_NO_DISPLAY) {
+ throw new NativeWindowException("BC EGL CreateDisplay failed");
+ }
+ aDevice = new EGLGraphicsDevice(handle);
+ }
+
+ protected void closeNative() {
+ if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) {
+ DestroyDisplay(aDevice.getHandle());
+ }
+ }
+
+ protected void dispatchMessages() {
+ // n/a .. DispatchMessages();
+ }
+
+ private native long CreateDisplay(int width, int height);
+ private native void DestroyDisplay(long dpy);
+ private native void DispatchMessages();
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Screen.java b/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Screen.java
new file mode 100755
index 000000000..f7abe3836
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Screen.java
@@ -0,0 +1,63 @@
+/*
+ * 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.jogamp.javafx.newt.opengl.broadcom.egl;
+
+import com.jogamp.javafx.newt.impl.*;
+import javax.media.nativewindow.*;
+
+public class Screen extends com.jogamp.javafx.newt.Screen {
+
+ static {
+ Display.initSingleton();
+ }
+
+
+ public Screen() {
+ }
+
+ protected void createNative(int index) {
+ aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
+ setScreenSize(fixedWidth, fixedHeight);
+ }
+
+ protected void closeNative() { }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ static final int fixedWidth = 1920;
+ static final int fixedHeight = 1080;
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Window.java b/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Window.java
new file mode 100755
index 000000000..bd2d7930e
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Window.java
@@ -0,0 +1,156 @@
+/*
+ * 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.jogamp.javafx.newt.opengl.broadcom.egl;
+
+import com.jogamp.javafx.newt.impl.*;
+import com.jogamp.opengl.impl.egl.*;
+import javax.media.nativewindow.*;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.nativewindow.NativeWindowException;
+
+public class Window extends com.jogamp.javafx.newt.Window {
+ static {
+ Display.initSingleton();
+ }
+
+ public Window() {
+ }
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ if(0!=parentWindowHandle) {
+ throw new RuntimeException("Window parenting not supported (yet)");
+ }
+ // query a good configuration .. even thought we drop this one
+ // and reuse the EGLUtil choosen one later.
+ config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
+ if (config == null) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+ setSizeImpl(getScreen().getWidth(), getScreen().getHeight());
+ }
+
+ protected void closeNative() {
+ if(0!=windowHandleClose) {
+ CloseWindow(getDisplayHandle(), windowHandleClose);
+ }
+ }
+
+ public void setVisible(boolean visible) {
+ if(this.visible!=visible) {
+ this.visible=visible;
+ if ( 0==windowHandle ) {
+ windowHandle = realizeWindow(true, width, height);
+ if (0 == windowHandle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
+ }
+ clearEventMask();
+ }
+ }
+
+ public void setSize(int width, int height) {
+ System.err.println("setSize "+width+"x"+height+" n/a in BroadcomEGL");
+ }
+
+ void setSizeImpl(int width, int height) {
+ if(0!=windowHandle) {
+ // n/a in BroadcomEGL
+ System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window");
+ } else {
+ if(DEBUG_IMPLEMENTATION) {
+ Exception e = new Exception("BCEGL Window.setSizeImpl() "+this.width+"x"+this.height+" -> "+width+"x"+height);
+ e.printStackTrace();
+ }
+ this.width = width;
+ this.height = height;
+ }
+ }
+
+ public void setPosition(int x, int y) {
+ // n/a in BroadcomEGL
+ System.err.println("setPosition n/a in BroadcomEGL");
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ // n/a in BroadcomEGL
+ System.err.println("setFullscreen n/a in BroadcomEGL");
+ return false;
+ }
+
+ public boolean surfaceSwap() {
+ if ( 0!=windowHandle ) {
+ SwapWindow(getDisplayHandle(), windowHandle);
+ return true;
+ }
+ return false;
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ protected static native boolean initIDs();
+ private native long CreateWindow(long eglDisplayHandle, boolean chromaKey, int width, int height);
+ private native void CloseWindow(long eglDisplayHandle, long eglWindowHandle);
+ private native void SwapWindow(long eglDisplayHandle, long eglWindowHandle);
+
+
+ private long realizeWindow(boolean chromaKey, int width, int height) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.out.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+config);
+ }
+ long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height);
+ if (0 == handle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
+ windowHandleClose = handle;
+ return handle;
+ }
+
+ private void windowCreated(int cfgID, int width, int height) {
+ this.width = width;
+ this.height = height;
+ GLCapabilities capsReq = (GLCapabilities) config.getRequestedCapabilities();
+ config = EGLGraphicsConfiguration.create(capsReq, screen.getGraphicsScreen(), cfgID);
+ if (config == null) {
+ throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this);
+ }
+ if(DEBUG_IMPLEMENTATION) {
+ System.out.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+config);
+ }
+ }
+
+ private long windowHandleClose;
+}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDDisplay.java b/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDDisplay.java
new file mode 100755
index 000000000..40a37115d
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDDisplay.java
@@ -0,0 +1,84 @@
+/*
+ * 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.jogamp.javafx.newt.opengl.kd;
+
+import com.jogamp.javafx.newt.*;
+import com.jogamp.javafx.newt.impl.*;
+import com.jogamp.opengl.impl.egl.*;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.egl.*;
+
+public class KDDisplay extends Display {
+
+ static {
+ NativeLibLoader.loadNEWT();
+
+ if (!KDWindow.initIDs()) {
+ throw new NativeWindowException("Failed to initialize KDWindow jmethodIDs");
+ }
+ }
+
+ public static void initSingleton() {
+ // just exist to ensure static init has been run
+ }
+
+
+ public KDDisplay() {
+ }
+
+ protected void createNative() {
+ // FIXME: map name to EGL_*_DISPLAY
+ long handle = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
+ if (handle == EGL.EGL_NO_DISPLAY) {
+ throw new NativeWindowException("eglGetDisplay failed");
+ }
+ if (!EGL.eglInitialize(handle, null, null)) {
+ throw new NativeWindowException("eglInitialize failed");
+ }
+ aDevice = new EGLGraphicsDevice(handle);
+ }
+
+ protected void closeNative() {
+ if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) {
+ EGL.eglTerminate(aDevice.getHandle());
+ }
+ }
+
+ protected void dispatchMessages() {
+ DispatchMessages();
+ }
+
+ private native void DispatchMessages();
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDScreen.java b/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDScreen.java
new file mode 100755
index 000000000..4bc7f8257
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDScreen.java
@@ -0,0 +1,57 @@
+/*
+ * 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.jogamp.javafx.newt.opengl.kd;
+
+import com.jogamp.javafx.newt.*;
+import javax.media.nativewindow.*;
+
+public class KDScreen extends Screen {
+ static {
+ KDDisplay.initSingleton();
+ }
+
+ public KDScreen() {
+ }
+
+ protected void createNative(int index) {
+ aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
+ }
+
+ protected void closeNative() { }
+
+ // elevate access to this package ..
+ protected void setScreenSize(int w, int h) {
+ super.setScreenSize(w, h);
+ }
+}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDWindow.java b/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDWindow.java
new file mode 100755
index 000000000..d5be2207c
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDWindow.java
@@ -0,0 +1,153 @@
+/*
+ * 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.jogamp.javafx.newt.opengl.kd;
+
+import com.jogamp.javafx.newt.*;
+import com.jogamp.javafx.newt.impl.*;
+import com.jogamp.opengl.impl.egl.*;
+import javax.media.nativewindow.*;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.nativewindow.NativeWindowException;
+
+public class KDWindow extends Window {
+ private static final String WINDOW_CLASS_NAME = "NewtWindow";
+ // non fullscreen dimensions ..
+ private int nfs_width, nfs_height, nfs_x, nfs_y;
+
+ static {
+ KDDisplay.initSingleton();
+ }
+
+ public KDWindow() {
+ }
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ if(0!=parentWindowHandle) {
+ throw new RuntimeException("Window parenting not supported (yet)");
+ }
+ config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
+ if (config == null) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+
+ GLCapabilities eglCaps = (GLCapabilities)config.getChosenCapabilities();
+ int[] eglAttribs = EGLGraphicsConfiguration.GLCapabilities2AttribList(eglCaps);
+
+ windowHandle = 0;
+ eglWindowHandle = CreateWindow(getDisplayHandle(), eglAttribs);
+ if (eglWindowHandle == 0) {
+ throw new NativeWindowException("Error creating egl window: "+config);
+ }
+ setVisible0(eglWindowHandle, false);
+ windowHandleClose = eglWindowHandle;
+ }
+
+ protected void closeNative() {
+ if(0!=windowHandleClose) {
+ CloseWindow(windowHandleClose, windowUserData);
+ windowUserData=0;
+ }
+ }
+
+ public void setVisible(boolean visible) {
+ if(0!=eglWindowHandle && this.visible!=visible) {
+ this.visible=visible;
+ setVisible0(eglWindowHandle, visible);
+ if ( 0==windowHandle ) {
+ windowHandle = RealizeWindow(eglWindowHandle);
+ if (0 == windowHandle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
+ }
+ clearEventMask();
+ }
+ }
+
+ public void setSize(int width, int height) {
+ if(0!=eglWindowHandle) {
+ setSize0(eglWindowHandle, width, height);
+ }
+ }
+
+ public void setPosition(int x, int y) {
+ // n/a in KD
+ System.err.println("setPosition n/a in KD");
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ if(0!=eglWindowHandle && this.fullscreen!=fullscreen) {
+ this.fullscreen=fullscreen;
+ if(this.fullscreen) {
+ setFullScreen0(eglWindowHandle, true);
+ } else {
+ setFullScreen0(eglWindowHandle, false);
+ setSize0(eglWindowHandle, nfs_width, nfs_height);
+ }
+ }
+ return true;
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ protected static native boolean initIDs();
+ private native long CreateWindow(long displayHandle, int[] attributes);
+ private native long RealizeWindow(long eglWindowHandle);
+ private native int CloseWindow(long eglWindowHandle, long userData);
+ private native void setVisible0(long eglWindowHandle, boolean visible);
+ private native void setSize0(long eglWindowHandle, int width, int height);
+ private native void setFullScreen0(long eglWindowHandle, boolean fullscreen);
+
+ private void windowCreated(long userData) {
+ windowUserData=userData;
+ }
+
+ private void sizeChanged(int newWidth, int newHeight) {
+ width = newWidth;
+ height = newHeight;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ } else {
+ ((KDScreen)screen).setScreenSize(width, height);
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
+ }
+
+ private long eglWindowHandle;
+ private long windowHandleClose;
+ private long windowUserData;
+}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/util/EventDispatchThread.java b/src/newt/classes/com/jogamp/javafx/newt/util/EventDispatchThread.java
new file mode 100644
index 000000000..db3f97ee6
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/util/EventDispatchThread.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+package com.jogamp.javafx.newt.util;
+
+import com.jogamp.javafx.newt.Display;
+import com.jogamp.javafx.newt.impl.Debug;
+import java.util.*;
+
+public class EventDispatchThread {
+ public static final boolean DEBUG = Debug.debug("EDT");
+
+ private ThreadGroup threadGroup;
+ private volatile boolean shouldStop = false;
+ private TaskWorker taskWorker = null;
+ private Object taskWorkerLock = new Object();
+ private ArrayList tasks = new ArrayList(); // one shot tasks
+ private Display display = null;
+ private String name;
+ private long edtPollGranularity = 10;
+
+ public EventDispatchThread(Display display, ThreadGroup tg, String name) {
+ this.display = display;
+ this.threadGroup = tg;
+ this.name=new String("EDT-Display_"+display.getName()+"-"+name);
+ }
+
+ public String getName() { return name; }
+
+ public ThreadGroup getThreadGroup() { return threadGroup; }
+
+ public void start() {
+ start(false);
+ }
+
+ /**
+ * @param externalStimuli true indicates that another thread stimulates,
+ * ie. calls this TaskManager's run() loop method.
+ * Hence no own thread is started in this case.
+ *
+ * @return The started Runnable, which handles the run-loop.
+ * Usefull in combination with externalStimuli=true,
+ * so an external stimuli can call it.
+ */
+ public Runnable start(boolean externalStimuli) {
+ synchronized(taskWorkerLock) {
+ if(null==taskWorker) {
+ taskWorker = new TaskWorker(threadGroup, name);
+ }
+ if(!taskWorker.isRunning()) {
+ shouldStop = false;
+ taskWorker.start(externalStimuli);
+ }
+ taskWorkerLock.notifyAll();
+ }
+ return taskWorker;
+ }
+
+ public void stop() {
+ synchronized(taskWorkerLock) {
+ if(null!=taskWorker && taskWorker.isRunning()) {
+ shouldStop = true;
+ }
+ taskWorkerLock.notifyAll();
+ if(DEBUG) {
+ System.out.println(Thread.currentThread()+": EDT signal STOP");
+ }
+ }
+ }
+
+ public boolean isThreadEDT(Thread thread) {
+ return null!=taskWorker && taskWorker == thread;
+ }
+
+ public boolean isCurrentThreadEDT() {
+ return null!=taskWorker && taskWorker == Thread.currentThread();
+ }
+
+ public boolean isRunning() {
+ return null!=taskWorker && taskWorker.isRunning() ;
+ }
+
+ public void invokeLater(Runnable task) {
+ if(task == null) {
+ return;
+ }
+ synchronized(taskWorkerLock) {
+ if(null!=taskWorker && taskWorker.isRunning() && taskWorker != Thread.currentThread() ) {
+ tasks.add(task);
+ taskWorkerLock.notifyAll();
+ } else {
+ // if !running or isEDTThread, do it right away
+ task.run();
+ }
+ }
+ }
+
+ public void invokeAndWait(Runnable task) {
+ if(task == null) {
+ return;
+ }
+ invokeLater(task);
+ waitOnWorker();
+ }
+
+ public void waitOnWorker() {
+ synchronized(taskWorkerLock) {
+ if(null!=taskWorker && taskWorker.isRunning() && tasks.size()>0 && taskWorker != Thread.currentThread() ) {
+ try {
+ taskWorkerLock.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public void waitUntilStopped() {
+ synchronized(taskWorkerLock) {
+ while(null!=taskWorker && taskWorker.isRunning() && taskWorker != Thread.currentThread() ) {
+ try {
+ taskWorkerLock.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ class TaskWorker extends Thread {
+ boolean isRunning = false;
+ boolean externalStimuli = false;
+
+ public TaskWorker(ThreadGroup tg, String name) {
+ super(tg, name);
+ }
+
+ public synchronized boolean isRunning() {
+ return isRunning;
+ }
+
+ public void start(boolean externalStimuli) throws IllegalThreadStateException {
+ synchronized(this) {
+ this.externalStimuli = externalStimuli;
+ isRunning = true;
+ }
+ if(!externalStimuli) {
+ super.start();
+ }
+ }
+
+ /**
+ * Utilizing taskWorkerLock only for local resources and task execution,
+ * not for event dispatching.
+ */
+ public void run() {
+ if(DEBUG) {
+ System.out.println(Thread.currentThread()+": EDT run() START");
+ }
+ while(!shouldStop) {
+ try {
+ // wait for something todo
+ while(!shouldStop && tasks.size()==0) {
+ synchronized(taskWorkerLock) {
+ if(!shouldStop && tasks.size()==0) {
+ try {
+ taskWorkerLock.wait(edtPollGranularity);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ display.pumpMessages(); // event dispatch
+ }
+ if(!shouldStop && tasks.size()>0) {
+ synchronized(taskWorkerLock) {
+ if(!shouldStop && tasks.size()>0) {
+ Runnable task = (Runnable) tasks.remove(0);
+ task.run();
+ taskWorkerLock.notifyAll();
+ }
+ }
+ display.pumpMessages(); // event dispatch
+ }
+ } catch (Throwable t) {
+ // handle errors ..
+ t.printStackTrace();
+ } finally {
+ // epilog - unlock locked stuff
+ }
+ if(externalStimuli) break; // no loop if called by external stimuli
+ }
+ synchronized(this) {
+ isRunning = !shouldStop;
+ }
+ if(!isRunning) {
+ synchronized(taskWorkerLock) {
+ taskWorkerLock.notifyAll();
+ }
+ }
+ if(DEBUG) {
+ System.out.println(Thread.currentThread()+": EDT run() EXIT");
+ }
+ }
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/util/MainThread.java b/src/newt/classes/com/jogamp/javafx/newt/util/MainThread.java
new file mode 100644
index 000000000..9bf25098f
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/util/MainThread.java
@@ -0,0 +1,307 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+package com.jogamp.javafx.newt.util;
+
+import java.util.*;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.security.*;
+
+import javax.media.nativewindow.*;
+
+import com.jogamp.javafx.newt.*;
+import com.jogamp.javafx.newt.impl.*;
+import com.jogamp.javafx.newt.macosx.MacDisplay;
+import com.jogamp.nativewindow.impl.NWReflection;
+
+/**
+ * NEWT Utility class MainThread
+ *
+ * Such behavior is necessary for native windowing toolkits,
+ * where the windowing management must happen on the so called
+ * main thread e.g. for Mac OS X !
+ *
+ * Utilizing this class as a launchpad, now you are able to
+ * use a NEWT multithreaded application with window handling within the different threads,
+ * even on these restricted platforms.
+ *
+ * To support your NEWT Window platform,
+ * you have to pass your main thread actions to {@link #invoke invoke(..)},
+ * have a look at the {@link com.jogamp.javafx.newt.macosx.MacWindow MacWindow} implementation.
+ * TODO: Some hardcoded dependencies exist in this implementation,
+ * where you have to patch this code or factor it out. newt.MainThread.force
to true
.newt.MainThread.force
to true
.
+ java -XstartOnFirstThread com.jogamp.javafx.newt.util.MainThread demos.es1.RedSquare -GL2 -GL2 -GL2 -GL2
+
+ * Which starts 4 threads, each with a window and OpenGL rendering.
+ */
+public class MainThread {
+ private static AccessControlContext localACC = AccessController.getContext();
+ public static final boolean USE_MAIN_THREAD = NativeWindowFactory.TYPE_MACOSX.equals(NativeWindowFactory.getNativeWindowType(false)) ||
+ Debug.getBooleanProperty("newt.MainThread.force", true, localACC);
+
+ protected static final boolean DEBUG = Debug.debug("MainThread");
+
+ private static boolean isExit=false;
+ private static volatile boolean isRunning=false;
+ private static Object taskWorkerLock=new Object();
+ private static boolean shouldStop;
+ private static ArrayList tasks;
+ private static ArrayList tasksBlock;
+ private static Thread mainThread;
+
+ static class MainAction extends Thread {
+ private String mainClassName;
+ private String[] mainClassArgs;
+
+ private Class mainClass;
+ private Method mainClassMain;
+
+ public MainAction(String mainClassName, String[] mainClassArgs) {
+ this.mainClassName=mainClassName;
+ this.mainClassArgs=mainClassArgs;
+ }
+
+ public void run() {
+ if ( USE_MAIN_THREAD ) {
+ // we have to start first to provide the service ..
+ MainThread.waitUntilRunning();
+ }
+
+ // start user app ..
+ try {
+ Class mainClass = NWReflection.getClass(mainClassName, true);
+ if(null==mainClass) {
+ throw new RuntimeException(new ClassNotFoundException("MainThread couldn't find main class "+mainClassName));
+ }
+ try {
+ mainClassMain = mainClass.getDeclaredMethod("main", new Class[] { String[].class });
+ mainClassMain.setAccessible(true);
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" invoke "+mainClassName);
+ mainClassMain.invoke(null, new Object[] { mainClassArgs } );
+ } catch (InvocationTargetException ite) {
+ ite.getTargetException().printStackTrace();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+
+ if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" user app fin");
+
+ if ( USE_MAIN_THREAD ) {
+ MainThread.exit();
+ if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" MainThread fin - exit");
+ System.exit(0);
+ }
+ }
+ }
+ private static MainAction mainAction;
+
+ /** Your new java application main entry, which pipelines your application */
+ public static void main(String[] args) {
+ if(DEBUG) System.err.println("MainThread.main(): "+Thread.currentThread().getName()+" USE_MAIN_THREAD "+ USE_MAIN_THREAD );
+
+ if(args.length==0) {
+ return;
+ }
+
+ String mainClassName=args[0];
+ String[] mainClassArgs=new String[args.length-1];
+ if(args.length>1) {
+ System.arraycopy(args, 1, mainClassArgs, 0, args.length-1);
+ }
+
+ NativeLibLoader.loadNEWT();
+
+ shouldStop = false;
+ tasks = new ArrayList();
+ tasksBlock = new ArrayList();
+ mainThread = Thread.currentThread();
+
+ mainAction = new MainAction(mainClassName, mainClassArgs);
+
+ if(NativeWindowFactory.TYPE_MACOSX.equals(NativeWindowFactory.getNativeWindowType(false))) {
+ MacDisplay.initSingleton();
+ }
+
+ if ( USE_MAIN_THREAD ) {
+ // dispatch user's main thread ..
+ mainAction.start();
+
+ // do our main thread task scheduling
+ run();
+ } else {
+ // run user's main in this thread
+ mainAction.run();
+ }
+ }
+
+ /** invokes the given Runnable */
+ public static void invoke(boolean wait, Runnable r) {
+ if(r == null) {
+ return;
+ }
+
+ // if this main thread is not being used or
+ // if this is already the main thread .. just execute.
+ if( !isRunning() || mainThread == Thread.currentThread() ) {
+ r.run();
+ return;
+ }
+
+ synchronized(taskWorkerLock) {
+ tasks.add(r);
+ if(wait) {
+ tasksBlock.add(r);
+ }
+ taskWorkerLock.notifyAll();
+ if(wait) {
+ while(tasksBlock.size()>0) {
+ try {
+ taskWorkerLock.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
+ public static void exit() {
+ if(DEBUG) System.err.println("MainThread.exit(): "+Thread.currentThread().getName()+" start");
+ synchronized(taskWorkerLock) {
+ if(isRunning) {
+ shouldStop = true;
+ }
+ taskWorkerLock.notifyAll();
+ }
+ if(DEBUG) System.err.println("MainThread.exit(): "+Thread.currentThread().getName()+" end");
+ }
+
+ public static boolean isRunning() {
+ synchronized(taskWorkerLock) {
+ return isRunning;
+ }
+ }
+
+ private static void waitUntilRunning() {
+ synchronized(taskWorkerLock) {
+ if(isExit) return;
+
+ while(!isRunning) {
+ try {
+ taskWorkerLock.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public static void run() {
+ if(DEBUG) System.err.println("MainThread.run(): "+Thread.currentThread().getName());
+ synchronized(taskWorkerLock) {
+ isRunning = true;
+ taskWorkerLock.notifyAll();
+ }
+ while(!shouldStop) {
+ try {
+ ArrayList localTasks=null;
+
+ // wait for something todo ..
+ synchronized(taskWorkerLock) {
+ while(!shouldStop && tasks.size()==0) {
+ try {
+ taskWorkerLock.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ // seq. process all tasks until no blocking one exists in the list
+ for(Iterator i = tasks.iterator(); tasksBlock.size()>0 && i.hasNext(); ) {
+ Runnable task = (Runnable) i.next();
+ task.run();
+ i.remove();
+ tasksBlock.remove(task);
+ }
+
+ // take over the tasks ..
+ if(tasks.size()>0) {
+ localTasks = tasks;
+ tasks = new ArrayList();
+ }
+ taskWorkerLock.notifyAll();
+ }
+
+ // seq. process all unblocking tasks ..
+ if(null!=localTasks) {
+ for(Iterator i = localTasks.iterator(); i.hasNext(); ) {
+ Runnable task = (Runnable) i.next();
+ task.run();
+ }
+ }
+ } catch (Throwable t) {
+ // handle errors ..
+ t.printStackTrace();
+ } finally {
+ // epilog - unlock locked stuff
+ }
+ }
+ if(DEBUG) System.err.println("MainThread.run(): "+Thread.currentThread().getName()+" fin");
+ synchronized(taskWorkerLock) {
+ isRunning = false;
+ isExit = true;
+ taskWorkerLock.notifyAll();
+ }
+ }
+}
+
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsDisplay.java b/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsDisplay.java
new file mode 100755
index 000000000..f2e8d21ef
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsDisplay.java
@@ -0,0 +1,105 @@
+/*
+ * 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.jogamp.javafx.newt.windows;
+
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.windows.*;
+import com.jogamp.javafx.newt.*;
+import com.jogamp.javafx.newt.impl.*;
+
+public class WindowsDisplay extends Display {
+
+ protected static final String WINDOW_CLASS_NAME = "NewtWindowClass";
+ private static int windowClassAtom;
+ private static long hInstance;
+
+ static {
+ NativeLibLoader.loadNEWT();
+
+ if (!WindowsWindow.initIDs()) {
+ throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs");
+ }
+ }
+
+ public static void initSingleton() {
+ // just exist to ensure static init has been run
+ }
+
+
+ public WindowsDisplay() {
+ }
+
+ protected void createNative() {
+ aDevice = new WindowsGraphicsDevice();
+ }
+
+ protected void closeNative() {
+ // Can't do .. only at application shutdown
+ // UnregisterWindowClass(getWindowClassAtom(), getHInstance());
+ }
+
+ protected void dispatchMessages() {
+ DispatchMessages();
+ }
+
+ protected static synchronized int getWindowClassAtom() {
+ if(0 == windowClassAtom) {
+ windowClassAtom = RegisterWindowClass(WINDOW_CLASS_NAME, getHInstance());
+ if (0 == windowClassAtom) {
+ throw new NativeWindowException("Error while registering window class");
+ }
+ }
+ return windowClassAtom;
+ }
+
+ protected static synchronized long getHInstance() {
+ if(0 == hInstance) {
+ hInstance = LoadLibraryW("newt");
+ if (0 == hInstance) {
+ throw new NativeWindowException("Error finding HINSTANCE for \"newt\"");
+ }
+ }
+ return hInstance;
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+ private static native long LoadLibraryW(String libraryName);
+ private static native int RegisterWindowClass(String windowClassName, long hInstance);
+ private static native void UnregisterWindowClass(int wndClassAtom, long hInstance);
+
+ private static native void DispatchMessages();
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsScreen.java b/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsScreen.java
new file mode 100755
index 000000000..ab11f97dd
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsScreen.java
@@ -0,0 +1,58 @@
+/*
+ * 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.jogamp.javafx.newt.windows;
+
+import com.jogamp.javafx.newt.*;
+import com.jogamp.javafx.newt.impl.*;
+import javax.media.nativewindow.*;
+
+public class WindowsScreen extends Screen {
+ static {
+ WindowsDisplay.initSingleton();
+ }
+
+
+ public WindowsScreen() {
+ }
+
+ protected void createNative(int index) {
+ aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
+ setScreenSize(getWidthImpl(getIndex()), getHeightImpl(getIndex()));
+ }
+
+ protected void closeNative() { }
+
+ private native int getWidthImpl(int scrn_idx);
+ private native int getHeightImpl(int scrn_idx);
+}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsWindow.java
new file mode 100755
index 000000000..7c8864190
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsWindow.java
@@ -0,0 +1,289 @@
+/*
+ * 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.jogamp.javafx.newt.windows;
+
+import javax.media.nativewindow.*;
+import com.jogamp.javafx.newt.*;
+
+public class WindowsWindow extends Window {
+
+ private long hmon;
+ private long hdc;
+ private long windowHandleClose;
+ private long parentWindowHandle;
+ // non fullscreen dimensions ..
+ private int nfs_width, nfs_height, nfs_x, nfs_y;
+ private final Insets insets = new Insets(0, 0, 0, 0);
+
+ static {
+ WindowsDisplay.initSingleton();
+ }
+
+ public WindowsWindow() {
+ }
+
+ Thread hdcOwner = null;
+
+ public synchronized int lockSurface() throws NativeWindowException {
+ int res = super.lockSurface();
+ if(LOCK_SUCCESS==res && 0!=windowHandle) {
+ if(hdc!=0) {
+ throw new NativeWindowException("NEWT Surface handle set HDC "+toHexString(hdc)+" - "+Thread.currentThread().getName()+" ; "+this);
+ }
+ hdc = GetDC(windowHandle);
+ hmon = MonitorFromWindow(windowHandle);
+ hdcOwner = Thread.currentThread();
+ }
+ return res;
+ }
+
+ public synchronized void unlockSurface() {
+ // prevalidate, before we change data ..
+ Thread cur = Thread.currentThread();
+ if ( getSurfaceLockOwner() != cur ) {
+ getLockedStack().printStackTrace();
+ throw new NativeWindowException(cur+": Not owner, owner is "+getSurfaceLockOwner());
+ }
+ if (0!=hdc && 0!=windowHandle) {
+ if(hdcOwner != cur) {
+ throw new NativeWindowException("NEWT Surface handle set HDC "+toHexString(hdc)+" by other thread "+hdcOwner+", this "+cur+" ; "+this);
+ }
+ ReleaseDC(windowHandle, hdc);
+ hdc=0;
+ hdcOwner=null;
+ }
+ super.unlockSurface();
+ }
+
+ public long getSurfaceHandle() {
+ return hdc;
+ }
+
+ public boolean hasDeviceChanged() {
+ if(0!=windowHandle) {
+ long _hmon = MonitorFromWindow(windowHandle);
+ if (hmon != _hmon) {
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ Exception e = new Exception("!!! Window Device Changed "+Thread.currentThread().getName()+
+ ", HMON "+toHexString(hmon)+" -> "+toHexString(_hmon));
+ e.printStackTrace();
+ }
+ hmon = _hmon;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ WindowsScreen screen = (WindowsScreen) getScreen();
+ WindowsDisplay display = (WindowsDisplay) screen.getDisplay();
+ config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
+ if (config == null) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+ windowHandle = CreateWindow(parentWindowHandle,
+ display.getWindowClassAtom(), display.WINDOW_CLASS_NAME, display.getHInstance(),
+ 0, undecorated, x, y, width, height);
+ if (windowHandle == 0) {
+ throw new NativeWindowException("Error creating window");
+ }
+ this.parentWindowHandle = parentWindowHandle;
+ windowHandleClose = windowHandle;
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ Exception e = new Exception("!!! Window new window handle "+Thread.currentThread().getName()+
+ " (Parent HWND "+toHexString(parentWindowHandle)+
+ ") : HWND "+toHexString(windowHandle)+", "+Thread.currentThread());
+ e.printStackTrace();
+ }
+ }
+
+ protected void closeNative() {
+ if (hdc != 0) {
+ if(windowHandleClose != 0) {
+ ReleaseDC(windowHandleClose, hdc);
+ }
+ hdc = 0;
+ }
+ if(windowHandleClose != 0) {
+ DestroyWindow(windowHandleClose);
+ windowHandleClose = 0;
+ }
+ }
+
+ protected void windowDestroyed() {
+ windowHandleClose = 0;
+ super.windowDestroyed();
+ }
+
+ public void setVisible(boolean visible) {
+ if(this.visible!=visible && 0!=windowHandle) {
+ this.visible=visible;
+ setVisible0(windowHandle, visible);
+ }
+ }
+
+ // @Override
+ public void setSize(int width, int height) {
+ if (0!=windowHandle && (width != this.width || this.height != height)) {
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ this.width = width;
+ this.height = height;
+ setSize0(parentWindowHandle, windowHandle, x, y, width, height);
+ }
+ }
+
+ //@Override
+ public void setPosition(int x, int y) {
+ if (0!=windowHandle && (this.x != x || this.y != y)) {
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ this.x = x;
+ this.y = y;
+ setPosition(parentWindowHandle, windowHandle, x , y);
+ }
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ if(0!=windowHandle && (this.fullscreen!=fullscreen)) {
+ int x,y,w,h;
+ this.fullscreen=fullscreen;
+ if(fullscreen) {
+ x = 0; y = 0;
+ w = screen.getWidth();
+ h = screen.getHeight();
+ } else {
+ x = nfs_x;
+ y = nfs_y;
+ w = nfs_width;
+ h = nfs_height;
+ }
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ System.err.println("WindowsWindow fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
+ }
+ setFullscreen0(parentWindowHandle, windowHandle, x, y, w, h, undecorated, fullscreen);
+ }
+ return fullscreen;
+ }
+
+ // @Override
+ public void requestFocus() {
+ super.requestFocus();
+ if (windowHandle != 0L) {
+ requestFocus(windowHandle);
+ }
+ }
+
+ // @Override
+ public void setTitle(String title) {
+ if (title == null) {
+ title = "";
+ }
+ if (0!=windowHandle && !title.equals(getTitle())) {
+ super.setTitle(title);
+ setTitle(windowHandle, title);
+ }
+ }
+
+ public Insets getInsets() {
+ return (Insets)insets.clone();
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+ protected static native boolean initIDs();
+ private native long CreateWindow(long parentWindowHandle,
+ int wndClassAtom, String wndName,
+ long hInstance, long visualID,
+ boolean isUndecorated,
+ int x, int y, int width, int height);
+ private native void DestroyWindow(long windowHandle);
+ private native long GetDC(long windowHandle);
+ private native void ReleaseDC(long windowHandle, long hdc);
+ private native long MonitorFromWindow(long windowHandle);
+ private static native void setVisible0(long windowHandle, boolean visible);
+ private native void setSize0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height);
+ private native void setPosition(long parentWindowHandle, long windowHandle, int x, int y);
+ private native void setFullscreen0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height, boolean isUndecorated, boolean on);
+ private static native void setTitle(long windowHandle, String title);
+ private static native void requestFocus(long windowHandle);
+
+ private void insetsChanged(int left, int top, int right, int bottom) {
+ if (left != -1 && top != -1 && right != -1 && bottom != -1) {
+ insets.left = left;
+ insets.top = top;
+ insets.right = right;
+ insets.bottom = bottom;
+ }
+ }
+ private void sizeChanged(int newWidth, int newHeight) {
+ width = newWidth;
+ height = newHeight;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
+ }
+
+ private void positionChanged(int newX, int newY) {
+ x = newX;
+ y = newY;
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
+ }
+
+ /**
+ *
+ * @param focusOwner if focusGained is true, focusOwner is the previous
+ * focus owner, if focusGained is false, focusOwner is the new focus owner
+ * @param focusGained
+ */
+ private void focusChanged(long focusOwner, boolean focusGained) {
+ if (focusGained) {
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
+ } else {
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_LOST_FOCUS);
+ }
+ }
+}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/x11/X11Display.java b/src/newt/classes/com/jogamp/javafx/newt/x11/X11Display.java
new file mode 100755
index 000000000..96d55c082
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/x11/X11Display.java
@@ -0,0 +1,120 @@
+/*
+ * 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.jogamp.javafx.newt.x11;
+
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.x11.*;
+import com.jogamp.javafx.newt.*;
+import com.jogamp.javafx.newt.impl.*;
+import com.jogamp.nativewindow.impl.x11.X11Util;
+
+public class X11Display extends Display {
+ static {
+ NativeLibLoader.loadNEWT();
+
+ if (!initIDs()) {
+ throw new NativeWindowException("Failed to initialize X11Display jmethodIDs");
+ }
+
+ if (!X11Window.initIDs()) {
+ throw new NativeWindowException("Failed to initialize X11Window jmethodIDs");
+ }
+ }
+
+ public static void initSingleton() {
+ // just exist to ensure static init has been run
+ }
+
+
+ public X11Display() {
+ }
+
+ protected void createNative() {
+ long handle= X11Util.getThreadLocalDisplay(name);
+ if (handle == 0 ) {
+ throw new RuntimeException("Error creating display: "+name);
+ }
+ try {
+ CompleteDisplay(handle);
+ } catch(RuntimeException e) {
+ X11Util.closeThreadLocalDisplay(name);
+ throw e;
+ }
+ aDevice = new X11GraphicsDevice(handle);
+ }
+
+ protected void closeNative() {
+ if(0==X11Util.closeThreadLocalDisplay(name)) {
+ throw new NativeWindowException(this+" was not mapped");
+ }
+ }
+
+ protected void dispatchMessages() {
+ DispatchMessages(getHandle(), javaObjectAtom, windowDeleteAtom);
+ }
+
+ protected void lockDisplay() {
+ super.lockDisplay();
+ LockDisplay(getHandle());
+ }
+
+ protected void unlockDisplay() {
+ UnlockDisplay(getHandle());
+ super.unlockDisplay();
+ }
+
+ protected long getJavaObjectAtom() { return javaObjectAtom; }
+ protected long getWindowDeleteAtom() { return windowDeleteAtom; }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+ private static native boolean initIDs();
+
+ private native void LockDisplay(long handle);
+ private native void UnlockDisplay(long handle);
+
+ private native void CompleteDisplay(long handle);
+
+ private native void DispatchMessages(long display, long javaObjectAtom, long windowDeleteAtom);
+
+ private void displayCompleted(long javaObjectAtom, long windowDeleteAtom) {
+ this.javaObjectAtom=javaObjectAtom;
+ this.windowDeleteAtom=windowDeleteAtom;
+ }
+
+ private long windowDeleteAtom;
+ private long javaObjectAtom;
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/x11/X11Screen.java b/src/newt/classes/com/jogamp/javafx/newt/x11/X11Screen.java
new file mode 100755
index 000000000..d90b1868d
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/x11/X11Screen.java
@@ -0,0 +1,71 @@
+/*
+ * 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.jogamp.javafx.newt.x11;
+
+import com.jogamp.javafx.newt.*;
+import com.jogamp.javafx.newt.impl.*;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.x11.*;
+
+public class X11Screen extends Screen {
+
+ static {
+ X11Display.initSingleton();
+ }
+
+
+ public X11Screen() {
+ }
+
+ protected void createNative(int index) {
+ long handle = GetScreen(display.getHandle(), index);
+ if (handle == 0 ) {
+ throw new RuntimeException("Error creating screen: "+index);
+ }
+ aScreen = new X11GraphicsScreen((X11GraphicsDevice)getDisplay().getGraphicsDevice(), index);
+ setScreenSize(getWidth0(display.getHandle(), index),
+ getHeight0(display.getHandle(), index));
+ }
+
+ protected void closeNative() { }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ private native long GetScreen(long dpy, int scrn_idx);
+ private native int getWidth0(long display, int scrn_idx);
+ private native int getHeight0(long display, int scrn_idx);
+}
+
diff --git a/src/newt/classes/com/jogamp/javafx/newt/x11/X11Window.java b/src/newt/classes/com/jogamp/javafx/newt/x11/X11Window.java
new file mode 100755
index 000000000..8387160c9
--- /dev/null
+++ b/src/newt/classes/com/jogamp/javafx/newt/x11/X11Window.java
@@ -0,0 +1,203 @@
+/*
+ * 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.jogamp.javafx.newt.x11;
+
+import com.jogamp.javafx.newt.*;
+import com.jogamp.javafx.newt.impl.*;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.x11.*;
+
+public class X11Window extends Window {
+ private static final String WINDOW_CLASS_NAME = "NewtWindow";
+ // non fullscreen dimensions ..
+ private int nfs_width, nfs_height, nfs_x, nfs_y;
+
+ static {
+ X11Display.initSingleton();
+ }
+
+ public X11Window() {
+ }
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ X11Screen screen = (X11Screen) getScreen();
+ X11Display display = (X11Display) screen.getDisplay();
+ config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
+ if (config == null) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+ X11GraphicsConfiguration x11config = (X11GraphicsConfiguration) config;
+ long visualID = x11config.getVisualID();
+ long w = CreateWindow(parentWindowHandle,
+ display.getHandle(), screen.getIndex(), visualID,
+ display.getJavaObjectAtom(), display.getWindowDeleteAtom(), x, y, width, height);
+ if (w == 0 || w!=windowHandle) {
+ throw new NativeWindowException("Error creating window: "+w);
+ }
+ this.parentWindowHandle = parentWindowHandle;
+ windowHandleClose = windowHandle;
+ displayHandleClose = display.getHandle();
+ }
+
+ protected void closeNative() {
+ if(0!=displayHandleClose && 0!=windowHandleClose && null!=getScreen() ) {
+ X11Display display = (X11Display) getScreen().getDisplay();
+ CloseWindow(displayHandleClose, windowHandleClose, display.getJavaObjectAtom());
+ windowHandleClose = 0;
+ displayHandleClose = 0;
+ }
+ }
+
+ protected void windowDestroyed() {
+ windowHandleClose = 0;
+ displayHandleClose = 0;
+ super.windowDestroyed();
+ }
+
+ public void setVisible(boolean visible) {
+ if(0!=windowHandle && this.visible!=visible) {
+ this.visible=visible;
+ setVisible0(getDisplayHandle(), windowHandle, visible);
+ clearEventMask();
+ }
+ }
+
+ public void requestFocus() {
+ super.requestFocus();
+ }
+
+ public void setSize(int width, int height) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("X11Window setSize: "+this.x+"/"+this.y+" "+this.width+"x"+this.height+" -> "+width+"x"+height);
+ // Exception e = new Exception("XXXXXXXXXX");
+ // e.printStackTrace();
+ }
+ this.width = width;
+ this.height = height;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ if(0!=windowHandle) {
+ setSize0(parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, width, height, (undecorated||fullscreen)?-1:1, false);
+ }
+ }
+
+ public void setPosition(int x, int y) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("X11Window setPosition: "+this.x+"/"+this.y+" -> "+x+"/"+y);
+ // Exception e = new Exception("XXXXXXXXXX");
+ // e.printStackTrace();
+ }
+ this.x = x;
+ this.y = y;
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ if(0!=windowHandle) {
+ setPosition0(getDisplayHandle(), windowHandle, x, y);
+ }
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ if(0!=windowHandle && this.fullscreen!=fullscreen) {
+ int x,y,w,h;
+ this.fullscreen=fullscreen;
+ if(fullscreen) {
+ x = 0; y = 0;
+ w = screen.getWidth();
+ h = screen.getHeight();
+ } else {
+ x = nfs_x;
+ y = nfs_y;
+ w = nfs_width;
+ h = nfs_height;
+ }
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ System.err.println("X11Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
+ }
+ setSize0(parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, w, h, (undecorated||fullscreen)?-1:1, false);
+ }
+ return fullscreen;
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ protected static native boolean initIDs();
+ private native long CreateWindow(long parentWindowHandle, long display, int screen_index,
+ long visualID, long javaObjectAtom, long windowDeleteAtom, int x, int y, int width, int height);
+ private native void CloseWindow(long display, long windowHandle, long javaObjectAtom);
+ private native void setVisible0(long display, long windowHandle, boolean visible);
+ private native void setSize0(long parentWindowHandle, long display, int screen_index, long windowHandle,
+ int x, int y, int width, int height, int decorationToggle, boolean setVisible);
+ private native void setPosition0(long display, long windowHandle, int x, int y);
+
+ private void windowChanged(int newX, int newY, int newWidth, int newHeight) {
+ if(width != newWidth || height != newHeight) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("X11Window windowChanged size: "+this.width+"x"+this.height+" -> "+newWidth+"x"+newHeight);
+ }
+ width = newWidth;
+ height = newHeight;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
+ }
+ if( 0==parentWindowHandle && ( x != newX || y != newY ) ) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("X11Window windowChanged position: "+this.x+"/"+this.y+" -> "+newX+"x"+newY);
+ }
+ x = newX;
+ y = newY;
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
+ }
+ }
+
+ private void windowCreated(long windowHandle) {
+ this.windowHandle = windowHandle;
+ }
+
+ private long windowHandleClose;
+ private long displayHandleClose;
+ private long parentWindowHandle;
+}
diff --git a/src/newt/classes/com/sun/javafx/newt/Display.java b/src/newt/classes/com/sun/javafx/newt/Display.java
deleted file mode 100755
index a4b7a4f51..000000000
--- a/src/newt/classes/com/sun/javafx/newt/Display.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * 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 javax.media.nativewindow.*;
-import com.sun.javafx.newt.impl.Debug;
-import com.sun.javafx.newt.util.EventDispatchThread;
-import java.util.*;
-
-public abstract class Display {
- public static final boolean DEBUG = Debug.debug("Display");
-
- private static Class getDisplayClass(String type)
- throws ClassNotFoundException
- {
- Class displayClass = NewtFactory.getCustomClass(type, "Display");
- if(null==displayClass) {
- if (NativeWindowFactory.TYPE_EGL.equals(type)) {
- displayClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDDisplay");
- } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
- displayClass = Class.forName("com.sun.javafx.newt.windows.WindowsDisplay");
- } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
- displayClass = Class.forName("com.sun.javafx.newt.macosx.MacDisplay");
- } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
- displayClass = Class.forName("com.sun.javafx.newt.x11.X11Display");
- } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
- displayClass = Class.forName("com.sun.javafx.newt.awt.AWTDisplay");
- } else {
- throw new RuntimeException("Unknown display type \"" + type + "\"");
- }
- }
- return displayClass;
- }
-
- // Unique Display for each thread
- private static ThreadLocal currentDisplayMap = new ThreadLocal();
-
- /** Returns the thread local display map */
- public static Map getCurrentDisplayMap() {
- Map displayMap = (Map) currentDisplayMap.get();
- if(null==displayMap) {
- displayMap = new HashMap();
- currentDisplayMap.set( displayMap );
- }
- return displayMap;
- }
-
- /** maps the given display to the thread local display map
- * and notifies all threads synchronized to this display map. */
- protected static Display setCurrentDisplay(Display display) {
- Map displayMap = getCurrentDisplayMap();
- Display oldDisplay = null;
- synchronized(displayMap) {
- String name = display.getName();
- if(null==name) name="nil";
- oldDisplay = (Display) displayMap.put(name, display);
- displayMap.notifyAll();
- }
- return oldDisplay;
- }
-
- /** removes the mapping of the given name from the thread local display map
- * and notifies all threads synchronized to this display map. */
- protected static Display removeCurrentDisplay(String name) {
- if(null==name) name="nil";
- Map displayMap = getCurrentDisplayMap();
- Display oldDisplay = null;
- synchronized(displayMap) {
- oldDisplay = (Display) displayMap.remove(name);
- displayMap.notifyAll();
- }
- return oldDisplay;
- }
-
- /** Returns the thread local display mapped to the given name */
- public static Display getCurrentDisplay(String name) {
- if(null==name) name="nil";
- Map displayMap = getCurrentDisplayMap();
- Display display = (Display) displayMap.get(name);
- return display;
- }
-
- public static void dumpDisplayMap(String prefix) {
- Map displayMap = getCurrentDisplayMap();
- Set entrySet = displayMap.entrySet();
- Iterator i = entrySet.iterator();
- System.err.println(prefix+" DisplayMap["+entrySet.size()+"] "+Thread.currentThread());
- for(int j=0; i.hasNext(); j++) {
- Map.Entry entry = (Map.Entry) i.next();
- System.err.println(" ["+j+"] "+entry.getKey()+" -> "+entry.getValue());
- }
- }
-
- /** Returns the thread local display collection */
- public static Collection getCurrentDisplays() {
- return getCurrentDisplayMap().values();
- }
-
- /** Make sure to reuse a Display with the same name */
- protected static Display create(String type, String name) {
- try {
- if(DEBUG) {
- dumpDisplayMap("Display.create("+name+") BEGIN");
- }
- Display display = getCurrentDisplay(name);
- if(null==display) {
- Class displayClass = getDisplayClass(type);
- display = (Display) displayClass.newInstance();
- display.name=name;
- display.refCount=1;
-
- if(NewtFactory.useEDT()) {
- Thread current = Thread.currentThread();
- display.eventDispatchThread = new EventDispatchThread(display, current.getThreadGroup(), current.getName());
- display.eventDispatchThread.start();
- final Display f_dpy = display;
- display.eventDispatchThread.invokeAndWait(new Runnable() {
- public void run() {
- f_dpy.createNative();
- }
- } );
- } else {
- display.createNative();
- }
- if(null==display.aDevice) {
- throw new RuntimeException("Display.createNative() failed to instanciate an AbstractGraphicsDevice");
- }
- setCurrentDisplay(display);
- if(DEBUG) {
- System.err.println("Display.create("+name+") NEW: "+display+" "+Thread.currentThread());
- }
- } else {
- synchronized(display) {
- display.refCount++;
- if(DEBUG) {
- System.err.println("Display.create("+name+") REUSE: refCount "+display.refCount+", "+display+" "+Thread.currentThread());
- }
- }
- }
- if(DEBUG) {
- dumpDisplayMap("Display.create("+name+") END");
- }
- return display;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- protected static Display wrapHandle(String type, String name, AbstractGraphicsDevice aDevice) {
- try {
- Class displayClass = getDisplayClass(type);
- Display display = (Display) displayClass.newInstance();
- display.name=name;
- display.aDevice=aDevice;
- return display;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public EventDispatchThread getEDT() { return eventDispatchThread; }
-
- public synchronized void destroy() {
- if(DEBUG) {
- dumpDisplayMap("Display.destroy("+name+") BEGIN");
- }
- refCount--;
- if(0==refCount) {
- removeCurrentDisplay(name);
- if(DEBUG) {
- System.err.println("Display.destroy("+name+") REMOVE: "+this+" "+Thread.currentThread());
- }
- if(null!=eventDispatchThread) {
- final Display f_dpy = this;
- final EventDispatchThread f_edt = eventDispatchThread;
- eventDispatchThread.invokeAndWait(new Runnable() {
- public void run() {
- f_dpy.closeNative();
- f_edt.stop();
- }
- } );
- } else {
- closeNative();
- }
- if(null!=eventDispatchThread) {
- eventDispatchThread.waitUntilStopped();
- eventDispatchThread=null;
- }
- aDevice = null;
- } else {
- if(DEBUG) {
- System.err.println("Display.destroy("+name+") KEEP: refCount "+refCount+", "+this+" "+Thread.currentThread());
- }
- }
- if(DEBUG) {
- dumpDisplayMap("Display.destroy("+name+") END");
- }
- }
-
- protected abstract void createNative();
- protected abstract void closeNative();
-
- public String getName() {
- return name;
- }
-
- public long getHandle() {
- if(null!=aDevice) {
- return aDevice.getHandle();
- }
- return 0;
- }
-
- public AbstractGraphicsDevice getGraphicsDevice() {
- return aDevice;
- }
-
- public void pumpMessages() {
- if(null!=eventDispatchThread) {
- dispatchMessages();
- } else {
- synchronized(this) {
- dispatchMessages();
- }
- }
- }
-
- public String toString() {
- return "NEWT-Display["+name+", refCount "+refCount+", "+aDevice+"]";
- }
-
- protected abstract void dispatchMessages();
-
- /** Default impl. nop - Currently only X11 needs a Display lock */
- protected void lockDisplay() { }
-
- /** Default impl. nop - Currently only X11 needs a Display lock */
- protected void unlockDisplay() { }
-
- protected EventDispatchThread eventDispatchThread = null;
- protected String name;
- protected int refCount;
- protected AbstractGraphicsDevice aDevice;
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/Event.java b/src/newt/classes/com/sun/javafx/newt/Event.java
deleted file mode 100644
index 3c045c52b..000000000
--- a/src/newt/classes/com/sun/javafx/newt/Event.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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;
-
-public class Event {
- private boolean isSystemEvent;
- private int eventType;
- private Window source;
- private long when;
-
- Event(boolean isSystemEvent, int eventType, Window source, long when) {
- this.isSystemEvent = isSystemEvent;
- this.eventType = eventType;
- this.source = source;
- this.when = when;
- }
-
- protected Event(int eventType, Window source, long when) {
- this(false, eventType, source, when);
- }
-
- /** Indicates whether this event was produced by the system or
- generated by user code. */
- public final boolean isSystemEvent() {
- return isSystemEvent;
- }
-
- /** Returns the event type of this event. */
- public final int getEventType() {
- return eventType;
- }
-
- /** Returns the source Window which produced this Event. */
- public final Window getSource() {
- return source;
- }
-
- /** Returns the timestamp, in milliseconds, of this event. */
- public final long getWhen() {
- return when;
- }
-
- public String toString() {
- return "Event[sys:"+isSystemEvent()+", source:"+getSource()+", when:"+getWhen()+"]";
- }
-
- public static String toHexString(int hex) {
- return "0x" + Integer.toHexString(hex);
- }
-
- public static String toHexString(long hex) {
- return "0x" + Long.toHexString(hex);
- }
-
-}
diff --git a/src/newt/classes/com/sun/javafx/newt/EventListener.java b/src/newt/classes/com/sun/javafx/newt/EventListener.java
deleted file mode 100644
index a312752fe..000000000
--- a/src/newt/classes/com/sun/javafx/newt/EventListener.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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;
-
-public interface EventListener
-{
- public static final int WINDOW = 1 << 0;
- public static final int MOUSE = 1 << 1;
- public static final int KEY = 1 << 2;
- public static final int SURFACE = 1 << 3;
-
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/InputEvent.java b/src/newt/classes/com/sun/javafx/newt/InputEvent.java
deleted file mode 100644
index b49c72e75..000000000
--- a/src/newt/classes/com/sun/javafx/newt/InputEvent.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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;
-
-public abstract class InputEvent extends Event
-{
- public static final int SHIFT_MASK = 1 << 0;
- public static final int CTRL_MASK = 1 << 1;
- public static final int META_MASK = 1 << 2;
- public static final int ALT_MASK = 1 << 3;
- public static final int ALT_GRAPH_MASK = 1 << 5;
- public static final int BUTTON1_MASK = 1 << 6;
- public static final int BUTTON2_MASK = 1 << 7;
- public static final int BUTTON3_MASK = 1 << 8;
-
- protected InputEvent(boolean sysEvent, int eventType, Window source, long when, int modifiers) {
- super(sysEvent, eventType, source, when);
- this.consumed=false;
- this.modifiers=modifiers;
- }
-
- public void consume() {
- consumed=true;
- }
-
- public boolean isConsumed() {
- return consumed;
- }
- public int getModifiers() {
- return modifiers;
- }
- public boolean isAltDown() {
- return (modifiers&ALT_MASK)!=0;
- }
- public boolean isAltGraphDown() {
- return (modifiers&ALT_GRAPH_MASK)!=0;
- }
- public boolean isControlDown() {
- return (modifiers&CTRL_MASK)!=0;
- }
- public boolean isMetaDown() {
- return (modifiers&META_MASK)!=0;
- }
- public boolean isShiftDown() {
- return (modifiers&SHIFT_MASK)!=0;
- }
-
- public boolean isButton1Down() {
- return (modifiers&BUTTON1_MASK)!=0;
- }
-
- public boolean isButton2Down() {
- return (modifiers&BUTTON2_MASK)!=0;
- }
-
- public boolean isButton3Down() {
- return (modifiers&BUTTON3_MASK)!=0;
- }
-
- public String toString() {
- return "InputEvent[modifiers:"+modifiers+"]";
- }
-
- private boolean consumed;
- private int modifiers;
-}
diff --git a/src/newt/classes/com/sun/javafx/newt/Insets.java b/src/newt/classes/com/sun/javafx/newt/Insets.java
deleted file mode 100644
index 7d379cd92..000000000
--- a/src/newt/classes/com/sun/javafx/newt/Insets.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2009 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;
-
-/**
- * Simple class representing insets.
- *
- * @author tdv
- */
-public class Insets implements Cloneable {
- public int top;
- public int left;
- public int bottom;
- public int right;
-
- /**
- * Creates and initializes a new Insets
object with the
- * specified top, left, bottom, and right insets.
- * @param top the inset from the top.
- * @param left the inset from the left.
- * @param bottom the inset from the bottom.
- * @param right the inset from the right.
- */
- public Insets(int top, int left, int bottom, int right) {
- this.top = top;
- this.left = left;
- this.bottom = bottom;
- this.right = right;
- }
-
- /**
- * Checks whether two insets objects are equal. Two instances
- * of Insets
are equal if the four integer values
- * of the fields top
, left
,
- * bottom
, and right
are all equal.
- * @return true
if the two insets are equal;
- * otherwise false
.
- */
- public boolean equals(Object obj) {
- if (obj instanceof Insets) {
- Insets insets = (Insets)obj;
- return ((top == insets.top) && (left == insets.left) &&
- (bottom == insets.bottom) && (right == insets.right));
- }
- return false;
- }
-
- /**
- * Returns the hash code for this Insets.
- *
- * @return a hash code for this Insets.
- */
- public int hashCode() {
- int sum1 = left + bottom;
- int sum2 = right + top;
- int val1 = sum1 * (sum1 + 1)/2 + left;
- int val2 = sum2 * (sum2 + 1)/2 + top;
- int sum3 = val1 + val2;
- return sum3 * (sum3 + 1)/2 + val2;
- }
-
- public String toString() {
- return getClass().getName() + "[top=" + top + ",left=" + left +
- ",bottom=" + bottom + ",right=" + right + "]";
- }
-
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
-}
diff --git a/src/newt/classes/com/sun/javafx/newt/KeyEvent.java b/src/newt/classes/com/sun/javafx/newt/KeyEvent.java
deleted file mode 100644
index c7450da67..000000000
--- a/src/newt/classes/com/sun/javafx/newt/KeyEvent.java
+++ /dev/null
@@ -1,738 +0,0 @@
-/*
- * 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;
-
-public class KeyEvent extends InputEvent
-{
- KeyEvent(boolean sysEvent, int eventType, Window source, long when, int modifiers, int keyCode, char keyChar) {
- super(sysEvent, eventType, source, when, modifiers);
- this.keyCode=keyCode;
- this.keyChar=keyChar;
- }
- public KeyEvent(int eventType, Window source, long when, int modifiers, int keyCode, char keyChar) {
- this(false, eventType, source, when, modifiers, keyCode, keyChar);
- }
-
- public char getKeyChar() {
- return keyChar;
- }
- public int getKeyCode() {
- return keyCode;
- }
-
- public String toString() {
- return "KeyEvent["+getEventTypeString(getEventType())+
- ", code "+keyCode+"("+toHexString(keyCode)+"), char <"+keyChar+"> ("+toHexString((int)keyChar)+"), isActionKey "+isActionKey()+", "+super.toString()+"]";
- }
-
- public static String getEventTypeString(int type) {
- switch(type) {
- case EVENT_KEY_PRESSED: return "EVENT_KEY_PRESSED";
- case EVENT_KEY_RELEASED: return "EVENT_KEY_RELEASED";
- case EVENT_KEY_TYPED: return "EVENT_KEY_TYPED";
- default: return "unknown (" + type + ")";
- }
- }
-
- public boolean isActionKey() {
- switch (keyCode) {
- case VK_HOME:
- case VK_END:
- case VK_PAGE_UP:
- case VK_PAGE_DOWN:
- case VK_UP:
- case VK_DOWN:
- case VK_LEFT:
- case VK_RIGHT:
-
- case VK_F1:
- case VK_F2:
- case VK_F3:
- case VK_F4:
- case VK_F5:
- case VK_F6:
- case VK_F7:
- case VK_F8:
- case VK_F9:
- case VK_F10:
- case VK_F11:
- case VK_F12:
- case VK_F13:
- case VK_F14:
- case VK_F15:
- case VK_F16:
- case VK_F17:
- case VK_F18:
- case VK_F19:
- case VK_F20:
- case VK_F21:
- case VK_F22:
- case VK_F23:
- case VK_F24:
- case VK_PRINTSCREEN:
- case VK_CAPS_LOCK:
- case VK_PAUSE:
- case VK_INSERT:
-
- case VK_HELP:
- case VK_WINDOWS:
- return true;
- }
- return false;
- }
-
- private int keyCode;
- private char keyChar;
-
- public static final int EVENT_KEY_PRESSED = 300;
- public static final int EVENT_KEY_RELEASED= 301;
- public static final int EVENT_KEY_TYPED = 302;
-
- /* Virtual key codes. */
-
- public static final int VK_ENTER = '\n';
- public static final int VK_BACK_SPACE = '\b';
- public static final int VK_TAB = '\t';
- public static final int VK_CANCEL = 0x03;
- public static final int VK_CLEAR = 0x0C;
- public static final int VK_SHIFT = 0x10;
- public static final int VK_CONTROL = 0x11;
- public static final int VK_ALT = 0x12;
- public static final int VK_PAUSE = 0x13;
- public static final int VK_CAPS_LOCK = 0x14;
- public static final int VK_ESCAPE = 0x1B;
- public static final int VK_SPACE = 0x20;
- public static final int VK_PAGE_UP = 0x21;
- public static final int VK_PAGE_DOWN = 0x22;
- public static final int VK_END = 0x23;
- public static final int VK_HOME = 0x24;
-
- /**
- * Constant for the non-numpad left arrow key.
- * @see #VK_KP_LEFT
- */
- public static final int VK_LEFT = 0x25;
-
- /**
- * Constant for the non-numpad up arrow key.
- * @see #VK_KP_UP
- */
- public static final int VK_UP = 0x26;
-
- /**
- * Constant for the non-numpad right arrow key.
- * @see #VK_KP_RIGHT
- */
- public static final int VK_RIGHT = 0x27;
-
- /**
- * Constant for the non-numpad down arrow key.
- * @see #VK_KP_DOWN
- */
- public static final int VK_DOWN = 0x28;
-
- /**
- * Constant for the comma key, ","
- */
- public static final int VK_COMMA = 0x2C;
-
- /**
- * Constant for the minus key, "-"
- * @since 1.2
- */
- public static final int VK_MINUS = 0x2D;
-
- /**
- * Constant for the period key, "."
- */
- public static final int VK_PERIOD = 0x2E;
-
- /**
- * Constant for the forward slash key, "/"
- */
- public static final int VK_SLASH = 0x2F;
-
- /** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
- public static final int VK_0 = 0x30;
- public static final int VK_1 = 0x31;
- public static final int VK_2 = 0x32;
- public static final int VK_3 = 0x33;
- public static final int VK_4 = 0x34;
- public static final int VK_5 = 0x35;
- public static final int VK_6 = 0x36;
- public static final int VK_7 = 0x37;
- public static final int VK_8 = 0x38;
- public static final int VK_9 = 0x39;
-
- /**
- * Constant for the semicolon key, ";"
- */
- public static final int VK_SEMICOLON = 0x3B;
-
- /**
- * Constant for the equals key, "="
- */
- public static final int VK_EQUALS = 0x3D;
-
- /** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
- public static final int VK_A = 0x41;
- public static final int VK_B = 0x42;
- public static final int VK_C = 0x43;
- public static final int VK_D = 0x44;
- public static final int VK_E = 0x45;
- public static final int VK_F = 0x46;
- public static final int VK_G = 0x47;
- public static final int VK_H = 0x48;
- public static final int VK_I = 0x49;
- public static final int VK_J = 0x4A;
- public static final int VK_K = 0x4B;
- public static final int VK_L = 0x4C;
- public static final int VK_M = 0x4D;
- public static final int VK_N = 0x4E;
- public static final int VK_O = 0x4F;
- public static final int VK_P = 0x50;
- public static final int VK_Q = 0x51;
- public static final int VK_R = 0x52;
- public static final int VK_S = 0x53;
- public static final int VK_T = 0x54;
- public static final int VK_U = 0x55;
- public static final int VK_V = 0x56;
- public static final int VK_W = 0x57;
- public static final int VK_X = 0x58;
- public static final int VK_Y = 0x59;
- public static final int VK_Z = 0x5A;
-
- /**
- * Constant for the open bracket key, "["
- */
- public static final int VK_OPEN_BRACKET = 0x5B;
-
- /**
- * Constant for the back slash key, "\"
- */
- public static final int VK_BACK_SLASH = 0x5C;
-
- /**
- * Constant for the close bracket key, "]"
- */
- public static final int VK_CLOSE_BRACKET = 0x5D;
-
- public static final int VK_NUMPAD0 = 0x60;
- public static final int VK_NUMPAD1 = 0x61;
- public static final int VK_NUMPAD2 = 0x62;
- public static final int VK_NUMPAD3 = 0x63;
- public static final int VK_NUMPAD4 = 0x64;
- public static final int VK_NUMPAD5 = 0x65;
- public static final int VK_NUMPAD6 = 0x66;
- public static final int VK_NUMPAD7 = 0x67;
- public static final int VK_NUMPAD8 = 0x68;
- public static final int VK_NUMPAD9 = 0x69;
- public static final int VK_MULTIPLY = 0x6A;
- public static final int VK_ADD = 0x6B;
-
- /**
- * This constant is obsolete, and is included only for backwards
- * compatibility.
- * @see #VK_SEPARATOR
- */
- public static final int VK_SEPARATER = 0x6C;
-
- /**
- * Constant for the Numpad Separator key.
- * @since 1.4
- */
- public static final int VK_SEPARATOR = VK_SEPARATER;
-
- public static final int VK_SUBTRACT = 0x6D;
- public static final int VK_DECIMAL = 0x6E;
- public static final int VK_DIVIDE = 0x6F;
- public static final int VK_DELETE = 0x7F; /* ASCII DEL */
- public static final int VK_NUM_LOCK = 0x90;
- public static final int VK_SCROLL_LOCK = 0x91;
-
- /** Constant for the F1 function key. */
- public static final int VK_F1 = 0x70;
-
- /** Constant for the F2 function key. */
- public static final int VK_F2 = 0x71;
-
- /** Constant for the F3 function key. */
- public static final int VK_F3 = 0x72;
-
- /** Constant for the F4 function key. */
- public static final int VK_F4 = 0x73;
-
- /** Constant for the F5 function key. */
- public static final int VK_F5 = 0x74;
-
- /** Constant for the F6 function key. */
- public static final int VK_F6 = 0x75;
-
- /** Constant for the F7 function key. */
- public static final int VK_F7 = 0x76;
-
- /** Constant for the F8 function key. */
- public static final int VK_F8 = 0x77;
-
- /** Constant for the F9 function key. */
- public static final int VK_F9 = 0x78;
-
- /** Constant for the F10 function key. */
- public static final int VK_F10 = 0x79;
-
- /** Constant for the F11 function key. */
- public static final int VK_F11 = 0x7A;
-
- /** Constant for the F12 function key. */
- public static final int VK_F12 = 0x7B;
-
- /**
- * Constant for the F13 function key.
- * @since 1.2
- */
- /* F13 - F24 are used on IBM 3270 keyboard; use random range for constants. */
- public static final int VK_F13 = 0xF000;
-
- /**
- * Constant for the F14 function key.
- * @since 1.2
- */
- public static final int VK_F14 = 0xF001;
-
- /**
- * Constant for the F15 function key.
- * @since 1.2
- */
- public static final int VK_F15 = 0xF002;
-
- /**
- * Constant for the F16 function key.
- * @since 1.2
- */
- public static final int VK_F16 = 0xF003;
-
- /**
- * Constant for the F17 function key.
- * @since 1.2
- */
- public static final int VK_F17 = 0xF004;
-
- /**
- * Constant for the F18 function key.
- * @since 1.2
- */
- public static final int VK_F18 = 0xF005;
-
- /**
- * Constant for the F19 function key.
- * @since 1.2
- */
- public static final int VK_F19 = 0xF006;
-
- /**
- * Constant for the F20 function key.
- * @since 1.2
- */
- public static final int VK_F20 = 0xF007;
-
- /**
- * Constant for the F21 function key.
- * @since 1.2
- */
- public static final int VK_F21 = 0xF008;
-
- /**
- * Constant for the F22 function key.
- * @since 1.2
- */
- public static final int VK_F22 = 0xF009;
-
- /**
- * Constant for the F23 function key.
- * @since 1.2
- */
- public static final int VK_F23 = 0xF00A;
-
- /**
- * Constant for the F24 function key.
- * @since 1.2
- */
- public static final int VK_F24 = 0xF00B;
-
- public static final int VK_PRINTSCREEN = 0x9A;
- public static final int VK_INSERT = 0x9B;
- public static final int VK_HELP = 0x9C;
- public static final int VK_META = 0x9D;
-
- public static final int VK_BACK_QUOTE = 0xC0;
- public static final int VK_QUOTE = 0xDE;
-
- /**
- * Constant for the numeric keypad up arrow key.
- * @see #VK_UP
- * @since 1.2
- */
- public static final int VK_KP_UP = 0xE0;
-
- /**
- * Constant for the numeric keypad down arrow key.
- * @see #VK_DOWN
- * @since 1.2
- */
- public static final int VK_KP_DOWN = 0xE1;
-
- /**
- * Constant for the numeric keypad left arrow key.
- * @see #VK_LEFT
- * @since 1.2
- */
- public static final int VK_KP_LEFT = 0xE2;
-
- /**
- * Constant for the numeric keypad right arrow key.
- * @see #VK_RIGHT
- * @since 1.2
- */
- public static final int VK_KP_RIGHT = 0xE3;
-
- /* For European keyboards */
- /** @since 1.2 */
- public static final int VK_DEAD_GRAVE = 0x80;
- /** @since 1.2 */
- public static final int VK_DEAD_ACUTE = 0x81;
- /** @since 1.2 */
- public static final int VK_DEAD_CIRCUMFLEX = 0x82;
- /** @since 1.2 */
- public static final int VK_DEAD_TILDE = 0x83;
- /** @since 1.2 */
- public static final int VK_DEAD_MACRON = 0x84;
- /** @since 1.2 */
- public static final int VK_DEAD_BREVE = 0x85;
- /** @since 1.2 */
- public static final int VK_DEAD_ABOVEDOT = 0x86;
- /** @since 1.2 */
- public static final int VK_DEAD_DIAERESIS = 0x87;
- /** @since 1.2 */
- public static final int VK_DEAD_ABOVERING = 0x88;
- /** @since 1.2 */
- public static final int VK_DEAD_DOUBLEACUTE = 0x89;
- /** @since 1.2 */
- public static final int VK_DEAD_CARON = 0x8a;
- /** @since 1.2 */
- public static final int VK_DEAD_CEDILLA = 0x8b;
- /** @since 1.2 */
- public static final int VK_DEAD_OGONEK = 0x8c;
- /** @since 1.2 */
- public static final int VK_DEAD_IOTA = 0x8d;
- /** @since 1.2 */
- public static final int VK_DEAD_VOICED_SOUND = 0x8e;
- /** @since 1.2 */
- public static final int VK_DEAD_SEMIVOICED_SOUND = 0x8f;
-
- /** @since 1.2 */
- public static final int VK_AMPERSAND = 0x96;
- /** @since 1.2 */
- public static final int VK_ASTERISK = 0x97;
- /** @since 1.2 */
- public static final int VK_QUOTEDBL = 0x98;
- /** @since 1.2 */
- public static final int VK_LESS = 0x99;
-
- /** @since 1.2 */
- public static final int VK_GREATER = 0xa0;
- /** @since 1.2 */
- public static final int VK_BRACELEFT = 0xa1;
- /** @since 1.2 */
- public static final int VK_BRACERIGHT = 0xa2;
-
- /**
- * Constant for the "@" key.
- * @since 1.2
- */
- public static final int VK_AT = 0x0200;
-
- /**
- * Constant for the ":" key.
- * @since 1.2
- */
- public static final int VK_COLON = 0x0201;
-
- /**
- * Constant for the "^" key.
- * @since 1.2
- */
- public static final int VK_CIRCUMFLEX = 0x0202;
-
- /**
- * Constant for the "$" key.
- * @since 1.2
- */
- public static final int VK_DOLLAR = 0x0203;
-
- /**
- * Constant for the Euro currency sign key.
- * @since 1.2
- */
- public static final int VK_EURO_SIGN = 0x0204;
-
- /**
- * Constant for the "!" key.
- * @since 1.2
- */
- public static final int VK_EXCLAMATION_MARK = 0x0205;
-
- /**
- * Constant for the inverted exclamation mark key.
- * @since 1.2
- */
- public static final int VK_INVERTED_EXCLAMATION_MARK = 0x0206;
-
- /**
- * Constant for the "(" key.
- * @since 1.2
- */
- public static final int VK_LEFT_PARENTHESIS = 0x0207;
-
- /**
- * Constant for the "#" key.
- * @since 1.2
- */
- public static final int VK_NUMBER_SIGN = 0x0208;
-
- /**
- * Constant for the "+" key.
- * @since 1.2
- */
- public static final int VK_PLUS = 0x0209;
-
- /**
- * Constant for the ")" key.
- * @since 1.2
- */
- public static final int VK_RIGHT_PARENTHESIS = 0x020A;
-
- /**
- * Constant for the "_" key.
- * @since 1.2
- */
- public static final int VK_UNDERSCORE = 0x020B;
-
- /**
- * Constant for the Microsoft Windows "Windows" key.
- * It is used for both the left and right version of the key.
- * @see #getKeyLocation()
- * @since 1.5
- */
- public static final int VK_WINDOWS = 0x020C;
-
- /**
- * Constant for the Microsoft Windows Context Menu key.
- * @since 1.5
- */
- public static final int VK_CONTEXT_MENU = 0x020D;
-
- /* for input method support on Asian Keyboards */
-
- /* not clear what this means - listed in Microsoft Windows API */
- public static final int VK_FINAL = 0x0018;
-
- /** Constant for the Convert function key. */
- /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */
- public static final int VK_CONVERT = 0x001C;
-
- /** Constant for the Don't Convert function key. */
- /* Japanese PC 106 keyboard: muhenkan */
- public static final int VK_NONCONVERT = 0x001D;
-
- /** Constant for the Accept or Commit function key. */
- /* Japanese Solaris keyboard: kakutei */
- public static final int VK_ACCEPT = 0x001E;
-
- /* not clear what this means - listed in Microsoft Windows API */
- public static final int VK_MODECHANGE = 0x001F;
-
- /* replaced by VK_KANA_LOCK for Microsoft Windows and Solaris;
- might still be used on other platforms */
- public static final int VK_KANA = 0x0015;
-
- /* replaced by VK_INPUT_METHOD_ON_OFF for Microsoft Windows and Solaris;
- might still be used for other platforms */
- public static final int VK_KANJI = 0x0019;
-
- /**
- * Constant for the Alphanumeric function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard: eisuu */
- public static final int VK_ALPHANUMERIC = 0x00F0;
-
- /**
- * Constant for the Katakana function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard: katakana */
- public static final int VK_KATAKANA = 0x00F1;
-
- /**
- * Constant for the Hiragana function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard: hiragana */
- public static final int VK_HIRAGANA = 0x00F2;
-
- /**
- * Constant for the Full-Width Characters function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard: zenkaku */
- public static final int VK_FULL_WIDTH = 0x00F3;
-
- /**
- * Constant for the Half-Width Characters function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard: hankaku */
- public static final int VK_HALF_WIDTH = 0x00F4;
-
- /**
- * Constant for the Roman Characters function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard: roumaji */
- public static final int VK_ROMAN_CHARACTERS = 0x00F5;
-
- /**
- * Constant for the All Candidates function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */
- public static final int VK_ALL_CANDIDATES = 0x0100;
-
- /**
- * Constant for the Previous Candidate function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */
- public static final int VK_PREVIOUS_CANDIDATE = 0x0101;
-
- /**
- * Constant for the Code Input function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */
- public static final int VK_CODE_INPUT = 0x0102;
-
- /**
- * Constant for the Japanese-Katakana function key.
- * This key switches to a Japanese input method and selects its Katakana input mode.
- * @since 1.2
- */
- /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */
- public static final int VK_JAPANESE_KATAKANA = 0x0103;
-
- /**
- * Constant for the Japanese-Hiragana function key.
- * This key switches to a Japanese input method and selects its Hiragana input mode.
- * @since 1.2
- */
- /* Japanese Macintosh keyboard */
- public static final int VK_JAPANESE_HIRAGANA = 0x0104;
-
- /**
- * Constant for the Japanese-Roman function key.
- * This key switches to a Japanese input method and selects its Roman-Direct input mode.
- * @since 1.2
- */
- /* Japanese Macintosh keyboard */
- public static final int VK_JAPANESE_ROMAN = 0x0105;
-
- /**
- * Constant for the locking Kana function key.
- * This key locks the keyboard into a Kana layout.
- * @since 1.3
- */
- /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */
- public static final int VK_KANA_LOCK = 0x0106;
-
- /**
- * Constant for the input method on/off key.
- * @since 1.3
- */
- /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */
- public static final int VK_INPUT_METHOD_ON_OFF = 0x0107;
-
- /* for Sun keyboards */
- /** @since 1.2 */
- public static final int VK_CUT = 0xFFD1;
- /** @since 1.2 */
- public static final int VK_COPY = 0xFFCD;
- /** @since 1.2 */
- public static final int VK_PASTE = 0xFFCF;
- /** @since 1.2 */
- public static final int VK_UNDO = 0xFFCB;
- /** @since 1.2 */
- public static final int VK_AGAIN = 0xFFC9;
- /** @since 1.2 */
- public static final int VK_FIND = 0xFFD0;
- /** @since 1.2 */
- public static final int VK_PROPS = 0xFFCA;
- /** @since 1.2 */
- public static final int VK_STOP = 0xFFC8;
-
- /**
- * Constant for the Compose function key.
- * @since 1.2
- */
- public static final int VK_COMPOSE = 0xFF20;
-
- /**
- * Constant for the AltGraph function key.
- * @since 1.2
- */
- public static final int VK_ALT_GRAPH = 0xFF7E;
-
- /**
- * Constant for the Begin key.
- * @since 1.5
- */
- public static final int VK_BEGIN = 0xFF58;
-
- /**
- * This value is used to indicate that the keyCode is unknown.
- * KEY_TYPED events do not have a keyCode value; this value
- * is used instead.
- */
- public static final int VK_UNDEFINED = 0x0;
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/KeyListener.java b/src/newt/classes/com/sun/javafx/newt/KeyListener.java
deleted file mode 100644
index 6f022c45a..000000000
--- a/src/newt/classes/com/sun/javafx/newt/KeyListener.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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;
-
-public interface KeyListener extends EventListener
-{
- public void keyPressed(KeyEvent e);
- public void keyReleased(KeyEvent e);
- public void keyTyped(KeyEvent e) ;
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/MouseEvent.java b/src/newt/classes/com/sun/javafx/newt/MouseEvent.java
deleted file mode 100644
index ede193e1c..000000000
--- a/src/newt/classes/com/sun/javafx/newt/MouseEvent.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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;
-
-public class MouseEvent extends InputEvent
-{
- public static final int BUTTON1 = 1;
- public static final int BUTTON2 = 2;
- public static final int BUTTON3 = 3;
- public static final int BUTTON4 = 4;
- public static final int BUTTON5 = 5;
- public static final int BUTTON6 = 6;
- public static final int BUTTON_NUMBER = 6;
-
- protected MouseEvent(boolean sysEvent, int eventType, Window source, long when,
- int modifiers, int x, int y, int clickCount, int button,
- int rotation)
- {
- super(sysEvent, eventType, source, when, modifiers);
- this.x=x;
- this.y=y;
- this.clickCount=clickCount;
- this.button=button;
- this.wheelRotation = rotation;
- }
- public MouseEvent(int eventType, Window source, long when, int modifiers,
- int x, int y, int clickCount, int button, int rotation) {
- this(false, eventType, source, when, modifiers, x, y, clickCount, button,
- rotation);
- }
-
- public int getButton() {
- return button;
- }
- public int getClickCount() {
- return clickCount;
- }
- public int getX() {
- return x;
- }
- public int getY() {
- return y;
- }
- public int getWheelRotation() {
- return wheelRotation;
- }
-
- public String toString() {
- return "MouseEvent["+getEventTypeString(getEventType())+
- ", "+x+"/"+y+", button "+button+", count "+clickCount+
- ", wheel rotation "+wheelRotation+
- ", "+super.toString()+"]";
- }
-
- public static String getEventTypeString(int type) {
- switch(type) {
- case EVENT_MOUSE_CLICKED: return "EVENT_MOUSE_CLICKED";
- case EVENT_MOUSE_ENTERED: return "EVENT_MOUSE_ENTERED";
- case EVENT_MOUSE_EXITED: return "EVENT_MOUSE_EXITED";
- case EVENT_MOUSE_PRESSED: return "EVENT_MOUSE_PRESSED";
- case EVENT_MOUSE_RELEASED: return "EVENT_MOUSE_RELEASED";
- case EVENT_MOUSE_MOVED: return "EVENT_MOUSE_MOVED";
- case EVENT_MOUSE_DRAGGED: return "EVENT_MOUSE_DRAGGED";
- case EVENT_MOUSE_WHEEL_MOVED: return "EVENT_MOUSE_WHEEL_MOVED";
- default: return "unknown (" + type + ")";
- }
- }
-
- private int x, y, clickCount, button, wheelRotation;
-
- public static final int EVENT_MOUSE_CLICKED = 200;
- public static final int EVENT_MOUSE_ENTERED = 201;
- public static final int EVENT_MOUSE_EXITED = 202;
- public static final int EVENT_MOUSE_PRESSED = 203;
- public static final int EVENT_MOUSE_RELEASED = 204;
- public static final int EVENT_MOUSE_MOVED = 205;
- public static final int EVENT_MOUSE_DRAGGED = 206;
- public static final int EVENT_MOUSE_WHEEL_MOVED = 207;
-}
diff --git a/src/newt/classes/com/sun/javafx/newt/MouseListener.java b/src/newt/classes/com/sun/javafx/newt/MouseListener.java
deleted file mode 100644
index 3d2031f2a..000000000
--- a/src/newt/classes/com/sun/javafx/newt/MouseListener.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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;
-
-public interface MouseListener extends EventListener
-{
- public void mouseClicked(MouseEvent e);
- public void mouseEntered(MouseEvent e);
- public void mouseExited(MouseEvent e);
- public void mousePressed(MouseEvent e);
- public void mouseReleased(MouseEvent e);
- public void mouseMoved(MouseEvent e);
- public void mouseDragged(MouseEvent e);
- public void mouseWheelMoved(MouseEvent e);
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
deleted file mode 100755
index 6e25b19eb..000000000
--- a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * 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 javax.media.nativewindow.*;
-import java.util.ArrayList;
-import java.util.Iterator;
-import com.sun.nativewindow.impl.jvm.JVMUtil;
-
-public abstract class NewtFactory {
- // Work-around for initialization order problems on Mac OS X
- // between native Newt and (apparently) Fmod
- static {
- JVMUtil.initSingleton();
- Window.init(NativeWindowFactory.getNativeWindowType(true));
- }
-
- static Class getCustomClass(String packageName, String classBaseName) {
- Class clazz = null;
- if(packageName!=null || classBaseName!=null) {
- String clazzName = packageName + "." + classBaseName ;
- try {
- clazz = Class.forName(clazzName);
- } catch (Throwable t) {}
- }
- return clazz;
- }
-
- private static boolean useEDT = true;
-
- /**
- * Toggles the usage of an EventDispatchThread while creating a Display.
- * The default is enabled.
- * The EventDispatchThread is thread local to the Display instance.
- */
- public static synchronized void setUseEDT(boolean onoff) {
- useEDT = onoff;
- }
-
- /** @see #setUseEDT(boolean) */
- public static boolean useEDT() { return useEDT; }
-
- /**
- * Create a Display entity, incl native creation
- */
- public static Display createDisplay(String name) {
- return Display.create(NativeWindowFactory.getNativeWindowType(true), name);
- }
-
- /**
- * Create a Display entity using the given implementation type, incl native creation
- */
- public static Display createDisplay(String type, String name) {
- return Display.create(type, name);
- }
-
- /**
- * Create a Screen entity, incl native creation
- */
- public static Screen createScreen(Display display, int index) {
- return Screen.create(NativeWindowFactory.getNativeWindowType(true), display, index);
- }
-
- /**
- * Create a Screen entity using the given implementation type, incl native creation
- */
- public static Screen createScreen(String type, Display display, int index) {
- return Screen.create(type, display, index);
- }
-
- /**
- * Create a Window entity, incl native creation
- */
- public static Window createWindow(Screen screen, Capabilities caps) {
- return Window.create(NativeWindowFactory.getNativeWindowType(true), 0, screen, caps, false);
- }
-
- public static Window createWindow(Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(NativeWindowFactory.getNativeWindowType(true), 0, screen, caps, undecorated);
- }
-
- public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(NativeWindowFactory.getNativeWindowType(true), parentWindowHandle, screen, caps, undecorated);
- }
-
- /**
- * Ability to try a Window type with a construnctor argument, if supported .. AWTWindow(Frame frame)
,
- * to support an external created AWT Frame, ie the browsers embedded frame.
- */
- public static Window createWindow(Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(NativeWindowFactory.getNativeWindowType(true), cstrArguments, screen, caps, undecorated);
- }
-
- /**
- * Create a Window entity using the given implementation type, incl native creation
- */
- public static Window createWindow(String type, Screen screen, Capabilities caps) {
- return Window.create(type, 0, screen, caps, false);
- }
-
- public static Window createWindow(String type, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(type, 0, screen, caps, undecorated);
- }
-
- public static Window createWindow(String type, long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(type, parentWindowHandle, screen, caps, undecorated);
- }
-
- public static Window createWindow(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(type, cstrArguments, screen, caps, undecorated);
- }
-
- /**
- * Instantiate a Display entity using the native handle.
- */
- public static Display wrapDisplay(String name, AbstractGraphicsDevice device) {
- return Display.wrapHandle(NativeWindowFactory.getNativeWindowType(true), name, device);
- }
-
- /**
- * Instantiate a Screen entity using the native handle.
- */
- public static Screen wrapScreen(Display display, AbstractGraphicsScreen screen) {
- return Screen.wrapHandle(NativeWindowFactory.getNativeWindowType(true), display, screen);
- }
-
- /**
- * Instantiate a Window entity using the native handle.
- */
- public static Window wrapWindow(Screen screen, AbstractGraphicsConfiguration config,
- long windowHandle, boolean fullscreen, boolean visible,
- int x, int y, int width, int height) {
- return Window.wrapHandle(NativeWindowFactory.getNativeWindowType(true), screen, config,
- windowHandle, fullscreen, visible, x, y, width, height);
- }
-
- private static final boolean instanceOf(Object obj, String clazzName) {
- Class clazz = obj.getClass();
- do {
- if(clazz.getName().equals(clazzName)) {
- return true;
- }
- clazz = clazz.getSuperclass();
- } while (clazz!=null);
- return false;
- }
-
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java b/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java
deleted file mode 100644
index 11ce8e6c7..000000000
--- a/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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 javax.media.nativewindow.*;
-
-public class OffscreenWindow extends Window implements SurfaceChangeable {
-
- long surfaceHandle = 0;
-
- public OffscreenWindow() {
- }
-
- static long nextWindowHandle = 0x100; // start here - a marker
-
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- if(0!=parentWindowHandle) {
- throw new NativeWindowException("OffscreenWindow does not support window parenting");
- }
- if(caps.isOnscreen()) {
- throw new NativeWindowException("Capabilities is onscreen");
- }
- AbstractGraphicsScreen aScreen = screen.getGraphicsScreen();
- config = GraphicsConfigurationFactory.getFactory(aScreen.getDevice()).chooseGraphicsConfiguration(caps, null, aScreen);
- if (config == null) {
- throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
- }
-
- synchronized(OffscreenWindow.class) {
- windowHandle = nextWindowHandle++;
- }
- }
-
- protected void closeNative() {
- // nop
- }
-
- public void invalidate() {
- super.invalidate();
- surfaceHandle = 0;
- }
-
- public synchronized void destroy() {
- surfaceHandle = 0;
- }
-
- public void setSurfaceHandle(long handle) {
- surfaceHandle = handle ;
- }
-
- public long getSurfaceHandle() {
- return surfaceHandle;
- }
-
- public void setVisible(boolean visible) {
- if(!visible) {
- this.visible = visible;
- }
- }
-
- public void setSize(int width, int height) {
- if(!visible) {
- this.width = width;
- this.height = height;
- }
- }
-
- public void setPosition(int x, int y) {
- // nop
- }
-
- public boolean setFullscreen(boolean fullscreen) {
- // nop
- return false;
- }
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/PaintEvent.java b/src/newt/classes/com/sun/javafx/newt/PaintEvent.java
deleted file mode 100755
index b27b969da..000000000
--- a/src/newt/classes/com/sun/javafx/newt/PaintEvent.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2009 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;
-
-/**
- *
- * @author tdv
- */
-public class PaintEvent extends Event {
-
- // bounds of the damage region
- private int x, y, width, height;
- public PaintEvent(int eventType, Window source,
- long when, int x, int y, int w, int h)
- {
- super(true, eventType, source, when);
- this.x = x;
- this.y = y;
- this.width = w;
- this.height = h;
- }
-
- public int getHeight() {
- return height;
- }
-
- public int getWidth() {
- return width;
- }
-
- public int getX() {
- return x;
- }
-
- public int getY() {
- return y;
- }
-
- public String toString() {
- return "ExposeEvent[modifiers: x="+x+" y="+y+" w="+width+" h="+height +"]";
- }
-
-}
diff --git a/src/newt/classes/com/sun/javafx/newt/PaintListener.java b/src/newt/classes/com/sun/javafx/newt/PaintListener.java
deleted file mode 100755
index fab5fa35c..000000000
--- a/src/newt/classes/com/sun/javafx/newt/PaintListener.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2009 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;
-
-/**
- *
- * @author tdv
- */
-public interface PaintListener {
- public void exposed(PaintEvent e);
-}
diff --git a/src/newt/classes/com/sun/javafx/newt/Screen.java b/src/newt/classes/com/sun/javafx/newt/Screen.java
deleted file mode 100755
index 9edd0b719..000000000
--- a/src/newt/classes/com/sun/javafx/newt/Screen.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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 com.sun.javafx.newt.impl.*;
-
-import javax.media.nativewindow.*;
-import java.security.*;
-
-public abstract class Screen {
-
- private static Class getScreenClass(String type)
- throws ClassNotFoundException
- {
- Class screenClass = NewtFactory.getCustomClass(type, "Screen");
- if(null==screenClass) {
- if (NativeWindowFactory.TYPE_EGL.equals(type)) {
- screenClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDScreen");
- } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
- screenClass = Class.forName("com.sun.javafx.newt.windows.WindowsScreen");
- } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
- screenClass = Class.forName("com.sun.javafx.newt.macosx.MacScreen");
- } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
- screenClass = Class.forName("com.sun.javafx.newt.x11.X11Screen");
- } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
- screenClass = Class.forName("com.sun.javafx.newt.awt.AWTScreen");
- } else {
- throw new RuntimeException("Unknown window type \"" + type + "\"");
- }
- }
- return screenClass;
- }
-
- protected static Screen create(String type, Display display, int idx) {
- try {
- if(usrWidth<0 || usrHeight<0) {
- usrWidth = Debug.getIntProperty("newt.ws.swidth", true, localACC);
- usrHeight = Debug.getIntProperty("newt.ws.sheight", true, localACC);
- System.out.println("User screen size "+usrWidth+"x"+usrHeight);
- }
- Class screenClass = getScreenClass(type);
- Screen screen = (Screen) screenClass.newInstance();
- screen.display = display;
- screen.createNative(idx);
- if(null==screen.aScreen) {
- throw new RuntimeException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen");
- }
- return screen;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public synchronized void destroy() {
- closeNative();
- display = null;
- aScreen = null;
- }
-
- protected static Screen wrapHandle(String type, Display display, AbstractGraphicsScreen aScreen) {
- try {
- Class screenClass = getScreenClass(type);
- Screen screen = (Screen) screenClass.newInstance();
- screen.display = display;
- screen.aScreen = aScreen;
- return screen;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- protected abstract void createNative(int index);
- protected abstract void closeNative();
-
- protected void setScreenSize(int w, int h) {
- System.out.println("Detected screen size "+w+"x"+h);
- width=w; height=h;
- }
-
- public Display getDisplay() {
- return display;
- }
-
- public int getIndex() {
- return aScreen.getIndex();
- }
-
- public AbstractGraphicsScreen getGraphicsScreen() {
- return aScreen;
- }
-
- /**
- * The actual implementation shall return the detected display value,
- * if not we return 800.
- * This can be overwritten with the user property 'newt.ws.swidth',
- */
- public int getWidth() {
- return (usrWidth>0) ? usrWidth : (width>0) ? width : 480;
- }
-
- /**
- * The actual implementation shall return the detected display value,
- * if not we return 480.
- * This can be overwritten with the user property 'newt.ws.sheight',
- */
- public int getHeight() {
- return (usrHeight>0) ? usrHeight : (height>0) ? height : 480;
- }
-
- protected Display display;
- protected AbstractGraphicsScreen aScreen;
- protected int width=-1, height=-1; // detected values: set using setScreenSize
- protected static int usrWidth=-1, usrHeight=-1; // property values: newt.ws.swidth and newt.ws.sheight
- private static AccessControlContext localACC = AccessController.getContext();
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java
deleted file mode 100755
index 58bd251d2..000000000
--- a/src/newt/classes/com/sun/javafx/newt/Window.java
+++ /dev/null
@@ -1,929 +0,0 @@
-/*
- * 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 com.sun.javafx.newt.impl.Debug;
-import com.sun.javafx.newt.util.EventDispatchThread;
-
-import javax.media.nativewindow.*;
-import com.sun.nativewindow.impl.NWReflection;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.lang.reflect.Method;
-
-public abstract class Window implements NativeWindow
-{
- public static final boolean DEBUG_MOUSE_EVENT = Debug.debug("Window.MouseEvent");
- public static final boolean DEBUG_KEY_EVENT = Debug.debug("Window.KeyEvent");
- public static final boolean DEBUG_WINDOW_EVENT = Debug.debug("Window.WindowEvent");
- public static final boolean DEBUG_IMPLEMENTATION = Debug.debug("Window");
-
- // Workaround for initialization order problems on Mac OS X
- // between native Newt and (apparently) Fmod -- if Fmod is
- // initialized first then the connection to the window server
- // breaks, leading to errors from deep within the AppKit
- static void init(String type) {
- if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
- try {
- getWindowClass(type);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- private static Class getWindowClass(String type)
- throws ClassNotFoundException
- {
- Class windowClass = NewtFactory.getCustomClass(type, "Window");
- if(null==windowClass) {
- if (NativeWindowFactory.TYPE_EGL.equals(type)) {
- windowClass = Class.forName("com.sun.javafx.newt.opengl.kd.KDWindow");
- } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
- windowClass = Class.forName("com.sun.javafx.newt.windows.WindowsWindow");
- } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
- windowClass = Class.forName("com.sun.javafx.newt.macosx.MacWindow");
- } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
- windowClass = Class.forName("com.sun.javafx.newt.x11.X11Window");
- } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
- windowClass = Class.forName("com.sun.javafx.newt.awt.AWTWindow");
- } else {
- throw new NativeWindowException("Unknown window type \"" + type + "\"");
- }
- }
- return windowClass;
- }
-
- protected static Window create(String type, final long parentWindowHandle, Screen screen, final Capabilities caps, boolean undecorated) {
- try {
- Class windowClass;
- if(caps.isOnscreen()) {
- windowClass = getWindowClass(type);
- } else {
- windowClass = OffscreenWindow.class;
- }
- Window window = (Window) windowClass.newInstance();
- window.invalidate();
- window.screen = screen;
- window.setUndecorated(undecorated||0!=parentWindowHandle);
- EventDispatchThread edt = screen.getDisplay().getEDT();
- if(null!=edt) {
- final Window f_win = window;
- edt.invokeAndWait(new Runnable() {
- public void run() {
- f_win.createNative(parentWindowHandle, caps);
- }
- } );
- } else {
- window.createNative(parentWindowHandle, caps);
- }
- return window;
- } catch (Throwable t) {
- t.printStackTrace();
- throw new NativeWindowException(t);
- }
- }
-
- protected static Window create(String type, Object[] cstrArguments, Screen screen, final Capabilities caps, boolean undecorated) {
- try {
- Class windowClass = getWindowClass(type);
- Class[] cstrArgumentTypes = getCustomConstructorArgumentTypes(windowClass);
- if(null==cstrArgumentTypes) {
- throw new NativeWindowException("WindowClass "+windowClass+" doesn't support custom arguments in constructor");
- }
- int argsChecked = verifyConstructorArgumentTypes(cstrArgumentTypes, cstrArguments);
- if ( argsChecked < cstrArguments.length ) {
- throw new NativeWindowException("WindowClass "+windowClass+" constructor mismatch at argument #"+argsChecked+"; Constructor: "+getTypeStrList(cstrArgumentTypes)+", arguments: "+getArgsStrList(cstrArguments));
- }
- Window window = (Window) NWReflection.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ;
- window.invalidate();
- window.screen = screen;
- window.setUndecorated(undecorated);
- EventDispatchThread edt = screen.getDisplay().getEDT();
- if(null!=edt) {
- final Window f_win = window;
- edt.invokeAndWait(new Runnable() {
- public void run() {
- f_win.createNative(0, caps);
- }
- } );
- } else {
- window.createNative(0, caps);
- }
- return window;
- } catch (Throwable t) {
- t.printStackTrace();
- throw new NativeWindowException(t);
- }
- }
-
- protected static Window wrapHandle(String type, Screen screen, AbstractGraphicsConfiguration config,
- long windowHandle, boolean fullscreen, boolean visible,
- int x, int y, int width, int height)
- {
- try {
- Class windowClass = getWindowClass(type);
- Window window = (Window) windowClass.newInstance();
- window.invalidate();
- window.screen = screen;
- window.config = config;
- window.windowHandle = windowHandle;
- window.fullscreen=fullscreen;
- window.visible=visible;
- window.x=x;
- window.y=y;
- window.width=width;
- window.height=height;
- return window;
- } catch (Throwable t) {
- t.printStackTrace();
- throw new NativeWindowException(t);
- }
- }
-
- public static String toHexString(int hex) {
- return "0x" + Integer.toHexString(hex);
- }
-
- public static String toHexString(long hex) {
- return "0x" + Long.toHexString(hex);
- }
-
- protected Screen screen;
-
- protected AbstractGraphicsConfiguration config;
- protected long windowHandle;
- protected boolean fullscreen, visible;
- protected int width, height, x, y;
- protected int eventMask;
-
- protected String title = "Newt Window";
- protected boolean undecorated = false;
-
- /**
- * Create native windowHandle, ie creates a new native invisible window.
- *
- * The parentWindowHandle may be null, in which case no window parenting
- * is requested.
- *
- * Shall use the capabilities to determine the graphics configuration
- * and shall set the chosen capabilities.
- */
- protected abstract void createNative(long parentWindowHandle, Capabilities caps);
-
- protected abstract void closeNative();
-
- public Screen getScreen() {
- return screen;
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
-
- sb.append(getClass().getName()+"[config "+config+
- ", windowHandle "+toHexString(getWindowHandle())+
- ", surfaceHandle "+toHexString(getSurfaceHandle())+
- ", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
- ", visible "+isVisible()+
- ", undecorated "+undecorated+
- ", fullscreen "+fullscreen+
- ", "+screen+
- ", wrappedWindow "+getWrappedWindow());
-
- sb.append(", SurfaceUpdatedListeners num "+surfaceUpdatedListeners.size()+" [");
- for (Iterator iter = surfaceUpdatedListeners.iterator(); iter.hasNext(); ) {
- sb.append(iter.next()+", ");
- }
- sb.append("], WindowListeners num "+windowListeners.size()+" [");
- for (Iterator iter = windowListeners.iterator(); iter.hasNext(); ) {
- sb.append(iter.next()+", ");
- }
- sb.append("], MouseListeners num "+mouseListeners.size()+" [");
- for (Iterator iter = mouseListeners.iterator(); iter.hasNext(); ) {
- sb.append(iter.next()+", ");
- }
- sb.append("], KeyListeners num "+keyListeners.size()+" [");
- for (Iterator iter = keyListeners.iterator(); iter.hasNext(); ) {
- sb.append(iter.next()+", ");
- }
- sb.append("] ]");
- return sb.toString();
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public void setUndecorated(boolean value) {
- undecorated = value;
- }
-
- public boolean isUndecorated() {
- return undecorated;
- }
-
- public void requestFocus() {
- }
-
- //
- // NativeWindow impl
- //
- private Thread owner;
- private int recursionCount;
- protected Exception lockedStack = null;
-
- /** Recursive and blocking lockSurface() implementation */
- public synchronized int lockSurface() {
- // We leave the ToolkitLock lock to the specializtion's discretion,
- // ie the implicit JAWTWindow in case of AWTWindow
- Thread cur = Thread.currentThread();
- if (owner == cur) {
- ++recursionCount;
- return LOCK_SUCCESS;
- }
- while (owner != null) {
- try {
- wait();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- owner = cur;
- lockedStack = new Exception("NEWT Surface previously locked by "+Thread.currentThread());
- screen.getDisplay().lockDisplay();
- return LOCK_SUCCESS;
- }
-
- /** Recursive and unblocking unlockSurface() implementation */
- public synchronized void unlockSurface() throws NativeWindowException {
- Thread cur = Thread.currentThread();
- if (owner != cur) {
- lockedStack.printStackTrace();
- throw new NativeWindowException(cur+": Not owner, owner is "+owner);
- }
- if (recursionCount > 0) {
- --recursionCount;
- return;
- }
- owner = null;
- lockedStack = null;
- screen.getDisplay().unlockDisplay();
- notifyAll();
- // We leave the ToolkitLock unlock to the specializtion's discretion,
- // ie the implicit JAWTWindow in case of AWTWindow
- }
-
- public synchronized boolean isSurfaceLocked() {
- return null!=owner;
- }
-
- public synchronized Thread getSurfaceLockOwner() {
- return owner;
- }
-
- public synchronized Exception getLockedStack() {
- return lockedStack;
- }
-
- public synchronized void destroy() {
- destroy(false);
- }
-
- /** @param deep If true, the linked Screen and Display will be destroyed as well. */
- public synchronized void destroy(boolean deep) {
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.destroy() start (deep "+deep+" - "+Thread.currentThread());
- }
- synchronized(surfaceUpdatedListeners) {
- surfaceUpdatedListeners = new ArrayList();
- }
- synchronized(windowListeners) {
- windowListeners = new ArrayList();
- }
- synchronized(mouseListeners) {
- mouseListeners = new ArrayList();
- }
- synchronized(keyListeners) {
- keyListeners = new ArrayList();
- }
- Screen scr = screen;
- Display dpy = (null!=screen) ? screen.getDisplay() : null;
- EventDispatchThread edt = (null!=dpy) ? dpy.getEDT() : null;
- if(null!=edt) {
- final Window f_win = this;
- edt.invokeAndWait(new Runnable() {
- public void run() {
- f_win.closeNative();
- }
- } );
- } else {
- closeNative();
- }
- invalidate();
- if(deep) {
- if(null!=scr) {
- scr.destroy();
- }
- if(null!=dpy) {
- dpy.destroy();
- }
- }
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.destroy() end "+Thread.currentThread());
- }
- }
-
- public void invalidate() {
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- Exception e = new Exception("!!! Window Invalidate "+Thread.currentThread());
- e.printStackTrace();
- }
- screen = null;
- windowHandle = 0;
- fullscreen=false;
- visible=false;
- eventMask = 0;
-
- // Default position and dimension will be re-set immediately by user
- width = 100;
- height = 100;
- x=0;
- y=0;
- }
-
- public boolean surfaceSwap() {
- return false;
- }
-
- protected void clearEventMask() {
- eventMask=0;
- }
-
- public long getDisplayHandle() {
- return screen.getDisplay().getHandle();
- }
-
- public int getScreenIndex() {
- return screen.getIndex();
- }
-
- public long getWindowHandle() {
- return windowHandle;
- }
-
- public long getSurfaceHandle() {
- return windowHandle; // default: return window handle
- }
-
- public AbstractGraphicsConfiguration getGraphicsConfiguration() {
- return config;
- }
-
- /**
- * Returns the width of the client area of this window
- * @return width of the client area
- */
- public int getWidth() {
- return width;
- }
-
- /**
- * Returns the height of the client area of this window
- * @return height of the client area
- */
- public int getHeight() {
- return height;
- }
-
- /**
- * Returns the insets for this native window (the difference between the
- * size of the toplevel window with the decorations and the client area).
- *
- * @return insets for this platform window
- */
- // this probably belongs to NativeWindow interface
- public Insets getInsets() {
- return new Insets(0,0,0,0);
- }
-
- /** If this Window actually wraps one from another toolkit such as
- the AWT, this will return a non-null value. */
- public Object getWrappedWindow() {
- return null;
- }
-
- //
- // Additional methods
- //
-
- public int getX() {
- return x;
- }
-
- public int getY() {
- return y;
- }
-
- public boolean isVisible() {
- return visible;
- }
-
- public boolean isFullscreen() {
- return fullscreen;
- }
-
- private boolean autoDrawableMember = false;
-
- /** If the implementation is capable of detecting a device change
- return true and clear the status/reason of the change. */
- public boolean hasDeviceChanged() {
- return false;
- }
-
- /**
- * If set to true,
- * certain action will be performed by the owning
- * AutoDrawable, ie the destroy() call within windowDestroyNotify()
- */
- public void setAutoDrawableClient(boolean b) {
- autoDrawableMember = b;
- }
-
- protected void windowDestroyNotify() {
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.windowDestroyeNotify start "+Thread.currentThread());
- }
-
- sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY);
-
- if(!autoDrawableMember) {
- destroy();
- }
-
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.windowDestroyeNotify end "+Thread.currentThread());
- }
- }
-
- protected void windowDestroyed() {
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.windowDestroyed "+Thread.currentThread());
- }
- invalidate();
- }
-
- public abstract void setVisible(boolean visible);
- /**
- * Sets the size of the client area of the window, excluding decorations
- * Total size of the window will be
- * {@code width+insets.left+insets.right, height+insets.top+insets.bottom}
- * @param width of the client area of the window
- * @param height of the client area of the window
- */
- public abstract void setSize(int width, int height);
- /**
- * Sets the location of the top left corner of the window, including
- * decorations (so the client area will be placed at
- * {@code x+insets.left,y+insets.top}.
- * @param x coord of the top left corner
- * @param y coord of the top left corner
- */
- public abstract void setPosition(int x, int y);
- public abstract boolean setFullscreen(boolean fullscreen);
-
- //
- // SurfaceUpdatedListener Support
- //
- private ArrayList surfaceUpdatedListeners = new ArrayList();
-
- public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- if(l == null) {
- return;
- }
- synchronized(surfaceUpdatedListeners) {
- ArrayList newSurfaceUpdatedListeners = (ArrayList) surfaceUpdatedListeners.clone();
- newSurfaceUpdatedListeners.add(l);
- surfaceUpdatedListeners = newSurfaceUpdatedListeners;
- }
- }
-
- public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- if (l == null) {
- return;
- }
- synchronized(surfaceUpdatedListeners) {
- ArrayList newSurfaceUpdatedListeners = (ArrayList) surfaceUpdatedListeners.clone();
- newSurfaceUpdatedListeners.remove(l);
- surfaceUpdatedListeners = newSurfaceUpdatedListeners;
- }
- }
-
- public SurfaceUpdatedListener[] getSurfaceUpdatedListener() {
- synchronized(surfaceUpdatedListeners) {
- return (SurfaceUpdatedListener[]) surfaceUpdatedListeners.toArray();
- }
- }
-
- public void surfaceUpdated(Object updater, NativeWindow window, long when) {
- ArrayList listeners = null;
- synchronized(surfaceUpdatedListeners) {
- listeners = surfaceUpdatedListeners;
- }
- for(Iterator i = listeners.iterator(); i.hasNext(); ) {
- SurfaceUpdatedListener l = (SurfaceUpdatedListener) i.next();
- l.surfaceUpdated(updater, window, when);
- }
- }
-
- //
- // MouseListener Support
- //
-
- public void addMouseListener(MouseListener l) {
- if(l == null) {
- return;
- }
- synchronized(mouseListeners) {
- ArrayList newMouseListeners = (ArrayList) mouseListeners.clone();
- newMouseListeners.add(l);
- mouseListeners = newMouseListeners;
- }
- }
-
- public void removeMouseListener(MouseListener l) {
- if (l == null) {
- return;
- }
- synchronized(mouseListeners) {
- ArrayList newMouseListeners = (ArrayList) mouseListeners.clone();
- newMouseListeners.remove(l);
- mouseListeners = newMouseListeners;
- }
- }
-
- public MouseListener[] getMouseListeners() {
- synchronized(mouseListeners) {
- return (MouseListener[]) mouseListeners.toArray();
- }
- }
-
- private ArrayList mouseListeners = new ArrayList();
- private int mouseButtonPressed = 0; // current pressed mouse button number
- private long lastMousePressed = 0; // last time when a mouse button was pressed
- private int lastMouseClickCount = 0; // last mouse button click count
- public static final int ClickTimeout = 300;
-
- protected void sendMouseEvent(int eventType, int modifiers,
- int x, int y, int button, int rotation) {
- if(x<0||y<0||x>=width||y>=height) {
- return; // .. invalid ..
- }
- if(DEBUG_MOUSE_EVENT) {
- System.out.println("sendMouseEvent: "+MouseEvent.getEventTypeString(eventType)+
- ", mod "+modifiers+", pos "+x+"/"+y+", button "+button);
- }
- if(button<0||button>MouseEvent.BUTTON_NUMBER) {
- throw new NativeWindowException("Invalid mouse button number" + button);
- }
- long when = System.currentTimeMillis();
- MouseEvent eClicked = null;
- MouseEvent e = null;
-
- if(MouseEvent.EVENT_MOUSE_PRESSED==eventType) {
- if(when-lastMousePressed
- * before calling the various input EventListener callbacks (MouseListener, KeyListener,
- * etc.).
- * This design decision is made to favor a more performant and simplified
- * implementation, as well as the event dispatcher shall be allowed
- * not having a notion about OpenGL.
- *
- * Enable or disables running the {@link Display#pumpMessages} in the {@link #display()} call.
- * The default behavior is to run {@link Display#pumpMessages}.
- * This could not have been verified. No measurable difference could have been recognized.
- *
- * Enabling local pump messages while using the EDT,
- * {@link com.sun.javafx.newt.NewtFactory#setUseEDT(boolean)},
- * will result in an exception.
- *
- * @deprecated EXPERIMENTAL, semantic is about to be removed after further verification.
- */
- public void setRunPumpMessages(boolean onoff) {
- if( onoff && null!=getScreen().getDisplay().getEDT() ) {
- throw new GLException("GLWindow.setRunPumpMessages(true) - Can't do with EDT on");
- }
- runPumpMessages = onoff;
- }
-
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- shouldNotCallThis();
- }
-
- protected void closeNative() {
- shouldNotCallThis();
- }
-
- protected void dispose(boolean regenerate, boolean sendEvent) {
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- Exception e1 = new Exception("GLWindow.dispose("+regenerate+") "+Thread.currentThread()+", 1");
- e1.printStackTrace();
- }
-
- if(sendEvent) {
- sendDisposeEvent();
- }
-
- if (context != null) {
- context.destroy();
- }
- if (drawable != null) {
- drawable.setRealized(false);
- }
-
- if(regenerate) {
- if(null==window) {
- throw new GLException("GLWindow.dispose(true): null window");
- }
-
- // recreate GLDrawable, to reflect the new graphics configurations
- NativeWindow nw;
- if (window.getWrappedWindow() != null) {
- nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
- } else {
- nw = window;
- }
- drawable = factory.createGLDrawable(nw);
- drawable.setRealized(true);
- context = drawable.createContext(null);
- sendReshape = true; // ensure a reshape event is send ..
- }
-
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println("GLWindow.dispose("+regenerate+") "+Thread.currentThread()+", fin: "+this);
- }
- }
-
- public synchronized void destroy() {
- destroy(true);
- }
-
- /** @param sendDisposeEvent should be false in a [time,reliable] critical shutdown */
- public synchronized void destroy(boolean sendDisposeEvent) {
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- Exception e1 = new Exception("GLWindow.destroy "+Thread.currentThread()+", 1: "+this);
- e1.printStackTrace();
- }
-
- List newglw = (List) ((ArrayList) glwindows).clone();
- newglw.remove(this);
- glwindows=newglw;
-
- dispose(false, sendDisposeEvent);
-
- if(null!=window) {
- if(ownerOfWinScrDpy) {
- window.destroy(true);
- }
- }
-
- drawable = null;
- context = null;
- window = null;
-
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println("GLWindow.destroy "+Thread.currentThread()+", fin: "+this);
- }
- }
-
- public boolean getPerfLogEnabled() { return perfLog; }
-
- public void enablePerfLog(boolean v) {
- perfLog = v;
- }
-
- public void setVisible(boolean visible) {
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread()+" GLWindow.setVisible("+visible+") START ; isVisible "+this.visible+" ; has context "+(null!=context));
- }
- this.visible=visible;
- window.setVisible(visible);
- if (visible && context == null) {
- NativeWindow nw;
- if (window.getWrappedWindow() != null) {
- nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
- } else {
- nw = window;
- }
- GLCapabilities glCaps = (GLCapabilities) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
- factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
- drawable = factory.createGLDrawable(nw);
- drawable.setRealized(true);
- context = drawable.createContext(null);
- sendReshape = true; // ensure a reshape event is send ..
- }
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread()+" GLWindow.setVisible("+visible+") END ; has context "+(null!=context));
- }
- }
-
- public Screen getScreen() {
- return window.getScreen();
- }
-
- public void setTitle(String title) {
- window.setTitle(title);
- }
-
- public String getTitle() {
- return window.getTitle();
- }
-
- public void setUndecorated(boolean value) {
- window.setUndecorated(value);
- }
-
- public boolean isUndecorated() {
- return window.isUndecorated();
- }
-
- public void setSize(int width, int height) {
- window.setSize(width, height);
- }
-
- public void setPosition(int x, int y) {
- window.setPosition(x, y);
- }
-
- public Insets getInsets() {
- return window.getInsets();
- }
-
- public boolean setFullscreen(boolean fullscreen) {
- return window.setFullscreen(fullscreen);
- }
-
- public boolean isVisible() {
- return window.isVisible();
- }
-
- public int getX() {
- return window.getX();
- }
-
- public int getY() {
- return window.getY();
- }
-
- public int getWidth() {
- return window.getWidth();
- }
-
- public int getHeight() {
- return window.getHeight();
- }
-
- public boolean isFullscreen() {
- return window.isFullscreen();
- }
-
- public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- window.addSurfaceUpdatedListener(l);
- }
- public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- window.removeSurfaceUpdatedListener(l);
- }
- public SurfaceUpdatedListener[] getSurfaceUpdatedListener() {
- return window.getSurfaceUpdatedListener();
- }
- public void surfaceUpdated(Object updater, NativeWindow window0, long when) {
- window.surfaceUpdated(updater, window, when);
- }
-
- public void addMouseListener(MouseListener l) {
- window.addMouseListener(l);
- }
-
- public void removeMouseListener(MouseListener l) {
- window.removeMouseListener(l);
- }
-
- public MouseListener[] getMouseListeners() {
- return window.getMouseListeners();
- }
-
- public void addKeyListener(KeyListener l) {
- window.addKeyListener(l);
- }
-
- public void removeKeyListener(KeyListener l) {
- window.removeKeyListener(l);
- }
-
- public KeyListener[] getKeyListeners() {
- return window.getKeyListeners();
- }
-
- public void addWindowListener(WindowListener l) {
- window.addWindowListener(l);
- }
-
- public void removeWindowListener(WindowListener l) {
- window.removeWindowListener(l);
- }
-
- public WindowListener[] getWindowListeners() {
- return window.getWindowListeners();
- }
-
- public String toString() {
- return "NEWT-GLWindow[ \n\tDrawable: "+drawable+", \n\tWindow: "+window+", \n\tHelper: "+helper+", \n\tFactory: "+factory+"]";
- }
-
- //----------------------------------------------------------------------
- // OpenGL-related methods and state
- //
-
- private GLDrawableFactory factory;
- private GLDrawable drawable;
- private GLContext context;
- private GLDrawableHelper helper = new GLDrawableHelper();
- // To make reshape events be sent immediately before a display event
- private boolean sendReshape=false;
- private boolean sendDestroy=false;
- private boolean perfLog = false;
-
- public GLDrawableFactory getFactory() {
- return factory;
- }
-
- public void setContext(GLContext newCtx) {
- context = newCtx;
- }
-
- public GLContext getContext() {
- return context;
- }
-
- public GL getGL() {
- if (context == null) {
- return null;
- }
- return context.getGL();
- }
-
- public GL setGL(GL gl) {
- if (context != null) {
- context.setGL(gl);
- return gl;
- }
- return null;
- }
-
- public void addGLEventListener(GLEventListener listener) {
- helper.addGLEventListener(listener);
- }
-
- public void removeGLEventListener(GLEventListener listener) {
- helper.removeGLEventListener(listener);
- }
-
- public void display() {
- display(false);
- }
-
- public void display(boolean forceReshape) {
- if(window!=null && drawable!=null && context != null) {
- if(runPumpMessages) {
- window.getScreen().getDisplay().pumpMessages();
- }
- if(window.hasDeviceChanged() && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED) {
- dispose(true, true);
- }
- if (sendDestroy) {
- destroy();
- sendDestroy=false;
- } else {
- if(forceReshape) {
- sendReshape = true;
- }
- helper.invokeGL(drawable, context, displayAction, initAction);
- }
- }
- }
-
- private void sendDisposeEvent() {
- if(drawable!=null && context != null) {
- helper.invokeGL(drawable, context, disposeAction, null);
- }
- }
-
- /** This implementation uses a static value */
- public void setAutoSwapBufferMode(boolean onOrOff) {
- helper.setAutoSwapBufferMode(onOrOff);
- }
-
- /** This implementation uses a static value */
- public boolean getAutoSwapBufferMode() {
- return helper.getAutoSwapBufferMode();
- }
-
- public void swapBuffers() {
- if(drawable!=null && context != null) {
- if (context != GLContext.getCurrent()) {
- // Assume we should try to make the context current before swapping the buffers
- helper.invokeGL(drawable, context, swapBuffersAction, initAction);
- } else {
- drawable.swapBuffers();
- }
- }
- }
-
- class InitAction implements Runnable {
- public void run() {
- helper.init(GLWindow.this);
- startTime = System.currentTimeMillis();
- curTime = startTime;
- if(perfLog) {
- lastCheck = startTime;
- totalFrames = 0; lastFrames = 0;
- }
- }
- }
- private InitAction initAction = new InitAction();
-
- class DisposeAction implements Runnable {
- public void run() {
- helper.dispose(GLWindow.this);
- }
- }
- private DisposeAction disposeAction = new DisposeAction();
-
- class DisplayAction implements Runnable {
- public void run() {
- if (sendReshape) {
- int width = getWidth();
- int height = getHeight();
- getGL().glViewport(0, 0, width, height);
- helper.reshape(GLWindow.this, 0, 0, width, height);
- sendReshape = false;
- }
-
- helper.display(GLWindow.this);
-
- curTime = System.currentTimeMillis();
- totalFrames++;
-
- if(perfLog) {
- long dt0, dt1;
- lastFrames++;
- dt0 = curTime-lastCheck;
- if ( dt0 > 5000 ) {
- dt1 = curTime-startTime;
- System.out.println(dt0/1000 +"s: "+ lastFrames + "f, " + (lastFrames*1000)/dt0 + " fps, "+dt0/lastFrames+" ms/f; "+
- "total: "+ dt1/1000+"s, "+(totalFrames*1000)/dt1 + " fps, "+dt1/totalFrames+" ms/f");
- lastCheck=curTime;
- lastFrames=0;
- }
- }
- }
- }
- private DisplayAction displayAction = new DisplayAction();
-
- public long getStartTime() { return startTime; }
- public long getCurrentTime() { return curTime; }
- public long getDuration() { return curTime-startTime; }
- public int getTotalFrames() { return totalFrames; }
-
- private long startTime = 0;
- private long curTime = 0;
- private long lastCheck = 0;
- private int totalFrames = 0, lastFrames = 0;
-
- class SwapBuffersAction implements Runnable {
- public void run() {
- drawable.swapBuffers();
- }
- }
- private SwapBuffersAction swapBuffersAction = new SwapBuffersAction();
-
- //----------------------------------------------------------------------
- // GLDrawable methods
- //
-
- public NativeWindow getNativeWindow() {
- return null!=drawable ? drawable.getNativeWindow() : null;
- }
-
- public synchronized int lockSurface() throws NativeWindowException {
- if(null!=drawable) return drawable.getNativeWindow().lockSurface();
- return NativeWindow.LOCK_SURFACE_NOT_READY;
- }
-
- public synchronized void unlockSurface() {
- if(null!=drawable) drawable.getNativeWindow().unlockSurface();
- else throw new NativeWindowException("NEWT-GLWindow not locked");
- }
-
- public synchronized boolean isSurfaceLocked() {
- if(null!=drawable) return drawable.getNativeWindow().isSurfaceLocked();
- return false;
- }
-
- public synchronized Exception getLockedStack() {
- if(null!=drawable) return drawable.getNativeWindow().getLockedStack();
- return null;
- }
-
- public boolean surfaceSwap() {
- if(null!=drawable) return drawable.getNativeWindow().surfaceSwap();
- return super.surfaceSwap();
- }
-
- public long getWindowHandle() {
- if(null!=drawable) return drawable.getNativeWindow().getWindowHandle();
- return super.getWindowHandle();
- }
-
- public long getSurfaceHandle() {
- if(null!=drawable) return drawable.getNativeWindow().getSurfaceHandle();
- return super.getSurfaceHandle();
- }
-
- //----------------------------------------------------------------------
- // GLDrawable methods that are not really needed
- //
-
- public GLContext createContext(GLContext shareWith) {
- return drawable.createContext(shareWith);
- }
-
- public void setRealized(boolean realized) {
- }
-
- public GLCapabilities getChosenGLCapabilities() {
- if (drawable == null) {
- throw new GLException("No drawable yet");
- }
-
- return drawable.getChosenGLCapabilities();
- }
-
- public GLProfile getGLProfile() {
- if (drawable == null) {
- throw new GLException("No drawable yet");
- }
-
- return drawable.getGLProfile();
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- private void shouldNotCallThis() {
- throw new NativeWindowException("Should not call this");
- }
-}
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Display.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Display.java
deleted file mode 100644
index 1b74aebc3..000000000
--- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Display.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.opengl.broadcom.egl;
-
-import com.sun.javafx.newt.impl.*;
-import com.jogamp.opengl.impl.egl.*;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.egl.*;
-
-public class Display extends com.sun.javafx.newt.Display {
-
- static {
- NativeLibLoader.loadNEWT();
-
- if (!Window.initIDs()) {
- throw new NativeWindowException("Failed to initialize BCEGL Window jmethodIDs");
- }
- }
-
- public static void initSingleton() {
- // just exist to ensure static init has been run
- }
-
-
- public Display() {
- }
-
- protected void createNative() {
- long handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight);
- if (handle == EGL.EGL_NO_DISPLAY) {
- throw new NativeWindowException("BC EGL CreateDisplay failed");
- }
- aDevice = new EGLGraphicsDevice(handle);
- }
-
- protected void closeNative() {
- if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) {
- DestroyDisplay(aDevice.getHandle());
- }
- }
-
- protected void dispatchMessages() {
- // n/a .. DispatchMessages();
- }
-
- private native long CreateDisplay(int width, int height);
- private native void DestroyDisplay(long dpy);
- private native void DispatchMessages();
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Screen.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Screen.java
deleted file mode 100755
index 28f7211c3..000000000
--- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Screen.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.opengl.broadcom.egl;
-
-import com.sun.javafx.newt.impl.*;
-import javax.media.nativewindow.*;
-
-public class Screen extends com.sun.javafx.newt.Screen {
-
- static {
- Display.initSingleton();
- }
-
-
- public Screen() {
- }
-
- protected void createNative(int index) {
- aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
- setScreenSize(fixedWidth, fixedHeight);
- }
-
- protected void closeNative() { }
-
- //----------------------------------------------------------------------
- // Internals only
- //
-
- static final int fixedWidth = 1920;
- static final int fixedHeight = 1080;
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Window.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Window.java
deleted file mode 100755
index 8446ec20f..000000000
--- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/egl/Window.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * 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.opengl.broadcom.egl;
-
-import com.sun.javafx.newt.impl.*;
-import com.jogamp.opengl.impl.egl.*;
-import javax.media.nativewindow.*;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-import javax.media.nativewindow.NativeWindowException;
-
-public class Window extends com.sun.javafx.newt.Window {
- static {
- Display.initSingleton();
- }
-
- public Window() {
- }
-
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- if(0!=parentWindowHandle) {
- throw new RuntimeException("Window parenting not supported (yet)");
- }
- // query a good configuration .. even thought we drop this one
- // and reuse the EGLUtil choosen one later.
- config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
- if (config == null) {
- throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
- }
- setSizeImpl(getScreen().getWidth(), getScreen().getHeight());
- }
-
- protected void closeNative() {
- if(0!=windowHandleClose) {
- CloseWindow(getDisplayHandle(), windowHandleClose);
- }
- }
-
- public void setVisible(boolean visible) {
- if(this.visible!=visible) {
- this.visible=visible;
- if ( 0==windowHandle ) {
- windowHandle = realizeWindow(true, width, height);
- if (0 == windowHandle) {
- throw new NativeWindowException("Error native Window Handle is null");
- }
- }
- clearEventMask();
- }
- }
-
- public void setSize(int width, int height) {
- System.err.println("setSize "+width+"x"+height+" n/a in BroadcomEGL");
- }
-
- void setSizeImpl(int width, int height) {
- if(0!=windowHandle) {
- // n/a in BroadcomEGL
- System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window");
- } else {
- if(DEBUG_IMPLEMENTATION) {
- Exception e = new Exception("BCEGL Window.setSizeImpl() "+this.width+"x"+this.height+" -> "+width+"x"+height);
- e.printStackTrace();
- }
- this.width = width;
- this.height = height;
- }
- }
-
- public void setPosition(int x, int y) {
- // n/a in BroadcomEGL
- System.err.println("setPosition n/a in BroadcomEGL");
- }
-
- public boolean setFullscreen(boolean fullscreen) {
- // n/a in BroadcomEGL
- System.err.println("setFullscreen n/a in BroadcomEGL");
- return false;
- }
-
- public boolean surfaceSwap() {
- if ( 0!=windowHandle ) {
- SwapWindow(getDisplayHandle(), windowHandle);
- return true;
- }
- return false;
- }
-
- //----------------------------------------------------------------------
- // Internals only
- //
-
- protected static native boolean initIDs();
- private native long CreateWindow(long eglDisplayHandle, boolean chromaKey, int width, int height);
- private native void CloseWindow(long eglDisplayHandle, long eglWindowHandle);
- private native void SwapWindow(long eglDisplayHandle, long eglWindowHandle);
-
-
- private long realizeWindow(boolean chromaKey, int width, int height) {
- if(DEBUG_IMPLEMENTATION) {
- System.out.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+config);
- }
- long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height);
- if (0 == handle) {
- throw new NativeWindowException("Error native Window Handle is null");
- }
- windowHandleClose = handle;
- return handle;
- }
-
- private void windowCreated(int cfgID, int width, int height) {
- this.width = width;
- this.height = height;
- GLCapabilities capsReq = (GLCapabilities) config.getRequestedCapabilities();
- config = EGLGraphicsConfiguration.create(capsReq, screen.getGraphicsScreen(), cfgID);
- if (config == null) {
- throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this);
- }
- if(DEBUG_IMPLEMENTATION) {
- System.out.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+config);
- }
- }
-
- private long windowHandleClose;
-}
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDDisplay.java b/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDDisplay.java
deleted file mode 100755
index 9e328a223..000000000
--- a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDDisplay.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.opengl.kd;
-
-import com.sun.javafx.newt.*;
-import com.sun.javafx.newt.impl.*;
-import com.jogamp.opengl.impl.egl.*;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.egl.*;
-
-public class KDDisplay extends Display {
-
- static {
- NativeLibLoader.loadNEWT();
-
- if (!KDWindow.initIDs()) {
- throw new NativeWindowException("Failed to initialize KDWindow jmethodIDs");
- }
- }
-
- public static void initSingleton() {
- // just exist to ensure static init has been run
- }
-
-
- public KDDisplay() {
- }
-
- protected void createNative() {
- // FIXME: map name to EGL_*_DISPLAY
- long handle = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
- if (handle == EGL.EGL_NO_DISPLAY) {
- throw new NativeWindowException("eglGetDisplay failed");
- }
- if (!EGL.eglInitialize(handle, null, null)) {
- throw new NativeWindowException("eglInitialize failed");
- }
- aDevice = new EGLGraphicsDevice(handle);
- }
-
- protected void closeNative() {
- if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) {
- EGL.eglTerminate(aDevice.getHandle());
- }
- }
-
- protected void dispatchMessages() {
- DispatchMessages();
- }
-
- private native void DispatchMessages();
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDScreen.java b/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDScreen.java
deleted file mode 100755
index 1767c1240..000000000
--- a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDScreen.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.opengl.kd;
-
-import com.sun.javafx.newt.*;
-import javax.media.nativewindow.*;
-
-public class KDScreen extends Screen {
- static {
- KDDisplay.initSingleton();
- }
-
- public KDScreen() {
- }
-
- protected void createNative(int index) {
- aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
- }
-
- protected void closeNative() { }
-
- // elevate access to this package ..
- protected void setScreenSize(int w, int h) {
- super.setScreenSize(w, h);
- }
-}
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java
deleted file mode 100755
index 9919d1f6f..000000000
--- a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.opengl.kd;
-
-import com.sun.javafx.newt.*;
-import com.sun.javafx.newt.impl.*;
-import com.jogamp.opengl.impl.egl.*;
-import javax.media.nativewindow.*;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-import javax.media.nativewindow.NativeWindowException;
-
-public class KDWindow extends Window {
- private static final String WINDOW_CLASS_NAME = "NewtWindow";
- // non fullscreen dimensions ..
- private int nfs_width, nfs_height, nfs_x, nfs_y;
-
- static {
- KDDisplay.initSingleton();
- }
-
- public KDWindow() {
- }
-
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- if(0!=parentWindowHandle) {
- throw new RuntimeException("Window parenting not supported (yet)");
- }
- config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
- if (config == null) {
- throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
- }
-
- GLCapabilities eglCaps = (GLCapabilities)config.getChosenCapabilities();
- int[] eglAttribs = EGLGraphicsConfiguration.GLCapabilities2AttribList(eglCaps);
-
- windowHandle = 0;
- eglWindowHandle = CreateWindow(getDisplayHandle(), eglAttribs);
- if (eglWindowHandle == 0) {
- throw new NativeWindowException("Error creating egl window: "+config);
- }
- setVisible0(eglWindowHandle, false);
- windowHandleClose = eglWindowHandle;
- }
-
- protected void closeNative() {
- if(0!=windowHandleClose) {
- CloseWindow(windowHandleClose, windowUserData);
- windowUserData=0;
- }
- }
-
- public void setVisible(boolean visible) {
- if(0!=eglWindowHandle && this.visible!=visible) {
- this.visible=visible;
- setVisible0(eglWindowHandle, visible);
- if ( 0==windowHandle ) {
- windowHandle = RealizeWindow(eglWindowHandle);
- if (0 == windowHandle) {
- throw new NativeWindowException("Error native Window Handle is null");
- }
- }
- clearEventMask();
- }
- }
-
- public void setSize(int width, int height) {
- if(0!=eglWindowHandle) {
- setSize0(eglWindowHandle, width, height);
- }
- }
-
- public void setPosition(int x, int y) {
- // n/a in KD
- System.err.println("setPosition n/a in KD");
- }
-
- public boolean setFullscreen(boolean fullscreen) {
- if(0!=eglWindowHandle && this.fullscreen!=fullscreen) {
- this.fullscreen=fullscreen;
- if(this.fullscreen) {
- setFullScreen0(eglWindowHandle, true);
- } else {
- setFullScreen0(eglWindowHandle, false);
- setSize0(eglWindowHandle, nfs_width, nfs_height);
- }
- }
- return true;
- }
-
- //----------------------------------------------------------------------
- // Internals only
- //
-
- protected static native boolean initIDs();
- private native long CreateWindow(long displayHandle, int[] attributes);
- private native long RealizeWindow(long eglWindowHandle);
- private native int CloseWindow(long eglWindowHandle, long userData);
- private native void setVisible0(long eglWindowHandle, boolean visible);
- private native void setSize0(long eglWindowHandle, int width, int height);
- private native void setFullScreen0(long eglWindowHandle, boolean fullscreen);
-
- private void windowCreated(long userData) {
- windowUserData=userData;
- }
-
- private void sizeChanged(int newWidth, int newHeight) {
- width = newWidth;
- height = newHeight;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- } else {
- ((KDScreen)screen).setScreenSize(width, height);
- }
- sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
- }
-
- private long eglWindowHandle;
- private long windowHandleClose;
- private long windowUserData;
-}
diff --git a/src/newt/classes/com/sun/javafx/newt/util/EventDispatchThread.java b/src/newt/classes/com/sun/javafx/newt/util/EventDispatchThread.java
deleted file mode 100644
index a98ebab93..000000000
--- a/src/newt/classes/com/sun/javafx/newt/util/EventDispatchThread.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (c) 2009 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.
- */
-
-package com.sun.javafx.newt.util;
-
-import com.sun.javafx.newt.Display;
-import com.sun.javafx.newt.impl.Debug;
-import java.util.*;
-
-public class EventDispatchThread {
- public static final boolean DEBUG = Debug.debug("EDT");
-
- private ThreadGroup threadGroup;
- private volatile boolean shouldStop = false;
- private TaskWorker taskWorker = null;
- private Object taskWorkerLock = new Object();
- private ArrayList tasks = new ArrayList(); // one shot tasks
- private Display display = null;
- private String name;
- private long edtPollGranularity = 10;
-
- public EventDispatchThread(Display display, ThreadGroup tg, String name) {
- this.display = display;
- this.threadGroup = tg;
- this.name=new String("EDT-Display_"+display.getName()+"-"+name);
- }
-
- public String getName() { return name; }
-
- public ThreadGroup getThreadGroup() { return threadGroup; }
-
- public void start() {
- start(false);
- }
-
- /**
- * @param externalStimuli true indicates that another thread stimulates,
- * ie. calls this TaskManager's run() loop method.
- * Hence no own thread is started in this case.
- *
- * @return The started Runnable, which handles the run-loop.
- * Usefull in combination with externalStimuli=true,
- * so an external stimuli can call it.
- */
- public Runnable start(boolean externalStimuli) {
- synchronized(taskWorkerLock) {
- if(null==taskWorker) {
- taskWorker = new TaskWorker(threadGroup, name);
- }
- if(!taskWorker.isRunning()) {
- shouldStop = false;
- taskWorker.start(externalStimuli);
- }
- taskWorkerLock.notifyAll();
- }
- return taskWorker;
- }
-
- public void stop() {
- synchronized(taskWorkerLock) {
- if(null!=taskWorker && taskWorker.isRunning()) {
- shouldStop = true;
- }
- taskWorkerLock.notifyAll();
- if(DEBUG) {
- System.out.println(Thread.currentThread()+": EDT signal STOP");
- }
- }
- }
-
- public boolean isThreadEDT(Thread thread) {
- return null!=taskWorker && taskWorker == thread;
- }
-
- public boolean isCurrentThreadEDT() {
- return null!=taskWorker && taskWorker == Thread.currentThread();
- }
-
- public boolean isRunning() {
- return null!=taskWorker && taskWorker.isRunning() ;
- }
-
- public void invokeLater(Runnable task) {
- if(task == null) {
- return;
- }
- synchronized(taskWorkerLock) {
- if(null!=taskWorker && taskWorker.isRunning() && taskWorker != Thread.currentThread() ) {
- tasks.add(task);
- taskWorkerLock.notifyAll();
- } else {
- // if !running or isEDTThread, do it right away
- task.run();
- }
- }
- }
-
- public void invokeAndWait(Runnable task) {
- if(task == null) {
- return;
- }
- invokeLater(task);
- waitOnWorker();
- }
-
- public void waitOnWorker() {
- synchronized(taskWorkerLock) {
- if(null!=taskWorker && taskWorker.isRunning() && tasks.size()>0 && taskWorker != Thread.currentThread() ) {
- try {
- taskWorkerLock.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- public void waitUntilStopped() {
- synchronized(taskWorkerLock) {
- while(null!=taskWorker && taskWorker.isRunning() && taskWorker != Thread.currentThread() ) {
- try {
- taskWorkerLock.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- class TaskWorker extends Thread {
- boolean isRunning = false;
- boolean externalStimuli = false;
-
- public TaskWorker(ThreadGroup tg, String name) {
- super(tg, name);
- }
-
- public synchronized boolean isRunning() {
- return isRunning;
- }
-
- public void start(boolean externalStimuli) throws IllegalThreadStateException {
- synchronized(this) {
- this.externalStimuli = externalStimuli;
- isRunning = true;
- }
- if(!externalStimuli) {
- super.start();
- }
- }
-
- /**
- * Utilizing taskWorkerLock only for local resources and task execution,
- * not for event dispatching.
- */
- public void run() {
- if(DEBUG) {
- System.out.println(Thread.currentThread()+": EDT run() START");
- }
- while(!shouldStop) {
- try {
- // wait for something todo
- while(!shouldStop && tasks.size()==0) {
- synchronized(taskWorkerLock) {
- if(!shouldStop && tasks.size()==0) {
- try {
- taskWorkerLock.wait(edtPollGranularity);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- display.pumpMessages(); // event dispatch
- }
- if(!shouldStop && tasks.size()>0) {
- synchronized(taskWorkerLock) {
- if(!shouldStop && tasks.size()>0) {
- Runnable task = (Runnable) tasks.remove(0);
- task.run();
- taskWorkerLock.notifyAll();
- }
- }
- display.pumpMessages(); // event dispatch
- }
- } catch (Throwable t) {
- // handle errors ..
- t.printStackTrace();
- } finally {
- // epilog - unlock locked stuff
- }
- if(externalStimuli) break; // no loop if called by external stimuli
- }
- synchronized(this) {
- isRunning = !shouldStop;
- }
- if(!isRunning) {
- synchronized(taskWorkerLock) {
- taskWorkerLock.notifyAll();
- }
- }
- if(DEBUG) {
- System.out.println(Thread.currentThread()+": EDT run() EXIT");
- }
- }
- }
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/util/MainThread.java b/src/newt/classes/com/sun/javafx/newt/util/MainThread.java
deleted file mode 100644
index abfe3f0c7..000000000
--- a/src/newt/classes/com/sun/javafx/newt/util/MainThread.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * Copyright (c) 2009 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.
- */
-
-package com.sun.javafx.newt.util;
-
-import java.util.*;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-import java.security.*;
-
-import javax.media.nativewindow.*;
-
-import com.sun.javafx.newt.*;
-import com.sun.javafx.newt.impl.*;
-import com.sun.javafx.newt.macosx.MacDisplay;
-import com.sun.nativewindow.impl.NWReflection;
-
-/**
- * NEWT Utility class MainThread
- *
- * Such behavior is necessary for native windowing toolkits,
- * where the windowing management must happen on the so called
- * main thread e.g. for Mac OS X !
- *
- * Utilizing this class as a launchpad, now you are able to
- * use a NEWT multithreaded application with window handling within the different threads,
- * even on these restricted platforms.
- *
- * To support your NEWT Window platform,
- * you have to pass your main thread actions to {@link #invoke invoke(..)},
- * have a look at the {@link com.sun.javafx.newt.macosx.MacWindow MacWindow} implementation.
- * TODO: Some hardcoded dependencies exist in this implementation,
- * where you have to patch this code or factor it out. newt.MainThread.force
to true
.newt.MainThread.force
to true
.
- java -XstartOnFirstThread com.sun.javafx.newt.util.MainThread demos.es1.RedSquare -GL2 -GL2 -GL2 -GL2
-
- * Which starts 4 threads, each with a window and OpenGL rendering.
- */
-public class MainThread {
- private static AccessControlContext localACC = AccessController.getContext();
- public static final boolean USE_MAIN_THREAD = NativeWindowFactory.TYPE_MACOSX.equals(NativeWindowFactory.getNativeWindowType(false)) ||
- Debug.getBooleanProperty("newt.MainThread.force", true, localACC);
-
- protected static final boolean DEBUG = Debug.debug("MainThread");
-
- private static boolean isExit=false;
- private static volatile boolean isRunning=false;
- private static Object taskWorkerLock=new Object();
- private static boolean shouldStop;
- private static ArrayList tasks;
- private static ArrayList tasksBlock;
- private static Thread mainThread;
-
- static class MainAction extends Thread {
- private String mainClassName;
- private String[] mainClassArgs;
-
- private Class mainClass;
- private Method mainClassMain;
-
- public MainAction(String mainClassName, String[] mainClassArgs) {
- this.mainClassName=mainClassName;
- this.mainClassArgs=mainClassArgs;
- }
-
- public void run() {
- if ( USE_MAIN_THREAD ) {
- // we have to start first to provide the service ..
- MainThread.waitUntilRunning();
- }
-
- // start user app ..
- try {
- Class mainClass = NWReflection.getClass(mainClassName, true);
- if(null==mainClass) {
- throw new RuntimeException(new ClassNotFoundException("MainThread couldn't find main class "+mainClassName));
- }
- try {
- mainClassMain = mainClass.getDeclaredMethod("main", new Class[] { String[].class });
- mainClassMain.setAccessible(true);
- } catch (Throwable t) {
- throw new RuntimeException(t);
- }
- if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" invoke "+mainClassName);
- mainClassMain.invoke(null, new Object[] { mainClassArgs } );
- } catch (InvocationTargetException ite) {
- ite.getTargetException().printStackTrace();
- } catch (Throwable t) {
- t.printStackTrace();
- }
-
- if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" user app fin");
-
- if ( USE_MAIN_THREAD ) {
- MainThread.exit();
- if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" MainThread fin - exit");
- System.exit(0);
- }
- }
- }
- private static MainAction mainAction;
-
- /** Your new java application main entry, which pipelines your application */
- public static void main(String[] args) {
- if(DEBUG) System.err.println("MainThread.main(): "+Thread.currentThread().getName()+" USE_MAIN_THREAD "+ USE_MAIN_THREAD );
-
- if(args.length==0) {
- return;
- }
-
- String mainClassName=args[0];
- String[] mainClassArgs=new String[args.length-1];
- if(args.length>1) {
- System.arraycopy(args, 1, mainClassArgs, 0, args.length-1);
- }
-
- NativeLibLoader.loadNEWT();
-
- shouldStop = false;
- tasks = new ArrayList();
- tasksBlock = new ArrayList();
- mainThread = Thread.currentThread();
-
- mainAction = new MainAction(mainClassName, mainClassArgs);
-
- if(NativeWindowFactory.TYPE_MACOSX.equals(NativeWindowFactory.getNativeWindowType(false))) {
- MacDisplay.initSingleton();
- }
-
- if ( USE_MAIN_THREAD ) {
- // dispatch user's main thread ..
- mainAction.start();
-
- // do our main thread task scheduling
- run();
- } else {
- // run user's main in this thread
- mainAction.run();
- }
- }
-
- /** invokes the given Runnable */
- public static void invoke(boolean wait, Runnable r) {
- if(r == null) {
- return;
- }
-
- // if this main thread is not being used or
- // if this is already the main thread .. just execute.
- if( !isRunning() || mainThread == Thread.currentThread() ) {
- r.run();
- return;
- }
-
- synchronized(taskWorkerLock) {
- tasks.add(r);
- if(wait) {
- tasksBlock.add(r);
- }
- taskWorkerLock.notifyAll();
- if(wait) {
- while(tasksBlock.size()>0) {
- try {
- taskWorkerLock.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
-
- public static void exit() {
- if(DEBUG) System.err.println("MainThread.exit(): "+Thread.currentThread().getName()+" start");
- synchronized(taskWorkerLock) {
- if(isRunning) {
- shouldStop = true;
- }
- taskWorkerLock.notifyAll();
- }
- if(DEBUG) System.err.println("MainThread.exit(): "+Thread.currentThread().getName()+" end");
- }
-
- public static boolean isRunning() {
- synchronized(taskWorkerLock) {
- return isRunning;
- }
- }
-
- private static void waitUntilRunning() {
- synchronized(taskWorkerLock) {
- if(isExit) return;
-
- while(!isRunning) {
- try {
- taskWorkerLock.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- public static void run() {
- if(DEBUG) System.err.println("MainThread.run(): "+Thread.currentThread().getName());
- synchronized(taskWorkerLock) {
- isRunning = true;
- taskWorkerLock.notifyAll();
- }
- while(!shouldStop) {
- try {
- ArrayList localTasks=null;
-
- // wait for something todo ..
- synchronized(taskWorkerLock) {
- while(!shouldStop && tasks.size()==0) {
- try {
- taskWorkerLock.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- // seq. process all tasks until no blocking one exists in the list
- for(Iterator i = tasks.iterator(); tasksBlock.size()>0 && i.hasNext(); ) {
- Runnable task = (Runnable) i.next();
- task.run();
- i.remove();
- tasksBlock.remove(task);
- }
-
- // take over the tasks ..
- if(tasks.size()>0) {
- localTasks = tasks;
- tasks = new ArrayList();
- }
- taskWorkerLock.notifyAll();
- }
-
- // seq. process all unblocking tasks ..
- if(null!=localTasks) {
- for(Iterator i = localTasks.iterator(); i.hasNext(); ) {
- Runnable task = (Runnable) i.next();
- task.run();
- }
- }
- } catch (Throwable t) {
- // handle errors ..
- t.printStackTrace();
- } finally {
- // epilog - unlock locked stuff
- }
- }
- if(DEBUG) System.err.println("MainThread.run(): "+Thread.currentThread().getName()+" fin");
- synchronized(taskWorkerLock) {
- isRunning = false;
- isExit = true;
- taskWorkerLock.notifyAll();
- }
- }
-}
-
-
diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsDisplay.java b/src/newt/classes/com/sun/javafx/newt/windows/WindowsDisplay.java
deleted file mode 100755
index 80485ed67..000000000
--- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsDisplay.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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 javax.media.nativewindow.*;
-import javax.media.nativewindow.windows.*;
-import com.sun.javafx.newt.*;
-import com.sun.javafx.newt.impl.*;
-
-public class WindowsDisplay extends Display {
-
- protected static final String WINDOW_CLASS_NAME = "NewtWindowClass";
- private static int windowClassAtom;
- private static long hInstance;
-
- static {
- NativeLibLoader.loadNEWT();
-
- if (!WindowsWindow.initIDs()) {
- throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs");
- }
- }
-
- public static void initSingleton() {
- // just exist to ensure static init has been run
- }
-
-
- public WindowsDisplay() {
- }
-
- protected void createNative() {
- aDevice = new WindowsGraphicsDevice();
- }
-
- protected void closeNative() {
- // Can't do .. only at application shutdown
- // UnregisterWindowClass(getWindowClassAtom(), getHInstance());
- }
-
- protected void dispatchMessages() {
- DispatchMessages();
- }
-
- protected static synchronized int getWindowClassAtom() {
- if(0 == windowClassAtom) {
- windowClassAtom = RegisterWindowClass(WINDOW_CLASS_NAME, getHInstance());
- if (0 == windowClassAtom) {
- throw new NativeWindowException("Error while registering window class");
- }
- }
- return windowClassAtom;
- }
-
- protected static synchronized long getHInstance() {
- if(0 == hInstance) {
- hInstance = LoadLibraryW("newt");
- if (0 == hInstance) {
- throw new NativeWindowException("Error finding HINSTANCE for \"newt\"");
- }
- }
- return hInstance;
- }
-
- //----------------------------------------------------------------------
- // Internals only
- //
- private static native long LoadLibraryW(String libraryName);
- private static native int RegisterWindowClass(String windowClassName, long hInstance);
- private static native void UnregisterWindowClass(int wndClassAtom, long hInstance);
-
- private static native void DispatchMessages();
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsScreen.java b/src/newt/classes/com/sun/javafx/newt/windows/WindowsScreen.java
deleted file mode 100755
index 87ae1b49d..000000000
--- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsScreen.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.javafx.newt.impl.*;
-import javax.media.nativewindow.*;
-
-public class WindowsScreen extends Screen {
- static {
- WindowsDisplay.initSingleton();
- }
-
-
- public WindowsScreen() {
- }
-
- protected void createNative(int index) {
- aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
- setScreenSize(getWidthImpl(getIndex()), getHeightImpl(getIndex()));
- }
-
- protected void closeNative() { }
-
- private native int getWidthImpl(int scrn_idx);
- private native int getHeightImpl(int scrn_idx);
-}
diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
deleted file mode 100755
index 1b5bf80cf..000000000
--- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * 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 javax.media.nativewindow.*;
-import com.sun.javafx.newt.*;
-
-public class WindowsWindow extends Window {
-
- private long hmon;
- private long hdc;
- private long windowHandleClose;
- private long parentWindowHandle;
- // non fullscreen dimensions ..
- private int nfs_width, nfs_height, nfs_x, nfs_y;
- private final Insets insets = new Insets(0, 0, 0, 0);
-
- static {
- WindowsDisplay.initSingleton();
- }
-
- public WindowsWindow() {
- }
-
- Thread hdcOwner = null;
-
- public synchronized int lockSurface() throws NativeWindowException {
- int res = super.lockSurface();
- if(LOCK_SUCCESS==res && 0!=windowHandle) {
- if(hdc!=0) {
- throw new NativeWindowException("NEWT Surface handle set HDC "+toHexString(hdc)+" - "+Thread.currentThread().getName()+" ; "+this);
- }
- hdc = GetDC(windowHandle);
- hmon = MonitorFromWindow(windowHandle);
- hdcOwner = Thread.currentThread();
- }
- return res;
- }
-
- public synchronized void unlockSurface() {
- // prevalidate, before we change data ..
- Thread cur = Thread.currentThread();
- if ( getSurfaceLockOwner() != cur ) {
- getLockedStack().printStackTrace();
- throw new NativeWindowException(cur+": Not owner, owner is "+getSurfaceLockOwner());
- }
- if (0!=hdc && 0!=windowHandle) {
- if(hdcOwner != cur) {
- throw new NativeWindowException("NEWT Surface handle set HDC "+toHexString(hdc)+" by other thread "+hdcOwner+", this "+cur+" ; "+this);
- }
- ReleaseDC(windowHandle, hdc);
- hdc=0;
- hdcOwner=null;
- }
- super.unlockSurface();
- }
-
- public long getSurfaceHandle() {
- return hdc;
- }
-
- public boolean hasDeviceChanged() {
- if(0!=windowHandle) {
- long _hmon = MonitorFromWindow(windowHandle);
- if (hmon != _hmon) {
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- Exception e = new Exception("!!! Window Device Changed "+Thread.currentThread().getName()+
- ", HMON "+toHexString(hmon)+" -> "+toHexString(_hmon));
- e.printStackTrace();
- }
- hmon = _hmon;
- return true;
- }
- }
- return false;
- }
-
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- WindowsScreen screen = (WindowsScreen) getScreen();
- WindowsDisplay display = (WindowsDisplay) screen.getDisplay();
- config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
- if (config == null) {
- throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
- }
- windowHandle = CreateWindow(parentWindowHandle,
- display.getWindowClassAtom(), display.WINDOW_CLASS_NAME, display.getHInstance(),
- 0, undecorated, x, y, width, height);
- if (windowHandle == 0) {
- throw new NativeWindowException("Error creating window");
- }
- this.parentWindowHandle = parentWindowHandle;
- windowHandleClose = windowHandle;
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- Exception e = new Exception("!!! Window new window handle "+Thread.currentThread().getName()+
- " (Parent HWND "+toHexString(parentWindowHandle)+
- ") : HWND "+toHexString(windowHandle)+", "+Thread.currentThread());
- e.printStackTrace();
- }
- }
-
- protected void closeNative() {
- if (hdc != 0) {
- if(windowHandleClose != 0) {
- ReleaseDC(windowHandleClose, hdc);
- }
- hdc = 0;
- }
- if(windowHandleClose != 0) {
- DestroyWindow(windowHandleClose);
- windowHandleClose = 0;
- }
- }
-
- protected void windowDestroyed() {
- windowHandleClose = 0;
- super.windowDestroyed();
- }
-
- public void setVisible(boolean visible) {
- if(this.visible!=visible && 0!=windowHandle) {
- this.visible=visible;
- setVisible0(windowHandle, visible);
- }
- }
-
- // @Override
- public void setSize(int width, int height) {
- if (0!=windowHandle && (width != this.width || this.height != height)) {
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- }
- this.width = width;
- this.height = height;
- setSize0(parentWindowHandle, windowHandle, x, y, width, height);
- }
- }
-
- //@Override
- public void setPosition(int x, int y) {
- if (0!=windowHandle && (this.x != x || this.y != y)) {
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
- }
- this.x = x;
- this.y = y;
- setPosition(parentWindowHandle, windowHandle, x , y);
- }
- }
-
- public boolean setFullscreen(boolean fullscreen) {
- if(0!=windowHandle && (this.fullscreen!=fullscreen)) {
- int x,y,w,h;
- this.fullscreen=fullscreen;
- if(fullscreen) {
- x = 0; y = 0;
- w = screen.getWidth();
- h = screen.getHeight();
- } else {
- x = nfs_x;
- y = nfs_y;
- w = nfs_width;
- h = nfs_height;
- }
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- System.err.println("WindowsWindow fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
- }
- setFullscreen0(parentWindowHandle, windowHandle, x, y, w, h, undecorated, fullscreen);
- }
- return fullscreen;
- }
-
- // @Override
- public void requestFocus() {
- super.requestFocus();
- if (windowHandle != 0L) {
- requestFocus(windowHandle);
- }
- }
-
- // @Override
- public void setTitle(String title) {
- if (title == null) {
- title = "";
- }
- if (0!=windowHandle && !title.equals(getTitle())) {
- super.setTitle(title);
- setTitle(windowHandle, title);
- }
- }
-
- public Insets getInsets() {
- return (Insets)insets.clone();
- }
-
- //----------------------------------------------------------------------
- // Internals only
- //
- protected static native boolean initIDs();
- private native long CreateWindow(long parentWindowHandle,
- int wndClassAtom, String wndName,
- long hInstance, long visualID,
- boolean isUndecorated,
- int x, int y, int width, int height);
- private native void DestroyWindow(long windowHandle);
- private native long GetDC(long windowHandle);
- private native void ReleaseDC(long windowHandle, long hdc);
- private native long MonitorFromWindow(long windowHandle);
- private static native void setVisible0(long windowHandle, boolean visible);
- private native void setSize0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height);
- private native void setPosition(long parentWindowHandle, long windowHandle, int x, int y);
- private native void setFullscreen0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height, boolean isUndecorated, boolean on);
- private static native void setTitle(long windowHandle, String title);
- private static native void requestFocus(long windowHandle);
-
- private void insetsChanged(int left, int top, int right, int bottom) {
- if (left != -1 && top != -1 && right != -1 && bottom != -1) {
- insets.left = left;
- insets.top = top;
- insets.right = right;
- insets.bottom = bottom;
- }
- }
- private void sizeChanged(int newWidth, int newHeight) {
- width = newWidth;
- height = newHeight;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- }
- sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
- }
-
- private void positionChanged(int newX, int newY) {
- x = newX;
- y = newY;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
- }
- sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
- }
-
- /**
- *
- * @param focusOwner if focusGained is true, focusOwner is the previous
- * focus owner, if focusGained is false, focusOwner is the new focus owner
- * @param focusGained
- */
- private void focusChanged(long focusOwner, boolean focusGained) {
- if (focusGained) {
- sendWindowEvent(WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
- } else {
- sendWindowEvent(WindowEvent.EVENT_WINDOW_LOST_FOCUS);
- }
- }
-}
diff --git a/src/newt/classes/com/sun/javafx/newt/x11/X11Display.java b/src/newt/classes/com/sun/javafx/newt/x11/X11Display.java
deleted file mode 100755
index ae23c4423..000000000
--- a/src/newt/classes/com/sun/javafx/newt/x11/X11Display.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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 javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-import com.sun.javafx.newt.*;
-import com.sun.javafx.newt.impl.*;
-import com.sun.nativewindow.impl.x11.X11Util;
-
-public class X11Display extends Display {
- static {
- NativeLibLoader.loadNEWT();
-
- if (!initIDs()) {
- throw new NativeWindowException("Failed to initialize X11Display jmethodIDs");
- }
-
- if (!X11Window.initIDs()) {
- throw new NativeWindowException("Failed to initialize X11Window jmethodIDs");
- }
- }
-
- public static void initSingleton() {
- // just exist to ensure static init has been run
- }
-
-
- public X11Display() {
- }
-
- protected void createNative() {
- long handle= X11Util.getThreadLocalDisplay(name);
- if (handle == 0 ) {
- throw new RuntimeException("Error creating display: "+name);
- }
- try {
- CompleteDisplay(handle);
- } catch(RuntimeException e) {
- X11Util.closeThreadLocalDisplay(name);
- throw e;
- }
- aDevice = new X11GraphicsDevice(handle);
- }
-
- protected void closeNative() {
- if(0==X11Util.closeThreadLocalDisplay(name)) {
- throw new NativeWindowException(this+" was not mapped");
- }
- }
-
- protected void dispatchMessages() {
- DispatchMessages(getHandle(), javaObjectAtom, windowDeleteAtom);
- }
-
- protected void lockDisplay() {
- super.lockDisplay();
- LockDisplay(getHandle());
- }
-
- protected void unlockDisplay() {
- UnlockDisplay(getHandle());
- super.unlockDisplay();
- }
-
- protected long getJavaObjectAtom() { return javaObjectAtom; }
- protected long getWindowDeleteAtom() { return windowDeleteAtom; }
-
- //----------------------------------------------------------------------
- // Internals only
- //
- private static native boolean initIDs();
-
- private native void LockDisplay(long handle);
- private native void UnlockDisplay(long handle);
-
- private native void CompleteDisplay(long handle);
-
- private native void DispatchMessages(long display, long javaObjectAtom, long windowDeleteAtom);
-
- private void displayCompleted(long javaObjectAtom, long windowDeleteAtom) {
- this.javaObjectAtom=javaObjectAtom;
- this.windowDeleteAtom=windowDeleteAtom;
- }
-
- private long windowDeleteAtom;
- private long javaObjectAtom;
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/x11/X11Screen.java b/src/newt/classes/com/sun/javafx/newt/x11/X11Screen.java
deleted file mode 100755
index cee576e2c..000000000
--- a/src/newt/classes/com/sun/javafx/newt/x11/X11Screen.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.javafx.newt.impl.*;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-
-public class X11Screen extends Screen {
-
- static {
- X11Display.initSingleton();
- }
-
-
- public X11Screen() {
- }
-
- protected void createNative(int index) {
- long handle = GetScreen(display.getHandle(), index);
- if (handle == 0 ) {
- throw new RuntimeException("Error creating screen: "+index);
- }
- aScreen = new X11GraphicsScreen((X11GraphicsDevice)getDisplay().getGraphicsDevice(), index);
- setScreenSize(getWidth0(display.getHandle(), index),
- getHeight0(display.getHandle(), index));
- }
-
- protected void closeNative() { }
-
- //----------------------------------------------------------------------
- // Internals only
- //
-
- private native long GetScreen(long dpy, int scrn_idx);
- private native int getWidth0(long display, int scrn_idx);
- private native int getHeight0(long display, int scrn_idx);
-}
-
diff --git a/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java b/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java
deleted file mode 100755
index f46ae9564..000000000
--- a/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * 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.javafx.newt.impl.*;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-
-public class X11Window extends Window {
- private static final String WINDOW_CLASS_NAME = "NewtWindow";
- // non fullscreen dimensions ..
- private int nfs_width, nfs_height, nfs_x, nfs_y;
-
- static {
- X11Display.initSingleton();
- }
-
- public X11Window() {
- }
-
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- X11Screen screen = (X11Screen) getScreen();
- X11Display display = (X11Display) screen.getDisplay();
- config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
- if (config == null) {
- throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
- }
- X11GraphicsConfiguration x11config = (X11GraphicsConfiguration) config;
- long visualID = x11config.getVisualID();
- long w = CreateWindow(parentWindowHandle,
- display.getHandle(), screen.getIndex(), visualID,
- display.getJavaObjectAtom(), display.getWindowDeleteAtom(), x, y, width, height);
- if (w == 0 || w!=windowHandle) {
- throw new NativeWindowException("Error creating window: "+w);
- }
- this.parentWindowHandle = parentWindowHandle;
- windowHandleClose = windowHandle;
- displayHandleClose = display.getHandle();
- }
-
- protected void closeNative() {
- if(0!=displayHandleClose && 0!=windowHandleClose && null!=getScreen() ) {
- X11Display display = (X11Display) getScreen().getDisplay();
- CloseWindow(displayHandleClose, windowHandleClose, display.getJavaObjectAtom());
- windowHandleClose = 0;
- displayHandleClose = 0;
- }
- }
-
- protected void windowDestroyed() {
- windowHandleClose = 0;
- displayHandleClose = 0;
- super.windowDestroyed();
- }
-
- public void setVisible(boolean visible) {
- if(0!=windowHandle && this.visible!=visible) {
- this.visible=visible;
- setVisible0(getDisplayHandle(), windowHandle, visible);
- clearEventMask();
- }
- }
-
- public void requestFocus() {
- super.requestFocus();
- }
-
- public void setSize(int width, int height) {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("X11Window setSize: "+this.x+"/"+this.y+" "+this.width+"x"+this.height+" -> "+width+"x"+height);
- // Exception e = new Exception("XXXXXXXXXX");
- // e.printStackTrace();
- }
- this.width = width;
- this.height = height;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- }
- if(0!=windowHandle) {
- setSize0(parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, width, height, (undecorated||fullscreen)?-1:1, false);
- }
- }
-
- public void setPosition(int x, int y) {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("X11Window setPosition: "+this.x+"/"+this.y+" -> "+x+"/"+y);
- // Exception e = new Exception("XXXXXXXXXX");
- // e.printStackTrace();
- }
- this.x = x;
- this.y = y;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
- }
- if(0!=windowHandle) {
- setPosition0(getDisplayHandle(), windowHandle, x, y);
- }
- }
-
- public boolean setFullscreen(boolean fullscreen) {
- if(0!=windowHandle && this.fullscreen!=fullscreen) {
- int x,y,w,h;
- this.fullscreen=fullscreen;
- if(fullscreen) {
- x = 0; y = 0;
- w = screen.getWidth();
- h = screen.getHeight();
- } else {
- x = nfs_x;
- y = nfs_y;
- w = nfs_width;
- h = nfs_height;
- }
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- System.err.println("X11Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
- }
- setSize0(parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, w, h, (undecorated||fullscreen)?-1:1, false);
- }
- return fullscreen;
- }
-
- //----------------------------------------------------------------------
- // Internals only
- //
-
- protected static native boolean initIDs();
- private native long CreateWindow(long parentWindowHandle, long display, int screen_index,
- long visualID, long javaObjectAtom, long windowDeleteAtom, int x, int y, int width, int height);
- private native void CloseWindow(long display, long windowHandle, long javaObjectAtom);
- private native void setVisible0(long display, long windowHandle, boolean visible);
- private native void setSize0(long parentWindowHandle, long display, int screen_index, long windowHandle,
- int x, int y, int width, int height, int decorationToggle, boolean setVisible);
- private native void setPosition0(long display, long windowHandle, int x, int y);
-
- private void windowChanged(int newX, int newY, int newWidth, int newHeight) {
- if(width != newWidth || height != newHeight) {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("X11Window windowChanged size: "+this.width+"x"+this.height+" -> "+newWidth+"x"+newHeight);
- }
- width = newWidth;
- height = newHeight;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- }
- sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
- }
- if( 0==parentWindowHandle && ( x != newX || y != newY ) ) {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("X11Window windowChanged position: "+this.x+"/"+this.y+" -> "+newX+"x"+newY);
- }
- x = newX;
- y = newY;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
- }
- sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
- }
- }
-
- private void windowCreated(long windowHandle) {
- this.windowHandle = windowHandle;
- }
-
- private long windowHandleClose;
- private long displayHandleClose;
- private long parentWindowHandle;
-}
diff --git a/src/newt/native/BroadcomEGL.c b/src/newt/native/BroadcomEGL.c
index 55688f9d1..8a9c5f948 100755
--- a/src/newt/native/BroadcomEGL.c
+++ b/src/newt/native/BroadcomEGL.c
@@ -41,7 +41,7 @@
#include java -Djava.awt.headless=true demos.es2.RedSquare -GL2
* Single thread (MacOSX) java -XstartOnFirstThread -Djava.awt.headless=true demos.es2.RedSquare -GL2
* Multiple threads & windows (Unix, Win32) java -Djava.awt.headless=true demos.es2.RedSquare -GL2 -GL2 -GL2 -GL2
-* Multiple threads & windows (MacOSX) java -XstartOnFirstThread -Djava.awt.headless=true com.jogamp.javafx.newt.util.MainThread demos.es2.RedSquare -GL2 -GL2 -GL2 -GL2
+* Multiple threads & windows (MacOSX) java -XstartOnFirstThread -Djava.awt.headless=true com.jogamp.newt.util.MainThread demos.es2.RedSquare -GL2 -GL2 -GL2 -GL2
-The serialization of the main Java class through ''com.jogamp.javafx.newt.util.MainThread''
+The serialization of the main Java class through ''com.jogamp.newt.util.MainThread''
may be used for all platforms, since it only takes effect on ''MacOSX''.
This allows you an almost platform independent invocation of your multithreaded Java applications.
-On ''MacOSX'', ''com.jogamp.javafx.newt.util.MainThread'' will occupy the main thread and
+On ''MacOSX'', ''com.jogamp.newt.util.MainThread'' will occupy the main thread and
serializes all native window related tasks through it.
This mechanism is thread safe utilizes reentrant locking.
diff --git a/doxygen/doxygen-all-pub.cfg b/doxygen/doxygen-all-pub.cfg
index a7f4711df..a94c49fb0 100644
--- a/doxygen/doxygen-all-pub.cfg
+++ b/doxygen/doxygen-all-pub.cfg
@@ -462,7 +462,7 @@ WARN_LOGFILE =
INPUT = ../src/jogl/classes/javax
INPUT += ../build-x86_64/jogl/gensrc/classes/javax
INPUT += ../src/jogl/classes/com/jogamp/opengl/util
-INPUT += ../src/newt/classes/com/jogamp/javafx/newt
+INPUT += ../src/newt/classes/com/jogamp/newt
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
diff --git a/make/build-jogl.xml b/make/build-jogl.xml
index c3bc96bd8..4a0bac4d5 100644
--- a/make/build-jogl.xml
+++ b/make/build-jogl.xml
@@ -191,10 +191,10 @@
+ falloffFactor
+ -------------------
+ falloffFactor + r^2
+
+*/
+ public void setFalloffFactor(float factor) {
+ falloffFactor = factor;
+ }
+
+ public void shutdown() {
+ synchronized(shutdownLock) {
+ shutdown = true;
+ SetEvent(event);
+ try {
+ shutdownLock.wait();
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+ class FillerThread extends Thread {
+ FillerThread() {
+ super("Mixer Thread");
+ }
+
+ public void run() {
+ while (!shutdown) {
+ List/*
- falloffFactor
- -------------------
- falloffFactor + r^2
-
-*/
- public void setFalloffFactor(float factor) {
- falloffFactor = factor;
- }
-
- public void shutdown() {
- synchronized(shutdownLock) {
- shutdown = true;
- SetEvent(event);
- try {
- shutdownLock.wait();
- } catch (InterruptedException e) {
- }
- }
- }
-
- class FillerThread extends Thread {
- FillerThread() {
- super("Mixer Thread");
- }
-
- public void run() {
- while (!shutdown) {
- List/*
This protocol does not describe how to create native windows, but how to bind a native window to an implementation of
{@link javax.media.nativewindow.NativeWindow NativeWindow}.
- However, an implementation of this protocol (e.g. {@link com.jogamp.javafx.newt}) may support the creation.
+ However, an implementation of this protocol (e.g. {@link com.jogamp.newt}) may support the creation.
Dependencies
This binding has dependencies to the following:
diff --git a/src/newt/classes/com/jogamp/javafx/newt/Display.java b/src/newt/classes/com/jogamp/javafx/newt/Display.java
deleted file mode 100755
index 5c5db0338..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/Display.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * 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.jogamp.javafx.newt;
-
-import javax.media.nativewindow.*;
-import com.jogamp.javafx.newt.impl.Debug;
-import com.jogamp.javafx.newt.util.EventDispatchThread;
-import java.util.*;
-
-public abstract class Display {
- public static final boolean DEBUG = Debug.debug("Display");
-
- private static Class getDisplayClass(String type)
- throws ClassNotFoundException
- {
- Class displayClass = NewtFactory.getCustomClass(type, "Display");
- if(null==displayClass) {
- if (NativeWindowFactory.TYPE_EGL.equals(type)) {
- displayClass = Class.forName("com.jogamp.javafx.newt.opengl.kd.KDDisplay");
- } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
- displayClass = Class.forName("com.jogamp.javafx.newt.windows.WindowsDisplay");
- } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
- displayClass = Class.forName("com.jogamp.javafx.newt.macosx.MacDisplay");
- } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
- displayClass = Class.forName("com.jogamp.javafx.newt.x11.X11Display");
- } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
- displayClass = Class.forName("com.jogamp.javafx.newt.awt.AWTDisplay");
- } else {
- throw new RuntimeException("Unknown display type \"" + type + "\"");
- }
- }
- return displayClass;
- }
-
- // Unique Display for each thread
- private static ThreadLocal currentDisplayMap = new ThreadLocal();
-
- /** Returns the thread local display map */
- public static Map getCurrentDisplayMap() {
- Map displayMap = (Map) currentDisplayMap.get();
- if(null==displayMap) {
- displayMap = new HashMap();
- currentDisplayMap.set( displayMap );
- }
- return displayMap;
- }
-
- /** maps the given display to the thread local display map
- * and notifies all threads synchronized to this display map. */
- protected static Display setCurrentDisplay(Display display) {
- Map displayMap = getCurrentDisplayMap();
- Display oldDisplay = null;
- synchronized(displayMap) {
- String name = display.getName();
- if(null==name) name="nil";
- oldDisplay = (Display) displayMap.put(name, display);
- displayMap.notifyAll();
- }
- return oldDisplay;
- }
-
- /** removes the mapping of the given name from the thread local display map
- * and notifies all threads synchronized to this display map. */
- protected static Display removeCurrentDisplay(String name) {
- if(null==name) name="nil";
- Map displayMap = getCurrentDisplayMap();
- Display oldDisplay = null;
- synchronized(displayMap) {
- oldDisplay = (Display) displayMap.remove(name);
- displayMap.notifyAll();
- }
- return oldDisplay;
- }
-
- /** Returns the thread local display mapped to the given name */
- public static Display getCurrentDisplay(String name) {
- if(null==name) name="nil";
- Map displayMap = getCurrentDisplayMap();
- Display display = (Display) displayMap.get(name);
- return display;
- }
-
- public static void dumpDisplayMap(String prefix) {
- Map displayMap = getCurrentDisplayMap();
- Set entrySet = displayMap.entrySet();
- Iterator i = entrySet.iterator();
- System.err.println(prefix+" DisplayMap["+entrySet.size()+"] "+Thread.currentThread());
- for(int j=0; i.hasNext(); j++) {
- Map.Entry entry = (Map.Entry) i.next();
- System.err.println(" ["+j+"] "+entry.getKey()+" -> "+entry.getValue());
- }
- }
-
- /** Returns the thread local display collection */
- public static Collection getCurrentDisplays() {
- return getCurrentDisplayMap().values();
- }
-
- /** Make sure to reuse a Display with the same name */
- protected static Display create(String type, String name) {
- try {
- if(DEBUG) {
- dumpDisplayMap("Display.create("+name+") BEGIN");
- }
- Display display = getCurrentDisplay(name);
- if(null==display) {
- Class displayClass = getDisplayClass(type);
- display = (Display) displayClass.newInstance();
- display.name=name;
- display.refCount=1;
-
- if(NewtFactory.useEDT()) {
- Thread current = Thread.currentThread();
- display.eventDispatchThread = new EventDispatchThread(display, current.getThreadGroup(), current.getName());
- display.eventDispatchThread.start();
- final Display f_dpy = display;
- display.eventDispatchThread.invokeAndWait(new Runnable() {
- public void run() {
- f_dpy.createNative();
- }
- } );
- } else {
- display.createNative();
- }
- if(null==display.aDevice) {
- throw new RuntimeException("Display.createNative() failed to instanciate an AbstractGraphicsDevice");
- }
- setCurrentDisplay(display);
- if(DEBUG) {
- System.err.println("Display.create("+name+") NEW: "+display+" "+Thread.currentThread());
- }
- } else {
- synchronized(display) {
- display.refCount++;
- if(DEBUG) {
- System.err.println("Display.create("+name+") REUSE: refCount "+display.refCount+", "+display+" "+Thread.currentThread());
- }
- }
- }
- if(DEBUG) {
- dumpDisplayMap("Display.create("+name+") END");
- }
- return display;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- protected static Display wrapHandle(String type, String name, AbstractGraphicsDevice aDevice) {
- try {
- Class displayClass = getDisplayClass(type);
- Display display = (Display) displayClass.newInstance();
- display.name=name;
- display.aDevice=aDevice;
- return display;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public EventDispatchThread getEDT() { return eventDispatchThread; }
-
- public synchronized void destroy() {
- if(DEBUG) {
- dumpDisplayMap("Display.destroy("+name+") BEGIN");
- }
- refCount--;
- if(0==refCount) {
- removeCurrentDisplay(name);
- if(DEBUG) {
- System.err.println("Display.destroy("+name+") REMOVE: "+this+" "+Thread.currentThread());
- }
- if(null!=eventDispatchThread) {
- final Display f_dpy = this;
- final EventDispatchThread f_edt = eventDispatchThread;
- eventDispatchThread.invokeAndWait(new Runnable() {
- public void run() {
- f_dpy.closeNative();
- f_edt.stop();
- }
- } );
- } else {
- closeNative();
- }
- if(null!=eventDispatchThread) {
- eventDispatchThread.waitUntilStopped();
- eventDispatchThread=null;
- }
- aDevice = null;
- } else {
- if(DEBUG) {
- System.err.println("Display.destroy("+name+") KEEP: refCount "+refCount+", "+this+" "+Thread.currentThread());
- }
- }
- if(DEBUG) {
- dumpDisplayMap("Display.destroy("+name+") END");
- }
- }
-
- protected abstract void createNative();
- protected abstract void closeNative();
-
- public String getName() {
- return name;
- }
-
- public long getHandle() {
- if(null!=aDevice) {
- return aDevice.getHandle();
- }
- return 0;
- }
-
- public AbstractGraphicsDevice getGraphicsDevice() {
- return aDevice;
- }
-
- public void pumpMessages() {
- if(null!=eventDispatchThread) {
- dispatchMessages();
- } else {
- synchronized(this) {
- dispatchMessages();
- }
- }
- }
-
- public String toString() {
- return "NEWT-Display["+name+", refCount "+refCount+", "+aDevice+"]";
- }
-
- protected abstract void dispatchMessages();
-
- /** Default impl. nop - Currently only X11 needs a Display lock */
- protected void lockDisplay() { }
-
- /** Default impl. nop - Currently only X11 needs a Display lock */
- protected void unlockDisplay() { }
-
- protected EventDispatchThread eventDispatchThread = null;
- protected String name;
- protected int refCount;
- protected AbstractGraphicsDevice aDevice;
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/Event.java b/src/newt/classes/com/jogamp/javafx/newt/Event.java
deleted file mode 100644
index 4274454ab..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/Event.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.jogamp.javafx.newt;
-
-public class Event {
- private boolean isSystemEvent;
- private int eventType;
- private Window source;
- private long when;
-
- Event(boolean isSystemEvent, int eventType, Window source, long when) {
- this.isSystemEvent = isSystemEvent;
- this.eventType = eventType;
- this.source = source;
- this.when = when;
- }
-
- protected Event(int eventType, Window source, long when) {
- this(false, eventType, source, when);
- }
-
- /** Indicates whether this event was produced by the system or
- generated by user code. */
- public final boolean isSystemEvent() {
- return isSystemEvent;
- }
-
- /** Returns the event type of this event. */
- public final int getEventType() {
- return eventType;
- }
-
- /** Returns the source Window which produced this Event. */
- public final Window getSource() {
- return source;
- }
-
- /** Returns the timestamp, in milliseconds, of this event. */
- public final long getWhen() {
- return when;
- }
-
- public String toString() {
- return "Event[sys:"+isSystemEvent()+", source:"+getSource()+", when:"+getWhen()+"]";
- }
-
- public static String toHexString(int hex) {
- return "0x" + Integer.toHexString(hex);
- }
-
- public static String toHexString(long hex) {
- return "0x" + Long.toHexString(hex);
- }
-
-}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/EventListener.java b/src/newt/classes/com/jogamp/javafx/newt/EventListener.java
deleted file mode 100644
index 065cc1de3..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/EventListener.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.jogamp.javafx.newt;
-
-public interface EventListener
-{
- public static final int WINDOW = 1 << 0;
- public static final int MOUSE = 1 << 1;
- public static final int KEY = 1 << 2;
- public static final int SURFACE = 1 << 3;
-
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/InputEvent.java b/src/newt/classes/com/jogamp/javafx/newt/InputEvent.java
deleted file mode 100644
index 0cfaaa4c0..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/InputEvent.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.jogamp.javafx.newt;
-
-public abstract class InputEvent extends Event
-{
- public static final int SHIFT_MASK = 1 << 0;
- public static final int CTRL_MASK = 1 << 1;
- public static final int META_MASK = 1 << 2;
- public static final int ALT_MASK = 1 << 3;
- public static final int ALT_GRAPH_MASK = 1 << 5;
- public static final int BUTTON1_MASK = 1 << 6;
- public static final int BUTTON2_MASK = 1 << 7;
- public static final int BUTTON3_MASK = 1 << 8;
-
- protected InputEvent(boolean sysEvent, int eventType, Window source, long when, int modifiers) {
- super(sysEvent, eventType, source, when);
- this.consumed=false;
- this.modifiers=modifiers;
- }
-
- public void consume() {
- consumed=true;
- }
-
- public boolean isConsumed() {
- return consumed;
- }
- public int getModifiers() {
- return modifiers;
- }
- public boolean isAltDown() {
- return (modifiers&ALT_MASK)!=0;
- }
- public boolean isAltGraphDown() {
- return (modifiers&ALT_GRAPH_MASK)!=0;
- }
- public boolean isControlDown() {
- return (modifiers&CTRL_MASK)!=0;
- }
- public boolean isMetaDown() {
- return (modifiers&META_MASK)!=0;
- }
- public boolean isShiftDown() {
- return (modifiers&SHIFT_MASK)!=0;
- }
-
- public boolean isButton1Down() {
- return (modifiers&BUTTON1_MASK)!=0;
- }
-
- public boolean isButton2Down() {
- return (modifiers&BUTTON2_MASK)!=0;
- }
-
- public boolean isButton3Down() {
- return (modifiers&BUTTON3_MASK)!=0;
- }
-
- public String toString() {
- return "InputEvent[modifiers:"+modifiers+"]";
- }
-
- private boolean consumed;
- private int modifiers;
-}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/Insets.java b/src/newt/classes/com/jogamp/javafx/newt/Insets.java
deleted file mode 100644
index 5c91847f4..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/Insets.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2009 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.jogamp.javafx.newt;
-
-/**
- * Simple class representing insets.
- *
- * @author tdv
- */
-public class Insets implements Cloneable {
- public int top;
- public int left;
- public int bottom;
- public int right;
-
- /**
- * Creates and initializes a new Insets
object with the
- * specified top, left, bottom, and right insets.
- * @param top the inset from the top.
- * @param left the inset from the left.
- * @param bottom the inset from the bottom.
- * @param right the inset from the right.
- */
- public Insets(int top, int left, int bottom, int right) {
- this.top = top;
- this.left = left;
- this.bottom = bottom;
- this.right = right;
- }
-
- /**
- * Checks whether two insets objects are equal. Two instances
- * of Insets
are equal if the four integer values
- * of the fields top
, left
,
- * bottom
, and right
are all equal.
- * @return true
if the two insets are equal;
- * otherwise false
.
- */
- public boolean equals(Object obj) {
- if (obj instanceof Insets) {
- Insets insets = (Insets)obj;
- return ((top == insets.top) && (left == insets.left) &&
- (bottom == insets.bottom) && (right == insets.right));
- }
- return false;
- }
-
- /**
- * Returns the hash code for this Insets.
- *
- * @return a hash code for this Insets.
- */
- public int hashCode() {
- int sum1 = left + bottom;
- int sum2 = right + top;
- int val1 = sum1 * (sum1 + 1)/2 + left;
- int val2 = sum2 * (sum2 + 1)/2 + top;
- int sum3 = val1 + val2;
- return sum3 * (sum3 + 1)/2 + val2;
- }
-
- public String toString() {
- return getClass().getName() + "[top=" + top + ",left=" + left +
- ",bottom=" + bottom + ",right=" + right + "]";
- }
-
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
-}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/KeyEvent.java b/src/newt/classes/com/jogamp/javafx/newt/KeyEvent.java
deleted file mode 100644
index 8ae92464c..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/KeyEvent.java
+++ /dev/null
@@ -1,738 +0,0 @@
-/*
- * 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.jogamp.javafx.newt;
-
-public class KeyEvent extends InputEvent
-{
- KeyEvent(boolean sysEvent, int eventType, Window source, long when, int modifiers, int keyCode, char keyChar) {
- super(sysEvent, eventType, source, when, modifiers);
- this.keyCode=keyCode;
- this.keyChar=keyChar;
- }
- public KeyEvent(int eventType, Window source, long when, int modifiers, int keyCode, char keyChar) {
- this(false, eventType, source, when, modifiers, keyCode, keyChar);
- }
-
- public char getKeyChar() {
- return keyChar;
- }
- public int getKeyCode() {
- return keyCode;
- }
-
- public String toString() {
- return "KeyEvent["+getEventTypeString(getEventType())+
- ", code "+keyCode+"("+toHexString(keyCode)+"), char <"+keyChar+"> ("+toHexString((int)keyChar)+"), isActionKey "+isActionKey()+", "+super.toString()+"]";
- }
-
- public static String getEventTypeString(int type) {
- switch(type) {
- case EVENT_KEY_PRESSED: return "EVENT_KEY_PRESSED";
- case EVENT_KEY_RELEASED: return "EVENT_KEY_RELEASED";
- case EVENT_KEY_TYPED: return "EVENT_KEY_TYPED";
- default: return "unknown (" + type + ")";
- }
- }
-
- public boolean isActionKey() {
- switch (keyCode) {
- case VK_HOME:
- case VK_END:
- case VK_PAGE_UP:
- case VK_PAGE_DOWN:
- case VK_UP:
- case VK_DOWN:
- case VK_LEFT:
- case VK_RIGHT:
-
- case VK_F1:
- case VK_F2:
- case VK_F3:
- case VK_F4:
- case VK_F5:
- case VK_F6:
- case VK_F7:
- case VK_F8:
- case VK_F9:
- case VK_F10:
- case VK_F11:
- case VK_F12:
- case VK_F13:
- case VK_F14:
- case VK_F15:
- case VK_F16:
- case VK_F17:
- case VK_F18:
- case VK_F19:
- case VK_F20:
- case VK_F21:
- case VK_F22:
- case VK_F23:
- case VK_F24:
- case VK_PRINTSCREEN:
- case VK_CAPS_LOCK:
- case VK_PAUSE:
- case VK_INSERT:
-
- case VK_HELP:
- case VK_WINDOWS:
- return true;
- }
- return false;
- }
-
- private int keyCode;
- private char keyChar;
-
- public static final int EVENT_KEY_PRESSED = 300;
- public static final int EVENT_KEY_RELEASED= 301;
- public static final int EVENT_KEY_TYPED = 302;
-
- /* Virtual key codes. */
-
- public static final int VK_ENTER = '\n';
- public static final int VK_BACK_SPACE = '\b';
- public static final int VK_TAB = '\t';
- public static final int VK_CANCEL = 0x03;
- public static final int VK_CLEAR = 0x0C;
- public static final int VK_SHIFT = 0x10;
- public static final int VK_CONTROL = 0x11;
- public static final int VK_ALT = 0x12;
- public static final int VK_PAUSE = 0x13;
- public static final int VK_CAPS_LOCK = 0x14;
- public static final int VK_ESCAPE = 0x1B;
- public static final int VK_SPACE = 0x20;
- public static final int VK_PAGE_UP = 0x21;
- public static final int VK_PAGE_DOWN = 0x22;
- public static final int VK_END = 0x23;
- public static final int VK_HOME = 0x24;
-
- /**
- * Constant for the non-numpad left arrow key.
- * @see #VK_KP_LEFT
- */
- public static final int VK_LEFT = 0x25;
-
- /**
- * Constant for the non-numpad up arrow key.
- * @see #VK_KP_UP
- */
- public static final int VK_UP = 0x26;
-
- /**
- * Constant for the non-numpad right arrow key.
- * @see #VK_KP_RIGHT
- */
- public static final int VK_RIGHT = 0x27;
-
- /**
- * Constant for the non-numpad down arrow key.
- * @see #VK_KP_DOWN
- */
- public static final int VK_DOWN = 0x28;
-
- /**
- * Constant for the comma key, ","
- */
- public static final int VK_COMMA = 0x2C;
-
- /**
- * Constant for the minus key, "-"
- * @since 1.2
- */
- public static final int VK_MINUS = 0x2D;
-
- /**
- * Constant for the period key, "."
- */
- public static final int VK_PERIOD = 0x2E;
-
- /**
- * Constant for the forward slash key, "/"
- */
- public static final int VK_SLASH = 0x2F;
-
- /** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
- public static final int VK_0 = 0x30;
- public static final int VK_1 = 0x31;
- public static final int VK_2 = 0x32;
- public static final int VK_3 = 0x33;
- public static final int VK_4 = 0x34;
- public static final int VK_5 = 0x35;
- public static final int VK_6 = 0x36;
- public static final int VK_7 = 0x37;
- public static final int VK_8 = 0x38;
- public static final int VK_9 = 0x39;
-
- /**
- * Constant for the semicolon key, ";"
- */
- public static final int VK_SEMICOLON = 0x3B;
-
- /**
- * Constant for the equals key, "="
- */
- public static final int VK_EQUALS = 0x3D;
-
- /** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
- public static final int VK_A = 0x41;
- public static final int VK_B = 0x42;
- public static final int VK_C = 0x43;
- public static final int VK_D = 0x44;
- public static final int VK_E = 0x45;
- public static final int VK_F = 0x46;
- public static final int VK_G = 0x47;
- public static final int VK_H = 0x48;
- public static final int VK_I = 0x49;
- public static final int VK_J = 0x4A;
- public static final int VK_K = 0x4B;
- public static final int VK_L = 0x4C;
- public static final int VK_M = 0x4D;
- public static final int VK_N = 0x4E;
- public static final int VK_O = 0x4F;
- public static final int VK_P = 0x50;
- public static final int VK_Q = 0x51;
- public static final int VK_R = 0x52;
- public static final int VK_S = 0x53;
- public static final int VK_T = 0x54;
- public static final int VK_U = 0x55;
- public static final int VK_V = 0x56;
- public static final int VK_W = 0x57;
- public static final int VK_X = 0x58;
- public static final int VK_Y = 0x59;
- public static final int VK_Z = 0x5A;
-
- /**
- * Constant for the open bracket key, "["
- */
- public static final int VK_OPEN_BRACKET = 0x5B;
-
- /**
- * Constant for the back slash key, "\"
- */
- public static final int VK_BACK_SLASH = 0x5C;
-
- /**
- * Constant for the close bracket key, "]"
- */
- public static final int VK_CLOSE_BRACKET = 0x5D;
-
- public static final int VK_NUMPAD0 = 0x60;
- public static final int VK_NUMPAD1 = 0x61;
- public static final int VK_NUMPAD2 = 0x62;
- public static final int VK_NUMPAD3 = 0x63;
- public static final int VK_NUMPAD4 = 0x64;
- public static final int VK_NUMPAD5 = 0x65;
- public static final int VK_NUMPAD6 = 0x66;
- public static final int VK_NUMPAD7 = 0x67;
- public static final int VK_NUMPAD8 = 0x68;
- public static final int VK_NUMPAD9 = 0x69;
- public static final int VK_MULTIPLY = 0x6A;
- public static final int VK_ADD = 0x6B;
-
- /**
- * This constant is obsolete, and is included only for backwards
- * compatibility.
- * @see #VK_SEPARATOR
- */
- public static final int VK_SEPARATER = 0x6C;
-
- /**
- * Constant for the Numpad Separator key.
- * @since 1.4
- */
- public static final int VK_SEPARATOR = VK_SEPARATER;
-
- public static final int VK_SUBTRACT = 0x6D;
- public static final int VK_DECIMAL = 0x6E;
- public static final int VK_DIVIDE = 0x6F;
- public static final int VK_DELETE = 0x7F; /* ASCII DEL */
- public static final int VK_NUM_LOCK = 0x90;
- public static final int VK_SCROLL_LOCK = 0x91;
-
- /** Constant for the F1 function key. */
- public static final int VK_F1 = 0x70;
-
- /** Constant for the F2 function key. */
- public static final int VK_F2 = 0x71;
-
- /** Constant for the F3 function key. */
- public static final int VK_F3 = 0x72;
-
- /** Constant for the F4 function key. */
- public static final int VK_F4 = 0x73;
-
- /** Constant for the F5 function key. */
- public static final int VK_F5 = 0x74;
-
- /** Constant for the F6 function key. */
- public static final int VK_F6 = 0x75;
-
- /** Constant for the F7 function key. */
- public static final int VK_F7 = 0x76;
-
- /** Constant for the F8 function key. */
- public static final int VK_F8 = 0x77;
-
- /** Constant for the F9 function key. */
- public static final int VK_F9 = 0x78;
-
- /** Constant for the F10 function key. */
- public static final int VK_F10 = 0x79;
-
- /** Constant for the F11 function key. */
- public static final int VK_F11 = 0x7A;
-
- /** Constant for the F12 function key. */
- public static final int VK_F12 = 0x7B;
-
- /**
- * Constant for the F13 function key.
- * @since 1.2
- */
- /* F13 - F24 are used on IBM 3270 keyboard; use random range for constants. */
- public static final int VK_F13 = 0xF000;
-
- /**
- * Constant for the F14 function key.
- * @since 1.2
- */
- public static final int VK_F14 = 0xF001;
-
- /**
- * Constant for the F15 function key.
- * @since 1.2
- */
- public static final int VK_F15 = 0xF002;
-
- /**
- * Constant for the F16 function key.
- * @since 1.2
- */
- public static final int VK_F16 = 0xF003;
-
- /**
- * Constant for the F17 function key.
- * @since 1.2
- */
- public static final int VK_F17 = 0xF004;
-
- /**
- * Constant for the F18 function key.
- * @since 1.2
- */
- public static final int VK_F18 = 0xF005;
-
- /**
- * Constant for the F19 function key.
- * @since 1.2
- */
- public static final int VK_F19 = 0xF006;
-
- /**
- * Constant for the F20 function key.
- * @since 1.2
- */
- public static final int VK_F20 = 0xF007;
-
- /**
- * Constant for the F21 function key.
- * @since 1.2
- */
- public static final int VK_F21 = 0xF008;
-
- /**
- * Constant for the F22 function key.
- * @since 1.2
- */
- public static final int VK_F22 = 0xF009;
-
- /**
- * Constant for the F23 function key.
- * @since 1.2
- */
- public static final int VK_F23 = 0xF00A;
-
- /**
- * Constant for the F24 function key.
- * @since 1.2
- */
- public static final int VK_F24 = 0xF00B;
-
- public static final int VK_PRINTSCREEN = 0x9A;
- public static final int VK_INSERT = 0x9B;
- public static final int VK_HELP = 0x9C;
- public static final int VK_META = 0x9D;
-
- public static final int VK_BACK_QUOTE = 0xC0;
- public static final int VK_QUOTE = 0xDE;
-
- /**
- * Constant for the numeric keypad up arrow key.
- * @see #VK_UP
- * @since 1.2
- */
- public static final int VK_KP_UP = 0xE0;
-
- /**
- * Constant for the numeric keypad down arrow key.
- * @see #VK_DOWN
- * @since 1.2
- */
- public static final int VK_KP_DOWN = 0xE1;
-
- /**
- * Constant for the numeric keypad left arrow key.
- * @see #VK_LEFT
- * @since 1.2
- */
- public static final int VK_KP_LEFT = 0xE2;
-
- /**
- * Constant for the numeric keypad right arrow key.
- * @see #VK_RIGHT
- * @since 1.2
- */
- public static final int VK_KP_RIGHT = 0xE3;
-
- /* For European keyboards */
- /** @since 1.2 */
- public static final int VK_DEAD_GRAVE = 0x80;
- /** @since 1.2 */
- public static final int VK_DEAD_ACUTE = 0x81;
- /** @since 1.2 */
- public static final int VK_DEAD_CIRCUMFLEX = 0x82;
- /** @since 1.2 */
- public static final int VK_DEAD_TILDE = 0x83;
- /** @since 1.2 */
- public static final int VK_DEAD_MACRON = 0x84;
- /** @since 1.2 */
- public static final int VK_DEAD_BREVE = 0x85;
- /** @since 1.2 */
- public static final int VK_DEAD_ABOVEDOT = 0x86;
- /** @since 1.2 */
- public static final int VK_DEAD_DIAERESIS = 0x87;
- /** @since 1.2 */
- public static final int VK_DEAD_ABOVERING = 0x88;
- /** @since 1.2 */
- public static final int VK_DEAD_DOUBLEACUTE = 0x89;
- /** @since 1.2 */
- public static final int VK_DEAD_CARON = 0x8a;
- /** @since 1.2 */
- public static final int VK_DEAD_CEDILLA = 0x8b;
- /** @since 1.2 */
- public static final int VK_DEAD_OGONEK = 0x8c;
- /** @since 1.2 */
- public static final int VK_DEAD_IOTA = 0x8d;
- /** @since 1.2 */
- public static final int VK_DEAD_VOICED_SOUND = 0x8e;
- /** @since 1.2 */
- public static final int VK_DEAD_SEMIVOICED_SOUND = 0x8f;
-
- /** @since 1.2 */
- public static final int VK_AMPERSAND = 0x96;
- /** @since 1.2 */
- public static final int VK_ASTERISK = 0x97;
- /** @since 1.2 */
- public static final int VK_QUOTEDBL = 0x98;
- /** @since 1.2 */
- public static final int VK_LESS = 0x99;
-
- /** @since 1.2 */
- public static final int VK_GREATER = 0xa0;
- /** @since 1.2 */
- public static final int VK_BRACELEFT = 0xa1;
- /** @since 1.2 */
- public static final int VK_BRACERIGHT = 0xa2;
-
- /**
- * Constant for the "@" key.
- * @since 1.2
- */
- public static final int VK_AT = 0x0200;
-
- /**
- * Constant for the ":" key.
- * @since 1.2
- */
- public static final int VK_COLON = 0x0201;
-
- /**
- * Constant for the "^" key.
- * @since 1.2
- */
- public static final int VK_CIRCUMFLEX = 0x0202;
-
- /**
- * Constant for the "$" key.
- * @since 1.2
- */
- public static final int VK_DOLLAR = 0x0203;
-
- /**
- * Constant for the Euro currency sign key.
- * @since 1.2
- */
- public static final int VK_EURO_SIGN = 0x0204;
-
- /**
- * Constant for the "!" key.
- * @since 1.2
- */
- public static final int VK_EXCLAMATION_MARK = 0x0205;
-
- /**
- * Constant for the inverted exclamation mark key.
- * @since 1.2
- */
- public static final int VK_INVERTED_EXCLAMATION_MARK = 0x0206;
-
- /**
- * Constant for the "(" key.
- * @since 1.2
- */
- public static final int VK_LEFT_PARENTHESIS = 0x0207;
-
- /**
- * Constant for the "#" key.
- * @since 1.2
- */
- public static final int VK_NUMBER_SIGN = 0x0208;
-
- /**
- * Constant for the "+" key.
- * @since 1.2
- */
- public static final int VK_PLUS = 0x0209;
-
- /**
- * Constant for the ")" key.
- * @since 1.2
- */
- public static final int VK_RIGHT_PARENTHESIS = 0x020A;
-
- /**
- * Constant for the "_" key.
- * @since 1.2
- */
- public static final int VK_UNDERSCORE = 0x020B;
-
- /**
- * Constant for the Microsoft Windows "Windows" key.
- * It is used for both the left and right version of the key.
- * @see #getKeyLocation()
- * @since 1.5
- */
- public static final int VK_WINDOWS = 0x020C;
-
- /**
- * Constant for the Microsoft Windows Context Menu key.
- * @since 1.5
- */
- public static final int VK_CONTEXT_MENU = 0x020D;
-
- /* for input method support on Asian Keyboards */
-
- /* not clear what this means - listed in Microsoft Windows API */
- public static final int VK_FINAL = 0x0018;
-
- /** Constant for the Convert function key. */
- /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */
- public static final int VK_CONVERT = 0x001C;
-
- /** Constant for the Don't Convert function key. */
- /* Japanese PC 106 keyboard: muhenkan */
- public static final int VK_NONCONVERT = 0x001D;
-
- /** Constant for the Accept or Commit function key. */
- /* Japanese Solaris keyboard: kakutei */
- public static final int VK_ACCEPT = 0x001E;
-
- /* not clear what this means - listed in Microsoft Windows API */
- public static final int VK_MODECHANGE = 0x001F;
-
- /* replaced by VK_KANA_LOCK for Microsoft Windows and Solaris;
- might still be used on other platforms */
- public static final int VK_KANA = 0x0015;
-
- /* replaced by VK_INPUT_METHOD_ON_OFF for Microsoft Windows and Solaris;
- might still be used for other platforms */
- public static final int VK_KANJI = 0x0019;
-
- /**
- * Constant for the Alphanumeric function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard: eisuu */
- public static final int VK_ALPHANUMERIC = 0x00F0;
-
- /**
- * Constant for the Katakana function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard: katakana */
- public static final int VK_KATAKANA = 0x00F1;
-
- /**
- * Constant for the Hiragana function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard: hiragana */
- public static final int VK_HIRAGANA = 0x00F2;
-
- /**
- * Constant for the Full-Width Characters function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard: zenkaku */
- public static final int VK_FULL_WIDTH = 0x00F3;
-
- /**
- * Constant for the Half-Width Characters function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard: hankaku */
- public static final int VK_HALF_WIDTH = 0x00F4;
-
- /**
- * Constant for the Roman Characters function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard: roumaji */
- public static final int VK_ROMAN_CHARACTERS = 0x00F5;
-
- /**
- * Constant for the All Candidates function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */
- public static final int VK_ALL_CANDIDATES = 0x0100;
-
- /**
- * Constant for the Previous Candidate function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */
- public static final int VK_PREVIOUS_CANDIDATE = 0x0101;
-
- /**
- * Constant for the Code Input function key.
- * @since 1.2
- */
- /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */
- public static final int VK_CODE_INPUT = 0x0102;
-
- /**
- * Constant for the Japanese-Katakana function key.
- * This key switches to a Japanese input method and selects its Katakana input mode.
- * @since 1.2
- */
- /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */
- public static final int VK_JAPANESE_KATAKANA = 0x0103;
-
- /**
- * Constant for the Japanese-Hiragana function key.
- * This key switches to a Japanese input method and selects its Hiragana input mode.
- * @since 1.2
- */
- /* Japanese Macintosh keyboard */
- public static final int VK_JAPANESE_HIRAGANA = 0x0104;
-
- /**
- * Constant for the Japanese-Roman function key.
- * This key switches to a Japanese input method and selects its Roman-Direct input mode.
- * @since 1.2
- */
- /* Japanese Macintosh keyboard */
- public static final int VK_JAPANESE_ROMAN = 0x0105;
-
- /**
- * Constant for the locking Kana function key.
- * This key locks the keyboard into a Kana layout.
- * @since 1.3
- */
- /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */
- public static final int VK_KANA_LOCK = 0x0106;
-
- /**
- * Constant for the input method on/off key.
- * @since 1.3
- */
- /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */
- public static final int VK_INPUT_METHOD_ON_OFF = 0x0107;
-
- /* for Sun keyboards */
- /** @since 1.2 */
- public static final int VK_CUT = 0xFFD1;
- /** @since 1.2 */
- public static final int VK_COPY = 0xFFCD;
- /** @since 1.2 */
- public static final int VK_PASTE = 0xFFCF;
- /** @since 1.2 */
- public static final int VK_UNDO = 0xFFCB;
- /** @since 1.2 */
- public static final int VK_AGAIN = 0xFFC9;
- /** @since 1.2 */
- public static final int VK_FIND = 0xFFD0;
- /** @since 1.2 */
- public static final int VK_PROPS = 0xFFCA;
- /** @since 1.2 */
- public static final int VK_STOP = 0xFFC8;
-
- /**
- * Constant for the Compose function key.
- * @since 1.2
- */
- public static final int VK_COMPOSE = 0xFF20;
-
- /**
- * Constant for the AltGraph function key.
- * @since 1.2
- */
- public static final int VK_ALT_GRAPH = 0xFF7E;
-
- /**
- * Constant for the Begin key.
- * @since 1.5
- */
- public static final int VK_BEGIN = 0xFF58;
-
- /**
- * This value is used to indicate that the keyCode is unknown.
- * KEY_TYPED events do not have a keyCode value; this value
- * is used instead.
- */
- public static final int VK_UNDEFINED = 0x0;
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/KeyListener.java b/src/newt/classes/com/jogamp/javafx/newt/KeyListener.java
deleted file mode 100644
index 7921a0a97..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/KeyListener.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.jogamp.javafx.newt;
-
-public interface KeyListener extends EventListener
-{
- public void keyPressed(KeyEvent e);
- public void keyReleased(KeyEvent e);
- public void keyTyped(KeyEvent e) ;
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/MouseEvent.java b/src/newt/classes/com/jogamp/javafx/newt/MouseEvent.java
deleted file mode 100644
index 82989e216..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/MouseEvent.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.jogamp.javafx.newt;
-
-public class MouseEvent extends InputEvent
-{
- public static final int BUTTON1 = 1;
- public static final int BUTTON2 = 2;
- public static final int BUTTON3 = 3;
- public static final int BUTTON4 = 4;
- public static final int BUTTON5 = 5;
- public static final int BUTTON6 = 6;
- public static final int BUTTON_NUMBER = 6;
-
- protected MouseEvent(boolean sysEvent, int eventType, Window source, long when,
- int modifiers, int x, int y, int clickCount, int button,
- int rotation)
- {
- super(sysEvent, eventType, source, when, modifiers);
- this.x=x;
- this.y=y;
- this.clickCount=clickCount;
- this.button=button;
- this.wheelRotation = rotation;
- }
- public MouseEvent(int eventType, Window source, long when, int modifiers,
- int x, int y, int clickCount, int button, int rotation) {
- this(false, eventType, source, when, modifiers, x, y, clickCount, button,
- rotation);
- }
-
- public int getButton() {
- return button;
- }
- public int getClickCount() {
- return clickCount;
- }
- public int getX() {
- return x;
- }
- public int getY() {
- return y;
- }
- public int getWheelRotation() {
- return wheelRotation;
- }
-
- public String toString() {
- return "MouseEvent["+getEventTypeString(getEventType())+
- ", "+x+"/"+y+", button "+button+", count "+clickCount+
- ", wheel rotation "+wheelRotation+
- ", "+super.toString()+"]";
- }
-
- public static String getEventTypeString(int type) {
- switch(type) {
- case EVENT_MOUSE_CLICKED: return "EVENT_MOUSE_CLICKED";
- case EVENT_MOUSE_ENTERED: return "EVENT_MOUSE_ENTERED";
- case EVENT_MOUSE_EXITED: return "EVENT_MOUSE_EXITED";
- case EVENT_MOUSE_PRESSED: return "EVENT_MOUSE_PRESSED";
- case EVENT_MOUSE_RELEASED: return "EVENT_MOUSE_RELEASED";
- case EVENT_MOUSE_MOVED: return "EVENT_MOUSE_MOVED";
- case EVENT_MOUSE_DRAGGED: return "EVENT_MOUSE_DRAGGED";
- case EVENT_MOUSE_WHEEL_MOVED: return "EVENT_MOUSE_WHEEL_MOVED";
- default: return "unknown (" + type + ")";
- }
- }
-
- private int x, y, clickCount, button, wheelRotation;
-
- public static final int EVENT_MOUSE_CLICKED = 200;
- public static final int EVENT_MOUSE_ENTERED = 201;
- public static final int EVENT_MOUSE_EXITED = 202;
- public static final int EVENT_MOUSE_PRESSED = 203;
- public static final int EVENT_MOUSE_RELEASED = 204;
- public static final int EVENT_MOUSE_MOVED = 205;
- public static final int EVENT_MOUSE_DRAGGED = 206;
- public static final int EVENT_MOUSE_WHEEL_MOVED = 207;
-}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/MouseListener.java b/src/newt/classes/com/jogamp/javafx/newt/MouseListener.java
deleted file mode 100644
index a0d42f738..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/MouseListener.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.jogamp.javafx.newt;
-
-public interface MouseListener extends EventListener
-{
- public void mouseClicked(MouseEvent e);
- public void mouseEntered(MouseEvent e);
- public void mouseExited(MouseEvent e);
- public void mousePressed(MouseEvent e);
- public void mouseReleased(MouseEvent e);
- public void mouseMoved(MouseEvent e);
- public void mouseDragged(MouseEvent e);
- public void mouseWheelMoved(MouseEvent e);
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/NewtFactory.java b/src/newt/classes/com/jogamp/javafx/newt/NewtFactory.java
deleted file mode 100755
index aae51aaf6..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/NewtFactory.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * 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.jogamp.javafx.newt;
-
-import javax.media.nativewindow.*;
-import java.util.ArrayList;
-import java.util.Iterator;
-import com.jogamp.nativewindow.impl.jvm.JVMUtil;
-
-public abstract class NewtFactory {
- // Work-around for initialization order problems on Mac OS X
- // between native Newt and (apparently) Fmod
- static {
- JVMUtil.initSingleton();
- Window.init(NativeWindowFactory.getNativeWindowType(true));
- }
-
- static Class getCustomClass(String packageName, String classBaseName) {
- Class clazz = null;
- if(packageName!=null || classBaseName!=null) {
- String clazzName = packageName + "." + classBaseName ;
- try {
- clazz = Class.forName(clazzName);
- } catch (Throwable t) {}
- }
- return clazz;
- }
-
- private static boolean useEDT = true;
-
- /**
- * Toggles the usage of an EventDispatchThread while creating a Display.
- * The default is enabled.
- * The EventDispatchThread is thread local to the Display instance.
- */
- public static synchronized void setUseEDT(boolean onoff) {
- useEDT = onoff;
- }
-
- /** @see #setUseEDT(boolean) */
- public static boolean useEDT() { return useEDT; }
-
- /**
- * Create a Display entity, incl native creation
- */
- public static Display createDisplay(String name) {
- return Display.create(NativeWindowFactory.getNativeWindowType(true), name);
- }
-
- /**
- * Create a Display entity using the given implementation type, incl native creation
- */
- public static Display createDisplay(String type, String name) {
- return Display.create(type, name);
- }
-
- /**
- * Create a Screen entity, incl native creation
- */
- public static Screen createScreen(Display display, int index) {
- return Screen.create(NativeWindowFactory.getNativeWindowType(true), display, index);
- }
-
- /**
- * Create a Screen entity using the given implementation type, incl native creation
- */
- public static Screen createScreen(String type, Display display, int index) {
- return Screen.create(type, display, index);
- }
-
- /**
- * Create a Window entity, incl native creation
- */
- public static Window createWindow(Screen screen, Capabilities caps) {
- return Window.create(NativeWindowFactory.getNativeWindowType(true), 0, screen, caps, false);
- }
-
- public static Window createWindow(Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(NativeWindowFactory.getNativeWindowType(true), 0, screen, caps, undecorated);
- }
-
- public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(NativeWindowFactory.getNativeWindowType(true), parentWindowHandle, screen, caps, undecorated);
- }
-
- /**
- * Ability to try a Window type with a construnctor argument, if supported .. AWTWindow(Frame frame)
,
- * to support an external created AWT Frame, ie the browsers embedded frame.
- */
- public static Window createWindow(Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(NativeWindowFactory.getNativeWindowType(true), cstrArguments, screen, caps, undecorated);
- }
-
- /**
- * Create a Window entity using the given implementation type, incl native creation
- */
- public static Window createWindow(String type, Screen screen, Capabilities caps) {
- return Window.create(type, 0, screen, caps, false);
- }
-
- public static Window createWindow(String type, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(type, 0, screen, caps, undecorated);
- }
-
- public static Window createWindow(String type, long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(type, parentWindowHandle, screen, caps, undecorated);
- }
-
- public static Window createWindow(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(type, cstrArguments, screen, caps, undecorated);
- }
-
- /**
- * Instantiate a Display entity using the native handle.
- */
- public static Display wrapDisplay(String name, AbstractGraphicsDevice device) {
- return Display.wrapHandle(NativeWindowFactory.getNativeWindowType(true), name, device);
- }
-
- /**
- * Instantiate a Screen entity using the native handle.
- */
- public static Screen wrapScreen(Display display, AbstractGraphicsScreen screen) {
- return Screen.wrapHandle(NativeWindowFactory.getNativeWindowType(true), display, screen);
- }
-
- /**
- * Instantiate a Window entity using the native handle.
- */
- public static Window wrapWindow(Screen screen, AbstractGraphicsConfiguration config,
- long windowHandle, boolean fullscreen, boolean visible,
- int x, int y, int width, int height) {
- return Window.wrapHandle(NativeWindowFactory.getNativeWindowType(true), screen, config,
- windowHandle, fullscreen, visible, x, y, width, height);
- }
-
- private static final boolean instanceOf(Object obj, String clazzName) {
- Class clazz = obj.getClass();
- do {
- if(clazz.getName().equals(clazzName)) {
- return true;
- }
- clazz = clazz.getSuperclass();
- } while (clazz!=null);
- return false;
- }
-
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/OffscreenWindow.java b/src/newt/classes/com/jogamp/javafx/newt/OffscreenWindow.java
deleted file mode 100644
index 015e9b8d2..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/OffscreenWindow.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.jogamp.javafx.newt;
-
-import javax.media.nativewindow.*;
-
-public class OffscreenWindow extends Window implements SurfaceChangeable {
-
- long surfaceHandle = 0;
-
- public OffscreenWindow() {
- }
-
- static long nextWindowHandle = 0x100; // start here - a marker
-
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- if(0!=parentWindowHandle) {
- throw new NativeWindowException("OffscreenWindow does not support window parenting");
- }
- if(caps.isOnscreen()) {
- throw new NativeWindowException("Capabilities is onscreen");
- }
- AbstractGraphicsScreen aScreen = screen.getGraphicsScreen();
- config = GraphicsConfigurationFactory.getFactory(aScreen.getDevice()).chooseGraphicsConfiguration(caps, null, aScreen);
- if (config == null) {
- throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
- }
-
- synchronized(OffscreenWindow.class) {
- windowHandle = nextWindowHandle++;
- }
- }
-
- protected void closeNative() {
- // nop
- }
-
- public void invalidate() {
- super.invalidate();
- surfaceHandle = 0;
- }
-
- public synchronized void destroy() {
- surfaceHandle = 0;
- }
-
- public void setSurfaceHandle(long handle) {
- surfaceHandle = handle ;
- }
-
- public long getSurfaceHandle() {
- return surfaceHandle;
- }
-
- public void setVisible(boolean visible) {
- if(!visible) {
- this.visible = visible;
- }
- }
-
- public void setSize(int width, int height) {
- if(!visible) {
- this.width = width;
- this.height = height;
- }
- }
-
- public void setPosition(int x, int y) {
- // nop
- }
-
- public boolean setFullscreen(boolean fullscreen) {
- // nop
- return false;
- }
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/PaintEvent.java b/src/newt/classes/com/jogamp/javafx/newt/PaintEvent.java
deleted file mode 100755
index 8543246a7..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/PaintEvent.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2009 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.jogamp.javafx.newt;
-
-/**
- *
- * @author tdv
- */
-public class PaintEvent extends Event {
-
- // bounds of the damage region
- private int x, y, width, height;
- public PaintEvent(int eventType, Window source,
- long when, int x, int y, int w, int h)
- {
- super(true, eventType, source, when);
- this.x = x;
- this.y = y;
- this.width = w;
- this.height = h;
- }
-
- public int getHeight() {
- return height;
- }
-
- public int getWidth() {
- return width;
- }
-
- public int getX() {
- return x;
- }
-
- public int getY() {
- return y;
- }
-
- public String toString() {
- return "ExposeEvent[modifiers: x="+x+" y="+y+" w="+width+" h="+height +"]";
- }
-
-}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/PaintListener.java b/src/newt/classes/com/jogamp/javafx/newt/PaintListener.java
deleted file mode 100755
index adfd78f18..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/PaintListener.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2009 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.jogamp.javafx.newt;
-
-/**
- *
- * @author tdv
- */
-public interface PaintListener {
- public void exposed(PaintEvent e);
-}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/Screen.java b/src/newt/classes/com/jogamp/javafx/newt/Screen.java
deleted file mode 100755
index b02a7ef00..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/Screen.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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.jogamp.javafx.newt;
-
-import com.jogamp.javafx.newt.impl.*;
-
-import javax.media.nativewindow.*;
-import java.security.*;
-
-public abstract class Screen {
-
- private static Class getScreenClass(String type)
- throws ClassNotFoundException
- {
- Class screenClass = NewtFactory.getCustomClass(type, "Screen");
- if(null==screenClass) {
- if (NativeWindowFactory.TYPE_EGL.equals(type)) {
- screenClass = Class.forName("com.jogamp.javafx.newt.opengl.kd.KDScreen");
- } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
- screenClass = Class.forName("com.jogamp.javafx.newt.windows.WindowsScreen");
- } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
- screenClass = Class.forName("com.jogamp.javafx.newt.macosx.MacScreen");
- } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
- screenClass = Class.forName("com.jogamp.javafx.newt.x11.X11Screen");
- } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
- screenClass = Class.forName("com.jogamp.javafx.newt.awt.AWTScreen");
- } else {
- throw new RuntimeException("Unknown window type \"" + type + "\"");
- }
- }
- return screenClass;
- }
-
- protected static Screen create(String type, Display display, int idx) {
- try {
- if(usrWidth<0 || usrHeight<0) {
- usrWidth = Debug.getIntProperty("newt.ws.swidth", true, localACC);
- usrHeight = Debug.getIntProperty("newt.ws.sheight", true, localACC);
- System.out.println("User screen size "+usrWidth+"x"+usrHeight);
- }
- Class screenClass = getScreenClass(type);
- Screen screen = (Screen) screenClass.newInstance();
- screen.display = display;
- screen.createNative(idx);
- if(null==screen.aScreen) {
- throw new RuntimeException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen");
- }
- return screen;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public synchronized void destroy() {
- closeNative();
- display = null;
- aScreen = null;
- }
-
- protected static Screen wrapHandle(String type, Display display, AbstractGraphicsScreen aScreen) {
- try {
- Class screenClass = getScreenClass(type);
- Screen screen = (Screen) screenClass.newInstance();
- screen.display = display;
- screen.aScreen = aScreen;
- return screen;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- protected abstract void createNative(int index);
- protected abstract void closeNative();
-
- protected void setScreenSize(int w, int h) {
- System.out.println("Detected screen size "+w+"x"+h);
- width=w; height=h;
- }
-
- public Display getDisplay() {
- return display;
- }
-
- public int getIndex() {
- return aScreen.getIndex();
- }
-
- public AbstractGraphicsScreen getGraphicsScreen() {
- return aScreen;
- }
-
- /**
- * The actual implementation shall return the detected display value,
- * if not we return 800.
- * This can be overwritten with the user property 'newt.ws.swidth',
- */
- public int getWidth() {
- return (usrWidth>0) ? usrWidth : (width>0) ? width : 480;
- }
-
- /**
- * The actual implementation shall return the detected display value,
- * if not we return 480.
- * This can be overwritten with the user property 'newt.ws.sheight',
- */
- public int getHeight() {
- return (usrHeight>0) ? usrHeight : (height>0) ? height : 480;
- }
-
- protected Display display;
- protected AbstractGraphicsScreen aScreen;
- protected int width=-1, height=-1; // detected values: set using setScreenSize
- protected static int usrWidth=-1, usrHeight=-1; // property values: newt.ws.swidth and newt.ws.sheight
- private static AccessControlContext localACC = AccessController.getContext();
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/Window.java b/src/newt/classes/com/jogamp/javafx/newt/Window.java
deleted file mode 100755
index 2d9341e13..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/Window.java
+++ /dev/null
@@ -1,929 +0,0 @@
-/*
- * 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.jogamp.javafx.newt;
-
-import com.jogamp.javafx.newt.impl.Debug;
-import com.jogamp.javafx.newt.util.EventDispatchThread;
-
-import javax.media.nativewindow.*;
-import com.jogamp.nativewindow.impl.NWReflection;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.lang.reflect.Method;
-
-public abstract class Window implements NativeWindow
-{
- public static final boolean DEBUG_MOUSE_EVENT = Debug.debug("Window.MouseEvent");
- public static final boolean DEBUG_KEY_EVENT = Debug.debug("Window.KeyEvent");
- public static final boolean DEBUG_WINDOW_EVENT = Debug.debug("Window.WindowEvent");
- public static final boolean DEBUG_IMPLEMENTATION = Debug.debug("Window");
-
- // Workaround for initialization order problems on Mac OS X
- // between native Newt and (apparently) Fmod -- if Fmod is
- // initialized first then the connection to the window server
- // breaks, leading to errors from deep within the AppKit
- static void init(String type) {
- if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
- try {
- getWindowClass(type);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- private static Class getWindowClass(String type)
- throws ClassNotFoundException
- {
- Class windowClass = NewtFactory.getCustomClass(type, "Window");
- if(null==windowClass) {
- if (NativeWindowFactory.TYPE_EGL.equals(type)) {
- windowClass = Class.forName("com.jogamp.javafx.newt.opengl.kd.KDWindow");
- } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
- windowClass = Class.forName("com.jogamp.javafx.newt.windows.WindowsWindow");
- } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
- windowClass = Class.forName("com.jogamp.javafx.newt.macosx.MacWindow");
- } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
- windowClass = Class.forName("com.jogamp.javafx.newt.x11.X11Window");
- } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
- windowClass = Class.forName("com.jogamp.javafx.newt.awt.AWTWindow");
- } else {
- throw new NativeWindowException("Unknown window type \"" + type + "\"");
- }
- }
- return windowClass;
- }
-
- protected static Window create(String type, final long parentWindowHandle, Screen screen, final Capabilities caps, boolean undecorated) {
- try {
- Class windowClass;
- if(caps.isOnscreen()) {
- windowClass = getWindowClass(type);
- } else {
- windowClass = OffscreenWindow.class;
- }
- Window window = (Window) windowClass.newInstance();
- window.invalidate();
- window.screen = screen;
- window.setUndecorated(undecorated||0!=parentWindowHandle);
- EventDispatchThread edt = screen.getDisplay().getEDT();
- if(null!=edt) {
- final Window f_win = window;
- edt.invokeAndWait(new Runnable() {
- public void run() {
- f_win.createNative(parentWindowHandle, caps);
- }
- } );
- } else {
- window.createNative(parentWindowHandle, caps);
- }
- return window;
- } catch (Throwable t) {
- t.printStackTrace();
- throw new NativeWindowException(t);
- }
- }
-
- protected static Window create(String type, Object[] cstrArguments, Screen screen, final Capabilities caps, boolean undecorated) {
- try {
- Class windowClass = getWindowClass(type);
- Class[] cstrArgumentTypes = getCustomConstructorArgumentTypes(windowClass);
- if(null==cstrArgumentTypes) {
- throw new NativeWindowException("WindowClass "+windowClass+" doesn't support custom arguments in constructor");
- }
- int argsChecked = verifyConstructorArgumentTypes(cstrArgumentTypes, cstrArguments);
- if ( argsChecked < cstrArguments.length ) {
- throw new NativeWindowException("WindowClass "+windowClass+" constructor mismatch at argument #"+argsChecked+"; Constructor: "+getTypeStrList(cstrArgumentTypes)+", arguments: "+getArgsStrList(cstrArguments));
- }
- Window window = (Window) NWReflection.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ;
- window.invalidate();
- window.screen = screen;
- window.setUndecorated(undecorated);
- EventDispatchThread edt = screen.getDisplay().getEDT();
- if(null!=edt) {
- final Window f_win = window;
- edt.invokeAndWait(new Runnable() {
- public void run() {
- f_win.createNative(0, caps);
- }
- } );
- } else {
- window.createNative(0, caps);
- }
- return window;
- } catch (Throwable t) {
- t.printStackTrace();
- throw new NativeWindowException(t);
- }
- }
-
- protected static Window wrapHandle(String type, Screen screen, AbstractGraphicsConfiguration config,
- long windowHandle, boolean fullscreen, boolean visible,
- int x, int y, int width, int height)
- {
- try {
- Class windowClass = getWindowClass(type);
- Window window = (Window) windowClass.newInstance();
- window.invalidate();
- window.screen = screen;
- window.config = config;
- window.windowHandle = windowHandle;
- window.fullscreen=fullscreen;
- window.visible=visible;
- window.x=x;
- window.y=y;
- window.width=width;
- window.height=height;
- return window;
- } catch (Throwable t) {
- t.printStackTrace();
- throw new NativeWindowException(t);
- }
- }
-
- public static String toHexString(int hex) {
- return "0x" + Integer.toHexString(hex);
- }
-
- public static String toHexString(long hex) {
- return "0x" + Long.toHexString(hex);
- }
-
- protected Screen screen;
-
- protected AbstractGraphicsConfiguration config;
- protected long windowHandle;
- protected boolean fullscreen, visible;
- protected int width, height, x, y;
- protected int eventMask;
-
- protected String title = "Newt Window";
- protected boolean undecorated = false;
-
- /**
- * Create native windowHandle, ie creates a new native invisible window.
- *
- * The parentWindowHandle may be null, in which case no window parenting
- * is requested.
- *
- * Shall use the capabilities to determine the graphics configuration
- * and shall set the chosen capabilities.
- */
- protected abstract void createNative(long parentWindowHandle, Capabilities caps);
-
- protected abstract void closeNative();
-
- public Screen getScreen() {
- return screen;
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
-
- sb.append(getClass().getName()+"[config "+config+
- ", windowHandle "+toHexString(getWindowHandle())+
- ", surfaceHandle "+toHexString(getSurfaceHandle())+
- ", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
- ", visible "+isVisible()+
- ", undecorated "+undecorated+
- ", fullscreen "+fullscreen+
- ", "+screen+
- ", wrappedWindow "+getWrappedWindow());
-
- sb.append(", SurfaceUpdatedListeners num "+surfaceUpdatedListeners.size()+" [");
- for (Iterator iter = surfaceUpdatedListeners.iterator(); iter.hasNext(); ) {
- sb.append(iter.next()+", ");
- }
- sb.append("], WindowListeners num "+windowListeners.size()+" [");
- for (Iterator iter = windowListeners.iterator(); iter.hasNext(); ) {
- sb.append(iter.next()+", ");
- }
- sb.append("], MouseListeners num "+mouseListeners.size()+" [");
- for (Iterator iter = mouseListeners.iterator(); iter.hasNext(); ) {
- sb.append(iter.next()+", ");
- }
- sb.append("], KeyListeners num "+keyListeners.size()+" [");
- for (Iterator iter = keyListeners.iterator(); iter.hasNext(); ) {
- sb.append(iter.next()+", ");
- }
- sb.append("] ]");
- return sb.toString();
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public void setUndecorated(boolean value) {
- undecorated = value;
- }
-
- public boolean isUndecorated() {
- return undecorated;
- }
-
- public void requestFocus() {
- }
-
- //
- // NativeWindow impl
- //
- private Thread owner;
- private int recursionCount;
- protected Exception lockedStack = null;
-
- /** Recursive and blocking lockSurface() implementation */
- public synchronized int lockSurface() {
- // We leave the ToolkitLock lock to the specializtion's discretion,
- // ie the implicit JAWTWindow in case of AWTWindow
- Thread cur = Thread.currentThread();
- if (owner == cur) {
- ++recursionCount;
- return LOCK_SUCCESS;
- }
- while (owner != null) {
- try {
- wait();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- owner = cur;
- lockedStack = new Exception("NEWT Surface previously locked by "+Thread.currentThread());
- screen.getDisplay().lockDisplay();
- return LOCK_SUCCESS;
- }
-
- /** Recursive and unblocking unlockSurface() implementation */
- public synchronized void unlockSurface() throws NativeWindowException {
- Thread cur = Thread.currentThread();
- if (owner != cur) {
- lockedStack.printStackTrace();
- throw new NativeWindowException(cur+": Not owner, owner is "+owner);
- }
- if (recursionCount > 0) {
- --recursionCount;
- return;
- }
- owner = null;
- lockedStack = null;
- screen.getDisplay().unlockDisplay();
- notifyAll();
- // We leave the ToolkitLock unlock to the specializtion's discretion,
- // ie the implicit JAWTWindow in case of AWTWindow
- }
-
- public synchronized boolean isSurfaceLocked() {
- return null!=owner;
- }
-
- public synchronized Thread getSurfaceLockOwner() {
- return owner;
- }
-
- public synchronized Exception getLockedStack() {
- return lockedStack;
- }
-
- public synchronized void destroy() {
- destroy(false);
- }
-
- /** @param deep If true, the linked Screen and Display will be destroyed as well. */
- public synchronized void destroy(boolean deep) {
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.destroy() start (deep "+deep+" - "+Thread.currentThread());
- }
- synchronized(surfaceUpdatedListeners) {
- surfaceUpdatedListeners = new ArrayList();
- }
- synchronized(windowListeners) {
- windowListeners = new ArrayList();
- }
- synchronized(mouseListeners) {
- mouseListeners = new ArrayList();
- }
- synchronized(keyListeners) {
- keyListeners = new ArrayList();
- }
- Screen scr = screen;
- Display dpy = (null!=screen) ? screen.getDisplay() : null;
- EventDispatchThread edt = (null!=dpy) ? dpy.getEDT() : null;
- if(null!=edt) {
- final Window f_win = this;
- edt.invokeAndWait(new Runnable() {
- public void run() {
- f_win.closeNative();
- }
- } );
- } else {
- closeNative();
- }
- invalidate();
- if(deep) {
- if(null!=scr) {
- scr.destroy();
- }
- if(null!=dpy) {
- dpy.destroy();
- }
- }
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.destroy() end "+Thread.currentThread());
- }
- }
-
- public void invalidate() {
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- Exception e = new Exception("!!! Window Invalidate "+Thread.currentThread());
- e.printStackTrace();
- }
- screen = null;
- windowHandle = 0;
- fullscreen=false;
- visible=false;
- eventMask = 0;
-
- // Default position and dimension will be re-set immediately by user
- width = 100;
- height = 100;
- x=0;
- y=0;
- }
-
- public boolean surfaceSwap() {
- return false;
- }
-
- protected void clearEventMask() {
- eventMask=0;
- }
-
- public long getDisplayHandle() {
- return screen.getDisplay().getHandle();
- }
-
- public int getScreenIndex() {
- return screen.getIndex();
- }
-
- public long getWindowHandle() {
- return windowHandle;
- }
-
- public long getSurfaceHandle() {
- return windowHandle; // default: return window handle
- }
-
- public AbstractGraphicsConfiguration getGraphicsConfiguration() {
- return config;
- }
-
- /**
- * Returns the width of the client area of this window
- * @return width of the client area
- */
- public int getWidth() {
- return width;
- }
-
- /**
- * Returns the height of the client area of this window
- * @return height of the client area
- */
- public int getHeight() {
- return height;
- }
-
- /**
- * Returns the insets for this native window (the difference between the
- * size of the toplevel window with the decorations and the client area).
- *
- * @return insets for this platform window
- */
- // this probably belongs to NativeWindow interface
- public Insets getInsets() {
- return new Insets(0,0,0,0);
- }
-
- /** If this Window actually wraps one from another toolkit such as
- the AWT, this will return a non-null value. */
- public Object getWrappedWindow() {
- return null;
- }
-
- //
- // Additional methods
- //
-
- public int getX() {
- return x;
- }
-
- public int getY() {
- return y;
- }
-
- public boolean isVisible() {
- return visible;
- }
-
- public boolean isFullscreen() {
- return fullscreen;
- }
-
- private boolean autoDrawableMember = false;
-
- /** If the implementation is capable of detecting a device change
- return true and clear the status/reason of the change. */
- public boolean hasDeviceChanged() {
- return false;
- }
-
- /**
- * If set to true,
- * certain action will be performed by the owning
- * AutoDrawable, ie the destroy() call within windowDestroyNotify()
- */
- public void setAutoDrawableClient(boolean b) {
- autoDrawableMember = b;
- }
-
- protected void windowDestroyNotify() {
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.windowDestroyeNotify start "+Thread.currentThread());
- }
-
- sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY);
-
- if(!autoDrawableMember) {
- destroy();
- }
-
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.windowDestroyeNotify end "+Thread.currentThread());
- }
- }
-
- protected void windowDestroyed() {
- if(DEBUG_WINDOW_EVENT) {
- System.out.println("Window.windowDestroyed "+Thread.currentThread());
- }
- invalidate();
- }
-
- public abstract void setVisible(boolean visible);
- /**
- * Sets the size of the client area of the window, excluding decorations
- * Total size of the window will be
- * {@code width+insets.left+insets.right, height+insets.top+insets.bottom}
- * @param width of the client area of the window
- * @param height of the client area of the window
- */
- public abstract void setSize(int width, int height);
- /**
- * Sets the location of the top left corner of the window, including
- * decorations (so the client area will be placed at
- * {@code x+insets.left,y+insets.top}.
- * @param x coord of the top left corner
- * @param y coord of the top left corner
- */
- public abstract void setPosition(int x, int y);
- public abstract boolean setFullscreen(boolean fullscreen);
-
- //
- // SurfaceUpdatedListener Support
- //
- private ArrayList surfaceUpdatedListeners = new ArrayList();
-
- public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- if(l == null) {
- return;
- }
- synchronized(surfaceUpdatedListeners) {
- ArrayList newSurfaceUpdatedListeners = (ArrayList) surfaceUpdatedListeners.clone();
- newSurfaceUpdatedListeners.add(l);
- surfaceUpdatedListeners = newSurfaceUpdatedListeners;
- }
- }
-
- public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- if (l == null) {
- return;
- }
- synchronized(surfaceUpdatedListeners) {
- ArrayList newSurfaceUpdatedListeners = (ArrayList) surfaceUpdatedListeners.clone();
- newSurfaceUpdatedListeners.remove(l);
- surfaceUpdatedListeners = newSurfaceUpdatedListeners;
- }
- }
-
- public SurfaceUpdatedListener[] getSurfaceUpdatedListener() {
- synchronized(surfaceUpdatedListeners) {
- return (SurfaceUpdatedListener[]) surfaceUpdatedListeners.toArray();
- }
- }
-
- public void surfaceUpdated(Object updater, NativeWindow window, long when) {
- ArrayList listeners = null;
- synchronized(surfaceUpdatedListeners) {
- listeners = surfaceUpdatedListeners;
- }
- for(Iterator i = listeners.iterator(); i.hasNext(); ) {
- SurfaceUpdatedListener l = (SurfaceUpdatedListener) i.next();
- l.surfaceUpdated(updater, window, when);
- }
- }
-
- //
- // MouseListener Support
- //
-
- public void addMouseListener(MouseListener l) {
- if(l == null) {
- return;
- }
- synchronized(mouseListeners) {
- ArrayList newMouseListeners = (ArrayList) mouseListeners.clone();
- newMouseListeners.add(l);
- mouseListeners = newMouseListeners;
- }
- }
-
- public void removeMouseListener(MouseListener l) {
- if (l == null) {
- return;
- }
- synchronized(mouseListeners) {
- ArrayList newMouseListeners = (ArrayList) mouseListeners.clone();
- newMouseListeners.remove(l);
- mouseListeners = newMouseListeners;
- }
- }
-
- public MouseListener[] getMouseListeners() {
- synchronized(mouseListeners) {
- return (MouseListener[]) mouseListeners.toArray();
- }
- }
-
- private ArrayList mouseListeners = new ArrayList();
- private int mouseButtonPressed = 0; // current pressed mouse button number
- private long lastMousePressed = 0; // last time when a mouse button was pressed
- private int lastMouseClickCount = 0; // last mouse button click count
- public static final int ClickTimeout = 300;
-
- protected void sendMouseEvent(int eventType, int modifiers,
- int x, int y, int button, int rotation) {
- if(x<0||y<0||x>=width||y>=height) {
- return; // .. invalid ..
- }
- if(DEBUG_MOUSE_EVENT) {
- System.out.println("sendMouseEvent: "+MouseEvent.getEventTypeString(eventType)+
- ", mod "+modifiers+", pos "+x+"/"+y+", button "+button);
- }
- if(button<0||button>MouseEvent.BUTTON_NUMBER) {
- throw new NativeWindowException("Invalid mouse button number" + button);
- }
- long when = System.currentTimeMillis();
- MouseEvent eClicked = null;
- MouseEvent e = null;
-
- if(MouseEvent.EVENT_MOUSE_PRESSED==eventType) {
- if(when-lastMousePressed
- * before calling the various input EventListener callbacks (MouseListener, KeyListener,
- * etc.).
- * This design decision is made to favor a more performant and simplified
- * implementation, as well as the event dispatcher shall be allowed
- * not having a notion about OpenGL.
- *
- * Enable or disables running the {@link Display#pumpMessages} in the {@link #display()} call.
- * The default behavior is to run {@link Display#pumpMessages}.
- * This could not have been verified. No measurable difference could have been recognized.
- *
- * Enabling local pump messages while using the EDT,
- * {@link com.jogamp.javafx.newt.NewtFactory#setUseEDT(boolean)},
- * will result in an exception.
- *
- * @deprecated EXPERIMENTAL, semantic is about to be removed after further verification.
- */
- public void setRunPumpMessages(boolean onoff) {
- if( onoff && null!=getScreen().getDisplay().getEDT() ) {
- throw new GLException("GLWindow.setRunPumpMessages(true) - Can't do with EDT on");
- }
- runPumpMessages = onoff;
- }
-
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- shouldNotCallThis();
- }
-
- protected void closeNative() {
- shouldNotCallThis();
- }
-
- protected void dispose(boolean regenerate, boolean sendEvent) {
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- Exception e1 = new Exception("GLWindow.dispose("+regenerate+") "+Thread.currentThread()+", 1");
- e1.printStackTrace();
- }
-
- if(sendEvent) {
- sendDisposeEvent();
- }
-
- if (context != null) {
- context.destroy();
- }
- if (drawable != null) {
- drawable.setRealized(false);
- }
-
- if(regenerate) {
- if(null==window) {
- throw new GLException("GLWindow.dispose(true): null window");
- }
-
- // recreate GLDrawable, to reflect the new graphics configurations
- NativeWindow nw;
- if (window.getWrappedWindow() != null) {
- nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
- } else {
- nw = window;
- }
- drawable = factory.createGLDrawable(nw);
- drawable.setRealized(true);
- context = drawable.createContext(null);
- sendReshape = true; // ensure a reshape event is send ..
- }
-
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println("GLWindow.dispose("+regenerate+") "+Thread.currentThread()+", fin: "+this);
- }
- }
-
- public synchronized void destroy() {
- destroy(true);
- }
-
- /** @param sendDisposeEvent should be false in a [time,reliable] critical shutdown */
- public synchronized void destroy(boolean sendDisposeEvent) {
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- Exception e1 = new Exception("GLWindow.destroy "+Thread.currentThread()+", 1: "+this);
- e1.printStackTrace();
- }
-
- List newglw = (List) ((ArrayList) glwindows).clone();
- newglw.remove(this);
- glwindows=newglw;
-
- dispose(false, sendDisposeEvent);
-
- if(null!=window) {
- if(ownerOfWinScrDpy) {
- window.destroy(true);
- }
- }
-
- drawable = null;
- context = null;
- window = null;
-
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println("GLWindow.destroy "+Thread.currentThread()+", fin: "+this);
- }
- }
-
- public boolean getPerfLogEnabled() { return perfLog; }
-
- public void enablePerfLog(boolean v) {
- perfLog = v;
- }
-
- public void setVisible(boolean visible) {
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread()+" GLWindow.setVisible("+visible+") START ; isVisible "+this.visible+" ; has context "+(null!=context));
- }
- this.visible=visible;
- window.setVisible(visible);
- if (visible && context == null) {
- NativeWindow nw;
- if (window.getWrappedWindow() != null) {
- nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
- } else {
- nw = window;
- }
- GLCapabilities glCaps = (GLCapabilities) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
- factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
- drawable = factory.createGLDrawable(nw);
- drawable.setRealized(true);
- context = drawable.createContext(null);
- sendReshape = true; // ensure a reshape event is send ..
- }
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println(Thread.currentThread()+" GLWindow.setVisible("+visible+") END ; has context "+(null!=context));
- }
- }
-
- public Screen getScreen() {
- return window.getScreen();
- }
-
- public void setTitle(String title) {
- window.setTitle(title);
- }
-
- public String getTitle() {
- return window.getTitle();
- }
-
- public void setUndecorated(boolean value) {
- window.setUndecorated(value);
- }
-
- public boolean isUndecorated() {
- return window.isUndecorated();
- }
-
- public void setSize(int width, int height) {
- window.setSize(width, height);
- }
-
- public void setPosition(int x, int y) {
- window.setPosition(x, y);
- }
-
- public Insets getInsets() {
- return window.getInsets();
- }
-
- public boolean setFullscreen(boolean fullscreen) {
- return window.setFullscreen(fullscreen);
- }
-
- public boolean isVisible() {
- return window.isVisible();
- }
-
- public int getX() {
- return window.getX();
- }
-
- public int getY() {
- return window.getY();
- }
-
- public int getWidth() {
- return window.getWidth();
- }
-
- public int getHeight() {
- return window.getHeight();
- }
-
- public boolean isFullscreen() {
- return window.isFullscreen();
- }
-
- public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- window.addSurfaceUpdatedListener(l);
- }
- public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
- window.removeSurfaceUpdatedListener(l);
- }
- public SurfaceUpdatedListener[] getSurfaceUpdatedListener() {
- return window.getSurfaceUpdatedListener();
- }
- public void surfaceUpdated(Object updater, NativeWindow window0, long when) {
- window.surfaceUpdated(updater, window, when);
- }
-
- public void addMouseListener(MouseListener l) {
- window.addMouseListener(l);
- }
-
- public void removeMouseListener(MouseListener l) {
- window.removeMouseListener(l);
- }
-
- public MouseListener[] getMouseListeners() {
- return window.getMouseListeners();
- }
-
- public void addKeyListener(KeyListener l) {
- window.addKeyListener(l);
- }
-
- public void removeKeyListener(KeyListener l) {
- window.removeKeyListener(l);
- }
-
- public KeyListener[] getKeyListeners() {
- return window.getKeyListeners();
- }
-
- public void addWindowListener(WindowListener l) {
- window.addWindowListener(l);
- }
-
- public void removeWindowListener(WindowListener l) {
- window.removeWindowListener(l);
- }
-
- public WindowListener[] getWindowListeners() {
- return window.getWindowListeners();
- }
-
- public String toString() {
- return "NEWT-GLWindow[ \n\tDrawable: "+drawable+", \n\tWindow: "+window+", \n\tHelper: "+helper+", \n\tFactory: "+factory+"]";
- }
-
- //----------------------------------------------------------------------
- // OpenGL-related methods and state
- //
-
- private GLDrawableFactory factory;
- private GLDrawable drawable;
- private GLContext context;
- private GLDrawableHelper helper = new GLDrawableHelper();
- // To make reshape events be sent immediately before a display event
- private boolean sendReshape=false;
- private boolean sendDestroy=false;
- private boolean perfLog = false;
-
- public GLDrawableFactory getFactory() {
- return factory;
- }
-
- public void setContext(GLContext newCtx) {
- context = newCtx;
- }
-
- public GLContext getContext() {
- return context;
- }
-
- public GL getGL() {
- if (context == null) {
- return null;
- }
- return context.getGL();
- }
-
- public GL setGL(GL gl) {
- if (context != null) {
- context.setGL(gl);
- return gl;
- }
- return null;
- }
-
- public void addGLEventListener(GLEventListener listener) {
- helper.addGLEventListener(listener);
- }
-
- public void removeGLEventListener(GLEventListener listener) {
- helper.removeGLEventListener(listener);
- }
-
- public void display() {
- display(false);
- }
-
- public void display(boolean forceReshape) {
- if(window!=null && drawable!=null && context != null) {
- if(runPumpMessages) {
- window.getScreen().getDisplay().pumpMessages();
- }
- if(window.hasDeviceChanged() && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED) {
- dispose(true, true);
- }
- if (sendDestroy) {
- destroy();
- sendDestroy=false;
- } else {
- if(forceReshape) {
- sendReshape = true;
- }
- helper.invokeGL(drawable, context, displayAction, initAction);
- }
- }
- }
-
- private void sendDisposeEvent() {
- if(drawable!=null && context != null) {
- helper.invokeGL(drawable, context, disposeAction, null);
- }
- }
-
- /** This implementation uses a static value */
- public void setAutoSwapBufferMode(boolean onOrOff) {
- helper.setAutoSwapBufferMode(onOrOff);
- }
-
- /** This implementation uses a static value */
- public boolean getAutoSwapBufferMode() {
- return helper.getAutoSwapBufferMode();
- }
-
- public void swapBuffers() {
- if(drawable!=null && context != null) {
- if (context != GLContext.getCurrent()) {
- // Assume we should try to make the context current before swapping the buffers
- helper.invokeGL(drawable, context, swapBuffersAction, initAction);
- } else {
- drawable.swapBuffers();
- }
- }
- }
-
- class InitAction implements Runnable {
- public void run() {
- helper.init(GLWindow.this);
- startTime = System.currentTimeMillis();
- curTime = startTime;
- if(perfLog) {
- lastCheck = startTime;
- totalFrames = 0; lastFrames = 0;
- }
- }
- }
- private InitAction initAction = new InitAction();
-
- class DisposeAction implements Runnable {
- public void run() {
- helper.dispose(GLWindow.this);
- }
- }
- private DisposeAction disposeAction = new DisposeAction();
-
- class DisplayAction implements Runnable {
- public void run() {
- if (sendReshape) {
- int width = getWidth();
- int height = getHeight();
- getGL().glViewport(0, 0, width, height);
- helper.reshape(GLWindow.this, 0, 0, width, height);
- sendReshape = false;
- }
-
- helper.display(GLWindow.this);
-
- curTime = System.currentTimeMillis();
- totalFrames++;
-
- if(perfLog) {
- long dt0, dt1;
- lastFrames++;
- dt0 = curTime-lastCheck;
- if ( dt0 > 5000 ) {
- dt1 = curTime-startTime;
- System.out.println(dt0/1000 +"s: "+ lastFrames + "f, " + (lastFrames*1000)/dt0 + " fps, "+dt0/lastFrames+" ms/f; "+
- "total: "+ dt1/1000+"s, "+(totalFrames*1000)/dt1 + " fps, "+dt1/totalFrames+" ms/f");
- lastCheck=curTime;
- lastFrames=0;
- }
- }
- }
- }
- private DisplayAction displayAction = new DisplayAction();
-
- public long getStartTime() { return startTime; }
- public long getCurrentTime() { return curTime; }
- public long getDuration() { return curTime-startTime; }
- public int getTotalFrames() { return totalFrames; }
-
- private long startTime = 0;
- private long curTime = 0;
- private long lastCheck = 0;
- private int totalFrames = 0, lastFrames = 0;
-
- class SwapBuffersAction implements Runnable {
- public void run() {
- drawable.swapBuffers();
- }
- }
- private SwapBuffersAction swapBuffersAction = new SwapBuffersAction();
-
- //----------------------------------------------------------------------
- // GLDrawable methods
- //
-
- public NativeWindow getNativeWindow() {
- return null!=drawable ? drawable.getNativeWindow() : null;
- }
-
- public synchronized int lockSurface() throws NativeWindowException {
- if(null!=drawable) return drawable.getNativeWindow().lockSurface();
- return NativeWindow.LOCK_SURFACE_NOT_READY;
- }
-
- public synchronized void unlockSurface() {
- if(null!=drawable) drawable.getNativeWindow().unlockSurface();
- else throw new NativeWindowException("NEWT-GLWindow not locked");
- }
-
- public synchronized boolean isSurfaceLocked() {
- if(null!=drawable) return drawable.getNativeWindow().isSurfaceLocked();
- return false;
- }
-
- public synchronized Exception getLockedStack() {
- if(null!=drawable) return drawable.getNativeWindow().getLockedStack();
- return null;
- }
-
- public boolean surfaceSwap() {
- if(null!=drawable) return drawable.getNativeWindow().surfaceSwap();
- return super.surfaceSwap();
- }
-
- public long getWindowHandle() {
- if(null!=drawable) return drawable.getNativeWindow().getWindowHandle();
- return super.getWindowHandle();
- }
-
- public long getSurfaceHandle() {
- if(null!=drawable) return drawable.getNativeWindow().getSurfaceHandle();
- return super.getSurfaceHandle();
- }
-
- //----------------------------------------------------------------------
- // GLDrawable methods that are not really needed
- //
-
- public GLContext createContext(GLContext shareWith) {
- return drawable.createContext(shareWith);
- }
-
- public void setRealized(boolean realized) {
- }
-
- public GLCapabilities getChosenGLCapabilities() {
- if (drawable == null) {
- throw new GLException("No drawable yet");
- }
-
- return drawable.getChosenGLCapabilities();
- }
-
- public GLProfile getGLProfile() {
- if (drawable == null) {
- throw new GLException("No drawable yet");
- }
-
- return drawable.getGLProfile();
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- private void shouldNotCallThis() {
- throw new NativeWindowException("Should not call this");
- }
-}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Display.java b/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Display.java
deleted file mode 100644
index c0c1ee5fd..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Display.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.jogamp.javafx.newt.opengl.broadcom.egl;
-
-import com.jogamp.javafx.newt.impl.*;
-import com.jogamp.opengl.impl.egl.*;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.egl.*;
-
-public class Display extends com.jogamp.javafx.newt.Display {
-
- static {
- NativeLibLoader.loadNEWT();
-
- if (!Window.initIDs()) {
- throw new NativeWindowException("Failed to initialize BCEGL Window jmethodIDs");
- }
- }
-
- public static void initSingleton() {
- // just exist to ensure static init has been run
- }
-
-
- public Display() {
- }
-
- protected void createNative() {
- long handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight);
- if (handle == EGL.EGL_NO_DISPLAY) {
- throw new NativeWindowException("BC EGL CreateDisplay failed");
- }
- aDevice = new EGLGraphicsDevice(handle);
- }
-
- protected void closeNative() {
- if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) {
- DestroyDisplay(aDevice.getHandle());
- }
- }
-
- protected void dispatchMessages() {
- // n/a .. DispatchMessages();
- }
-
- private native long CreateDisplay(int width, int height);
- private native void DestroyDisplay(long dpy);
- private native void DispatchMessages();
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Screen.java b/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Screen.java
deleted file mode 100755
index f7abe3836..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Screen.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.jogamp.javafx.newt.opengl.broadcom.egl;
-
-import com.jogamp.javafx.newt.impl.*;
-import javax.media.nativewindow.*;
-
-public class Screen extends com.jogamp.javafx.newt.Screen {
-
- static {
- Display.initSingleton();
- }
-
-
- public Screen() {
- }
-
- protected void createNative(int index) {
- aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
- setScreenSize(fixedWidth, fixedHeight);
- }
-
- protected void closeNative() { }
-
- //----------------------------------------------------------------------
- // Internals only
- //
-
- static final int fixedWidth = 1920;
- static final int fixedHeight = 1080;
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Window.java b/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Window.java
deleted file mode 100755
index bd2d7930e..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/opengl/broadcom/egl/Window.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * 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.jogamp.javafx.newt.opengl.broadcom.egl;
-
-import com.jogamp.javafx.newt.impl.*;
-import com.jogamp.opengl.impl.egl.*;
-import javax.media.nativewindow.*;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-import javax.media.nativewindow.NativeWindowException;
-
-public class Window extends com.jogamp.javafx.newt.Window {
- static {
- Display.initSingleton();
- }
-
- public Window() {
- }
-
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- if(0!=parentWindowHandle) {
- throw new RuntimeException("Window parenting not supported (yet)");
- }
- // query a good configuration .. even thought we drop this one
- // and reuse the EGLUtil choosen one later.
- config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
- if (config == null) {
- throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
- }
- setSizeImpl(getScreen().getWidth(), getScreen().getHeight());
- }
-
- protected void closeNative() {
- if(0!=windowHandleClose) {
- CloseWindow(getDisplayHandle(), windowHandleClose);
- }
- }
-
- public void setVisible(boolean visible) {
- if(this.visible!=visible) {
- this.visible=visible;
- if ( 0==windowHandle ) {
- windowHandle = realizeWindow(true, width, height);
- if (0 == windowHandle) {
- throw new NativeWindowException("Error native Window Handle is null");
- }
- }
- clearEventMask();
- }
- }
-
- public void setSize(int width, int height) {
- System.err.println("setSize "+width+"x"+height+" n/a in BroadcomEGL");
- }
-
- void setSizeImpl(int width, int height) {
- if(0!=windowHandle) {
- // n/a in BroadcomEGL
- System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window");
- } else {
- if(DEBUG_IMPLEMENTATION) {
- Exception e = new Exception("BCEGL Window.setSizeImpl() "+this.width+"x"+this.height+" -> "+width+"x"+height);
- e.printStackTrace();
- }
- this.width = width;
- this.height = height;
- }
- }
-
- public void setPosition(int x, int y) {
- // n/a in BroadcomEGL
- System.err.println("setPosition n/a in BroadcomEGL");
- }
-
- public boolean setFullscreen(boolean fullscreen) {
- // n/a in BroadcomEGL
- System.err.println("setFullscreen n/a in BroadcomEGL");
- return false;
- }
-
- public boolean surfaceSwap() {
- if ( 0!=windowHandle ) {
- SwapWindow(getDisplayHandle(), windowHandle);
- return true;
- }
- return false;
- }
-
- //----------------------------------------------------------------------
- // Internals only
- //
-
- protected static native boolean initIDs();
- private native long CreateWindow(long eglDisplayHandle, boolean chromaKey, int width, int height);
- private native void CloseWindow(long eglDisplayHandle, long eglWindowHandle);
- private native void SwapWindow(long eglDisplayHandle, long eglWindowHandle);
-
-
- private long realizeWindow(boolean chromaKey, int width, int height) {
- if(DEBUG_IMPLEMENTATION) {
- System.out.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+config);
- }
- long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height);
- if (0 == handle) {
- throw new NativeWindowException("Error native Window Handle is null");
- }
- windowHandleClose = handle;
- return handle;
- }
-
- private void windowCreated(int cfgID, int width, int height) {
- this.width = width;
- this.height = height;
- GLCapabilities capsReq = (GLCapabilities) config.getRequestedCapabilities();
- config = EGLGraphicsConfiguration.create(capsReq, screen.getGraphicsScreen(), cfgID);
- if (config == null) {
- throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this);
- }
- if(DEBUG_IMPLEMENTATION) {
- System.out.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+config);
- }
- }
-
- private long windowHandleClose;
-}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDDisplay.java b/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDDisplay.java
deleted file mode 100755
index 40a37115d..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDDisplay.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.jogamp.javafx.newt.opengl.kd;
-
-import com.jogamp.javafx.newt.*;
-import com.jogamp.javafx.newt.impl.*;
-import com.jogamp.opengl.impl.egl.*;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.egl.*;
-
-public class KDDisplay extends Display {
-
- static {
- NativeLibLoader.loadNEWT();
-
- if (!KDWindow.initIDs()) {
- throw new NativeWindowException("Failed to initialize KDWindow jmethodIDs");
- }
- }
-
- public static void initSingleton() {
- // just exist to ensure static init has been run
- }
-
-
- public KDDisplay() {
- }
-
- protected void createNative() {
- // FIXME: map name to EGL_*_DISPLAY
- long handle = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
- if (handle == EGL.EGL_NO_DISPLAY) {
- throw new NativeWindowException("eglGetDisplay failed");
- }
- if (!EGL.eglInitialize(handle, null, null)) {
- throw new NativeWindowException("eglInitialize failed");
- }
- aDevice = new EGLGraphicsDevice(handle);
- }
-
- protected void closeNative() {
- if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) {
- EGL.eglTerminate(aDevice.getHandle());
- }
- }
-
- protected void dispatchMessages() {
- DispatchMessages();
- }
-
- private native void DispatchMessages();
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDScreen.java b/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDScreen.java
deleted file mode 100755
index 4bc7f8257..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDScreen.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.jogamp.javafx.newt.opengl.kd;
-
-import com.jogamp.javafx.newt.*;
-import javax.media.nativewindow.*;
-
-public class KDScreen extends Screen {
- static {
- KDDisplay.initSingleton();
- }
-
- public KDScreen() {
- }
-
- protected void createNative(int index) {
- aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
- }
-
- protected void closeNative() { }
-
- // elevate access to this package ..
- protected void setScreenSize(int w, int h) {
- super.setScreenSize(w, h);
- }
-}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDWindow.java b/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDWindow.java
deleted file mode 100755
index d5be2207c..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/opengl/kd/KDWindow.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.jogamp.javafx.newt.opengl.kd;
-
-import com.jogamp.javafx.newt.*;
-import com.jogamp.javafx.newt.impl.*;
-import com.jogamp.opengl.impl.egl.*;
-import javax.media.nativewindow.*;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
-import javax.media.nativewindow.NativeWindowException;
-
-public class KDWindow extends Window {
- private static final String WINDOW_CLASS_NAME = "NewtWindow";
- // non fullscreen dimensions ..
- private int nfs_width, nfs_height, nfs_x, nfs_y;
-
- static {
- KDDisplay.initSingleton();
- }
-
- public KDWindow() {
- }
-
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- if(0!=parentWindowHandle) {
- throw new RuntimeException("Window parenting not supported (yet)");
- }
- config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
- if (config == null) {
- throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
- }
-
- GLCapabilities eglCaps = (GLCapabilities)config.getChosenCapabilities();
- int[] eglAttribs = EGLGraphicsConfiguration.GLCapabilities2AttribList(eglCaps);
-
- windowHandle = 0;
- eglWindowHandle = CreateWindow(getDisplayHandle(), eglAttribs);
- if (eglWindowHandle == 0) {
- throw new NativeWindowException("Error creating egl window: "+config);
- }
- setVisible0(eglWindowHandle, false);
- windowHandleClose = eglWindowHandle;
- }
-
- protected void closeNative() {
- if(0!=windowHandleClose) {
- CloseWindow(windowHandleClose, windowUserData);
- windowUserData=0;
- }
- }
-
- public void setVisible(boolean visible) {
- if(0!=eglWindowHandle && this.visible!=visible) {
- this.visible=visible;
- setVisible0(eglWindowHandle, visible);
- if ( 0==windowHandle ) {
- windowHandle = RealizeWindow(eglWindowHandle);
- if (0 == windowHandle) {
- throw new NativeWindowException("Error native Window Handle is null");
- }
- }
- clearEventMask();
- }
- }
-
- public void setSize(int width, int height) {
- if(0!=eglWindowHandle) {
- setSize0(eglWindowHandle, width, height);
- }
- }
-
- public void setPosition(int x, int y) {
- // n/a in KD
- System.err.println("setPosition n/a in KD");
- }
-
- public boolean setFullscreen(boolean fullscreen) {
- if(0!=eglWindowHandle && this.fullscreen!=fullscreen) {
- this.fullscreen=fullscreen;
- if(this.fullscreen) {
- setFullScreen0(eglWindowHandle, true);
- } else {
- setFullScreen0(eglWindowHandle, false);
- setSize0(eglWindowHandle, nfs_width, nfs_height);
- }
- }
- return true;
- }
-
- //----------------------------------------------------------------------
- // Internals only
- //
-
- protected static native boolean initIDs();
- private native long CreateWindow(long displayHandle, int[] attributes);
- private native long RealizeWindow(long eglWindowHandle);
- private native int CloseWindow(long eglWindowHandle, long userData);
- private native void setVisible0(long eglWindowHandle, boolean visible);
- private native void setSize0(long eglWindowHandle, int width, int height);
- private native void setFullScreen0(long eglWindowHandle, boolean fullscreen);
-
- private void windowCreated(long userData) {
- windowUserData=userData;
- }
-
- private void sizeChanged(int newWidth, int newHeight) {
- width = newWidth;
- height = newHeight;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- } else {
- ((KDScreen)screen).setScreenSize(width, height);
- }
- sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
- }
-
- private long eglWindowHandle;
- private long windowHandleClose;
- private long windowUserData;
-}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/util/EventDispatchThread.java b/src/newt/classes/com/jogamp/javafx/newt/util/EventDispatchThread.java
deleted file mode 100644
index db3f97ee6..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/util/EventDispatchThread.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (c) 2009 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.
- */
-
-package com.jogamp.javafx.newt.util;
-
-import com.jogamp.javafx.newt.Display;
-import com.jogamp.javafx.newt.impl.Debug;
-import java.util.*;
-
-public class EventDispatchThread {
- public static final boolean DEBUG = Debug.debug("EDT");
-
- private ThreadGroup threadGroup;
- private volatile boolean shouldStop = false;
- private TaskWorker taskWorker = null;
- private Object taskWorkerLock = new Object();
- private ArrayList tasks = new ArrayList(); // one shot tasks
- private Display display = null;
- private String name;
- private long edtPollGranularity = 10;
-
- public EventDispatchThread(Display display, ThreadGroup tg, String name) {
- this.display = display;
- this.threadGroup = tg;
- this.name=new String("EDT-Display_"+display.getName()+"-"+name);
- }
-
- public String getName() { return name; }
-
- public ThreadGroup getThreadGroup() { return threadGroup; }
-
- public void start() {
- start(false);
- }
-
- /**
- * @param externalStimuli true indicates that another thread stimulates,
- * ie. calls this TaskManager's run() loop method.
- * Hence no own thread is started in this case.
- *
- * @return The started Runnable, which handles the run-loop.
- * Usefull in combination with externalStimuli=true,
- * so an external stimuli can call it.
- */
- public Runnable start(boolean externalStimuli) {
- synchronized(taskWorkerLock) {
- if(null==taskWorker) {
- taskWorker = new TaskWorker(threadGroup, name);
- }
- if(!taskWorker.isRunning()) {
- shouldStop = false;
- taskWorker.start(externalStimuli);
- }
- taskWorkerLock.notifyAll();
- }
- return taskWorker;
- }
-
- public void stop() {
- synchronized(taskWorkerLock) {
- if(null!=taskWorker && taskWorker.isRunning()) {
- shouldStop = true;
- }
- taskWorkerLock.notifyAll();
- if(DEBUG) {
- System.out.println(Thread.currentThread()+": EDT signal STOP");
- }
- }
- }
-
- public boolean isThreadEDT(Thread thread) {
- return null!=taskWorker && taskWorker == thread;
- }
-
- public boolean isCurrentThreadEDT() {
- return null!=taskWorker && taskWorker == Thread.currentThread();
- }
-
- public boolean isRunning() {
- return null!=taskWorker && taskWorker.isRunning() ;
- }
-
- public void invokeLater(Runnable task) {
- if(task == null) {
- return;
- }
- synchronized(taskWorkerLock) {
- if(null!=taskWorker && taskWorker.isRunning() && taskWorker != Thread.currentThread() ) {
- tasks.add(task);
- taskWorkerLock.notifyAll();
- } else {
- // if !running or isEDTThread, do it right away
- task.run();
- }
- }
- }
-
- public void invokeAndWait(Runnable task) {
- if(task == null) {
- return;
- }
- invokeLater(task);
- waitOnWorker();
- }
-
- public void waitOnWorker() {
- synchronized(taskWorkerLock) {
- if(null!=taskWorker && taskWorker.isRunning() && tasks.size()>0 && taskWorker != Thread.currentThread() ) {
- try {
- taskWorkerLock.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- public void waitUntilStopped() {
- synchronized(taskWorkerLock) {
- while(null!=taskWorker && taskWorker.isRunning() && taskWorker != Thread.currentThread() ) {
- try {
- taskWorkerLock.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- class TaskWorker extends Thread {
- boolean isRunning = false;
- boolean externalStimuli = false;
-
- public TaskWorker(ThreadGroup tg, String name) {
- super(tg, name);
- }
-
- public synchronized boolean isRunning() {
- return isRunning;
- }
-
- public void start(boolean externalStimuli) throws IllegalThreadStateException {
- synchronized(this) {
- this.externalStimuli = externalStimuli;
- isRunning = true;
- }
- if(!externalStimuli) {
- super.start();
- }
- }
-
- /**
- * Utilizing taskWorkerLock only for local resources and task execution,
- * not for event dispatching.
- */
- public void run() {
- if(DEBUG) {
- System.out.println(Thread.currentThread()+": EDT run() START");
- }
- while(!shouldStop) {
- try {
- // wait for something todo
- while(!shouldStop && tasks.size()==0) {
- synchronized(taskWorkerLock) {
- if(!shouldStop && tasks.size()==0) {
- try {
- taskWorkerLock.wait(edtPollGranularity);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- display.pumpMessages(); // event dispatch
- }
- if(!shouldStop && tasks.size()>0) {
- synchronized(taskWorkerLock) {
- if(!shouldStop && tasks.size()>0) {
- Runnable task = (Runnable) tasks.remove(0);
- task.run();
- taskWorkerLock.notifyAll();
- }
- }
- display.pumpMessages(); // event dispatch
- }
- } catch (Throwable t) {
- // handle errors ..
- t.printStackTrace();
- } finally {
- // epilog - unlock locked stuff
- }
- if(externalStimuli) break; // no loop if called by external stimuli
- }
- synchronized(this) {
- isRunning = !shouldStop;
- }
- if(!isRunning) {
- synchronized(taskWorkerLock) {
- taskWorkerLock.notifyAll();
- }
- }
- if(DEBUG) {
- System.out.println(Thread.currentThread()+": EDT run() EXIT");
- }
- }
- }
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/util/MainThread.java b/src/newt/classes/com/jogamp/javafx/newt/util/MainThread.java
deleted file mode 100644
index 9bf25098f..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/util/MainThread.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * Copyright (c) 2009 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.
- */
-
-package com.jogamp.javafx.newt.util;
-
-import java.util.*;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-import java.security.*;
-
-import javax.media.nativewindow.*;
-
-import com.jogamp.javafx.newt.*;
-import com.jogamp.javafx.newt.impl.*;
-import com.jogamp.javafx.newt.macosx.MacDisplay;
-import com.jogamp.nativewindow.impl.NWReflection;
-
-/**
- * NEWT Utility class MainThread
- *
- * Such behavior is necessary for native windowing toolkits,
- * where the windowing management must happen on the so called
- * main thread e.g. for Mac OS X !
- *
- * Utilizing this class as a launchpad, now you are able to
- * use a NEWT multithreaded application with window handling within the different threads,
- * even on these restricted platforms.
- *
- * To support your NEWT Window platform,
- * you have to pass your main thread actions to {@link #invoke invoke(..)},
- * have a look at the {@link com.jogamp.javafx.newt.macosx.MacWindow MacWindow} implementation.
- * TODO: Some hardcoded dependencies exist in this implementation,
- * where you have to patch this code or factor it out. newt.MainThread.force
to true
.newt.MainThread.force
to true
.
- java -XstartOnFirstThread com.jogamp.javafx.newt.util.MainThread demos.es1.RedSquare -GL2 -GL2 -GL2 -GL2
-
- * Which starts 4 threads, each with a window and OpenGL rendering.
- */
-public class MainThread {
- private static AccessControlContext localACC = AccessController.getContext();
- public static final boolean USE_MAIN_THREAD = NativeWindowFactory.TYPE_MACOSX.equals(NativeWindowFactory.getNativeWindowType(false)) ||
- Debug.getBooleanProperty("newt.MainThread.force", true, localACC);
-
- protected static final boolean DEBUG = Debug.debug("MainThread");
-
- private static boolean isExit=false;
- private static volatile boolean isRunning=false;
- private static Object taskWorkerLock=new Object();
- private static boolean shouldStop;
- private static ArrayList tasks;
- private static ArrayList tasksBlock;
- private static Thread mainThread;
-
- static class MainAction extends Thread {
- private String mainClassName;
- private String[] mainClassArgs;
-
- private Class mainClass;
- private Method mainClassMain;
-
- public MainAction(String mainClassName, String[] mainClassArgs) {
- this.mainClassName=mainClassName;
- this.mainClassArgs=mainClassArgs;
- }
-
- public void run() {
- if ( USE_MAIN_THREAD ) {
- // we have to start first to provide the service ..
- MainThread.waitUntilRunning();
- }
-
- // start user app ..
- try {
- Class mainClass = NWReflection.getClass(mainClassName, true);
- if(null==mainClass) {
- throw new RuntimeException(new ClassNotFoundException("MainThread couldn't find main class "+mainClassName));
- }
- try {
- mainClassMain = mainClass.getDeclaredMethod("main", new Class[] { String[].class });
- mainClassMain.setAccessible(true);
- } catch (Throwable t) {
- throw new RuntimeException(t);
- }
- if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" invoke "+mainClassName);
- mainClassMain.invoke(null, new Object[] { mainClassArgs } );
- } catch (InvocationTargetException ite) {
- ite.getTargetException().printStackTrace();
- } catch (Throwable t) {
- t.printStackTrace();
- }
-
- if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" user app fin");
-
- if ( USE_MAIN_THREAD ) {
- MainThread.exit();
- if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" MainThread fin - exit");
- System.exit(0);
- }
- }
- }
- private static MainAction mainAction;
-
- /** Your new java application main entry, which pipelines your application */
- public static void main(String[] args) {
- if(DEBUG) System.err.println("MainThread.main(): "+Thread.currentThread().getName()+" USE_MAIN_THREAD "+ USE_MAIN_THREAD );
-
- if(args.length==0) {
- return;
- }
-
- String mainClassName=args[0];
- String[] mainClassArgs=new String[args.length-1];
- if(args.length>1) {
- System.arraycopy(args, 1, mainClassArgs, 0, args.length-1);
- }
-
- NativeLibLoader.loadNEWT();
-
- shouldStop = false;
- tasks = new ArrayList();
- tasksBlock = new ArrayList();
- mainThread = Thread.currentThread();
-
- mainAction = new MainAction(mainClassName, mainClassArgs);
-
- if(NativeWindowFactory.TYPE_MACOSX.equals(NativeWindowFactory.getNativeWindowType(false))) {
- MacDisplay.initSingleton();
- }
-
- if ( USE_MAIN_THREAD ) {
- // dispatch user's main thread ..
- mainAction.start();
-
- // do our main thread task scheduling
- run();
- } else {
- // run user's main in this thread
- mainAction.run();
- }
- }
-
- /** invokes the given Runnable */
- public static void invoke(boolean wait, Runnable r) {
- if(r == null) {
- return;
- }
-
- // if this main thread is not being used or
- // if this is already the main thread .. just execute.
- if( !isRunning() || mainThread == Thread.currentThread() ) {
- r.run();
- return;
- }
-
- synchronized(taskWorkerLock) {
- tasks.add(r);
- if(wait) {
- tasksBlock.add(r);
- }
- taskWorkerLock.notifyAll();
- if(wait) {
- while(tasksBlock.size()>0) {
- try {
- taskWorkerLock.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
-
- public static void exit() {
- if(DEBUG) System.err.println("MainThread.exit(): "+Thread.currentThread().getName()+" start");
- synchronized(taskWorkerLock) {
- if(isRunning) {
- shouldStop = true;
- }
- taskWorkerLock.notifyAll();
- }
- if(DEBUG) System.err.println("MainThread.exit(): "+Thread.currentThread().getName()+" end");
- }
-
- public static boolean isRunning() {
- synchronized(taskWorkerLock) {
- return isRunning;
- }
- }
-
- private static void waitUntilRunning() {
- synchronized(taskWorkerLock) {
- if(isExit) return;
-
- while(!isRunning) {
- try {
- taskWorkerLock.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- public static void run() {
- if(DEBUG) System.err.println("MainThread.run(): "+Thread.currentThread().getName());
- synchronized(taskWorkerLock) {
- isRunning = true;
- taskWorkerLock.notifyAll();
- }
- while(!shouldStop) {
- try {
- ArrayList localTasks=null;
-
- // wait for something todo ..
- synchronized(taskWorkerLock) {
- while(!shouldStop && tasks.size()==0) {
- try {
- taskWorkerLock.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- // seq. process all tasks until no blocking one exists in the list
- for(Iterator i = tasks.iterator(); tasksBlock.size()>0 && i.hasNext(); ) {
- Runnable task = (Runnable) i.next();
- task.run();
- i.remove();
- tasksBlock.remove(task);
- }
-
- // take over the tasks ..
- if(tasks.size()>0) {
- localTasks = tasks;
- tasks = new ArrayList();
- }
- taskWorkerLock.notifyAll();
- }
-
- // seq. process all unblocking tasks ..
- if(null!=localTasks) {
- for(Iterator i = localTasks.iterator(); i.hasNext(); ) {
- Runnable task = (Runnable) i.next();
- task.run();
- }
- }
- } catch (Throwable t) {
- // handle errors ..
- t.printStackTrace();
- } finally {
- // epilog - unlock locked stuff
- }
- }
- if(DEBUG) System.err.println("MainThread.run(): "+Thread.currentThread().getName()+" fin");
- synchronized(taskWorkerLock) {
- isRunning = false;
- isExit = true;
- taskWorkerLock.notifyAll();
- }
- }
-}
-
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsDisplay.java b/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsDisplay.java
deleted file mode 100755
index f2e8d21ef..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsDisplay.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.jogamp.javafx.newt.windows;
-
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.windows.*;
-import com.jogamp.javafx.newt.*;
-import com.jogamp.javafx.newt.impl.*;
-
-public class WindowsDisplay extends Display {
-
- protected static final String WINDOW_CLASS_NAME = "NewtWindowClass";
- private static int windowClassAtom;
- private static long hInstance;
-
- static {
- NativeLibLoader.loadNEWT();
-
- if (!WindowsWindow.initIDs()) {
- throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs");
- }
- }
-
- public static void initSingleton() {
- // just exist to ensure static init has been run
- }
-
-
- public WindowsDisplay() {
- }
-
- protected void createNative() {
- aDevice = new WindowsGraphicsDevice();
- }
-
- protected void closeNative() {
- // Can't do .. only at application shutdown
- // UnregisterWindowClass(getWindowClassAtom(), getHInstance());
- }
-
- protected void dispatchMessages() {
- DispatchMessages();
- }
-
- protected static synchronized int getWindowClassAtom() {
- if(0 == windowClassAtom) {
- windowClassAtom = RegisterWindowClass(WINDOW_CLASS_NAME, getHInstance());
- if (0 == windowClassAtom) {
- throw new NativeWindowException("Error while registering window class");
- }
- }
- return windowClassAtom;
- }
-
- protected static synchronized long getHInstance() {
- if(0 == hInstance) {
- hInstance = LoadLibraryW("newt");
- if (0 == hInstance) {
- throw new NativeWindowException("Error finding HINSTANCE for \"newt\"");
- }
- }
- return hInstance;
- }
-
- //----------------------------------------------------------------------
- // Internals only
- //
- private static native long LoadLibraryW(String libraryName);
- private static native int RegisterWindowClass(String windowClassName, long hInstance);
- private static native void UnregisterWindowClass(int wndClassAtom, long hInstance);
-
- private static native void DispatchMessages();
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsScreen.java b/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsScreen.java
deleted file mode 100755
index ab11f97dd..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsScreen.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.jogamp.javafx.newt.windows;
-
-import com.jogamp.javafx.newt.*;
-import com.jogamp.javafx.newt.impl.*;
-import javax.media.nativewindow.*;
-
-public class WindowsScreen extends Screen {
- static {
- WindowsDisplay.initSingleton();
- }
-
-
- public WindowsScreen() {
- }
-
- protected void createNative(int index) {
- aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
- setScreenSize(getWidthImpl(getIndex()), getHeightImpl(getIndex()));
- }
-
- protected void closeNative() { }
-
- private native int getWidthImpl(int scrn_idx);
- private native int getHeightImpl(int scrn_idx);
-}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsWindow.java
deleted file mode 100755
index 7c8864190..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/windows/WindowsWindow.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * 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.jogamp.javafx.newt.windows;
-
-import javax.media.nativewindow.*;
-import com.jogamp.javafx.newt.*;
-
-public class WindowsWindow extends Window {
-
- private long hmon;
- private long hdc;
- private long windowHandleClose;
- private long parentWindowHandle;
- // non fullscreen dimensions ..
- private int nfs_width, nfs_height, nfs_x, nfs_y;
- private final Insets insets = new Insets(0, 0, 0, 0);
-
- static {
- WindowsDisplay.initSingleton();
- }
-
- public WindowsWindow() {
- }
-
- Thread hdcOwner = null;
-
- public synchronized int lockSurface() throws NativeWindowException {
- int res = super.lockSurface();
- if(LOCK_SUCCESS==res && 0!=windowHandle) {
- if(hdc!=0) {
- throw new NativeWindowException("NEWT Surface handle set HDC "+toHexString(hdc)+" - "+Thread.currentThread().getName()+" ; "+this);
- }
- hdc = GetDC(windowHandle);
- hmon = MonitorFromWindow(windowHandle);
- hdcOwner = Thread.currentThread();
- }
- return res;
- }
-
- public synchronized void unlockSurface() {
- // prevalidate, before we change data ..
- Thread cur = Thread.currentThread();
- if ( getSurfaceLockOwner() != cur ) {
- getLockedStack().printStackTrace();
- throw new NativeWindowException(cur+": Not owner, owner is "+getSurfaceLockOwner());
- }
- if (0!=hdc && 0!=windowHandle) {
- if(hdcOwner != cur) {
- throw new NativeWindowException("NEWT Surface handle set HDC "+toHexString(hdc)+" by other thread "+hdcOwner+", this "+cur+" ; "+this);
- }
- ReleaseDC(windowHandle, hdc);
- hdc=0;
- hdcOwner=null;
- }
- super.unlockSurface();
- }
-
- public long getSurfaceHandle() {
- return hdc;
- }
-
- public boolean hasDeviceChanged() {
- if(0!=windowHandle) {
- long _hmon = MonitorFromWindow(windowHandle);
- if (hmon != _hmon) {
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- Exception e = new Exception("!!! Window Device Changed "+Thread.currentThread().getName()+
- ", HMON "+toHexString(hmon)+" -> "+toHexString(_hmon));
- e.printStackTrace();
- }
- hmon = _hmon;
- return true;
- }
- }
- return false;
- }
-
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- WindowsScreen screen = (WindowsScreen) getScreen();
- WindowsDisplay display = (WindowsDisplay) screen.getDisplay();
- config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
- if (config == null) {
- throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
- }
- windowHandle = CreateWindow(parentWindowHandle,
- display.getWindowClassAtom(), display.WINDOW_CLASS_NAME, display.getHInstance(),
- 0, undecorated, x, y, width, height);
- if (windowHandle == 0) {
- throw new NativeWindowException("Error creating window");
- }
- this.parentWindowHandle = parentWindowHandle;
- windowHandleClose = windowHandle;
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- Exception e = new Exception("!!! Window new window handle "+Thread.currentThread().getName()+
- " (Parent HWND "+toHexString(parentWindowHandle)+
- ") : HWND "+toHexString(windowHandle)+", "+Thread.currentThread());
- e.printStackTrace();
- }
- }
-
- protected void closeNative() {
- if (hdc != 0) {
- if(windowHandleClose != 0) {
- ReleaseDC(windowHandleClose, hdc);
- }
- hdc = 0;
- }
- if(windowHandleClose != 0) {
- DestroyWindow(windowHandleClose);
- windowHandleClose = 0;
- }
- }
-
- protected void windowDestroyed() {
- windowHandleClose = 0;
- super.windowDestroyed();
- }
-
- public void setVisible(boolean visible) {
- if(this.visible!=visible && 0!=windowHandle) {
- this.visible=visible;
- setVisible0(windowHandle, visible);
- }
- }
-
- // @Override
- public void setSize(int width, int height) {
- if (0!=windowHandle && (width != this.width || this.height != height)) {
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- }
- this.width = width;
- this.height = height;
- setSize0(parentWindowHandle, windowHandle, x, y, width, height);
- }
- }
-
- //@Override
- public void setPosition(int x, int y) {
- if (0!=windowHandle && (this.x != x || this.y != y)) {
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
- }
- this.x = x;
- this.y = y;
- setPosition(parentWindowHandle, windowHandle, x , y);
- }
- }
-
- public boolean setFullscreen(boolean fullscreen) {
- if(0!=windowHandle && (this.fullscreen!=fullscreen)) {
- int x,y,w,h;
- this.fullscreen=fullscreen;
- if(fullscreen) {
- x = 0; y = 0;
- w = screen.getWidth();
- h = screen.getHeight();
- } else {
- x = nfs_x;
- y = nfs_y;
- w = nfs_width;
- h = nfs_height;
- }
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- System.err.println("WindowsWindow fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
- }
- setFullscreen0(parentWindowHandle, windowHandle, x, y, w, h, undecorated, fullscreen);
- }
- return fullscreen;
- }
-
- // @Override
- public void requestFocus() {
- super.requestFocus();
- if (windowHandle != 0L) {
- requestFocus(windowHandle);
- }
- }
-
- // @Override
- public void setTitle(String title) {
- if (title == null) {
- title = "";
- }
- if (0!=windowHandle && !title.equals(getTitle())) {
- super.setTitle(title);
- setTitle(windowHandle, title);
- }
- }
-
- public Insets getInsets() {
- return (Insets)insets.clone();
- }
-
- //----------------------------------------------------------------------
- // Internals only
- //
- protected static native boolean initIDs();
- private native long CreateWindow(long parentWindowHandle,
- int wndClassAtom, String wndName,
- long hInstance, long visualID,
- boolean isUndecorated,
- int x, int y, int width, int height);
- private native void DestroyWindow(long windowHandle);
- private native long GetDC(long windowHandle);
- private native void ReleaseDC(long windowHandle, long hdc);
- private native long MonitorFromWindow(long windowHandle);
- private static native void setVisible0(long windowHandle, boolean visible);
- private native void setSize0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height);
- private native void setPosition(long parentWindowHandle, long windowHandle, int x, int y);
- private native void setFullscreen0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height, boolean isUndecorated, boolean on);
- private static native void setTitle(long windowHandle, String title);
- private static native void requestFocus(long windowHandle);
-
- private void insetsChanged(int left, int top, int right, int bottom) {
- if (left != -1 && top != -1 && right != -1 && bottom != -1) {
- insets.left = left;
- insets.top = top;
- insets.right = right;
- insets.bottom = bottom;
- }
- }
- private void sizeChanged(int newWidth, int newHeight) {
- width = newWidth;
- height = newHeight;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- }
- sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
- }
-
- private void positionChanged(int newX, int newY) {
- x = newX;
- y = newY;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
- }
- sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
- }
-
- /**
- *
- * @param focusOwner if focusGained is true, focusOwner is the previous
- * focus owner, if focusGained is false, focusOwner is the new focus owner
- * @param focusGained
- */
- private void focusChanged(long focusOwner, boolean focusGained) {
- if (focusGained) {
- sendWindowEvent(WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
- } else {
- sendWindowEvent(WindowEvent.EVENT_WINDOW_LOST_FOCUS);
- }
- }
-}
diff --git a/src/newt/classes/com/jogamp/javafx/newt/x11/X11Display.java b/src/newt/classes/com/jogamp/javafx/newt/x11/X11Display.java
deleted file mode 100755
index 96d55c082..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/x11/X11Display.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.jogamp.javafx.newt.x11;
-
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-import com.jogamp.javafx.newt.*;
-import com.jogamp.javafx.newt.impl.*;
-import com.jogamp.nativewindow.impl.x11.X11Util;
-
-public class X11Display extends Display {
- static {
- NativeLibLoader.loadNEWT();
-
- if (!initIDs()) {
- throw new NativeWindowException("Failed to initialize X11Display jmethodIDs");
- }
-
- if (!X11Window.initIDs()) {
- throw new NativeWindowException("Failed to initialize X11Window jmethodIDs");
- }
- }
-
- public static void initSingleton() {
- // just exist to ensure static init has been run
- }
-
-
- public X11Display() {
- }
-
- protected void createNative() {
- long handle= X11Util.getThreadLocalDisplay(name);
- if (handle == 0 ) {
- throw new RuntimeException("Error creating display: "+name);
- }
- try {
- CompleteDisplay(handle);
- } catch(RuntimeException e) {
- X11Util.closeThreadLocalDisplay(name);
- throw e;
- }
- aDevice = new X11GraphicsDevice(handle);
- }
-
- protected void closeNative() {
- if(0==X11Util.closeThreadLocalDisplay(name)) {
- throw new NativeWindowException(this+" was not mapped");
- }
- }
-
- protected void dispatchMessages() {
- DispatchMessages(getHandle(), javaObjectAtom, windowDeleteAtom);
- }
-
- protected void lockDisplay() {
- super.lockDisplay();
- LockDisplay(getHandle());
- }
-
- protected void unlockDisplay() {
- UnlockDisplay(getHandle());
- super.unlockDisplay();
- }
-
- protected long getJavaObjectAtom() { return javaObjectAtom; }
- protected long getWindowDeleteAtom() { return windowDeleteAtom; }
-
- //----------------------------------------------------------------------
- // Internals only
- //
- private static native boolean initIDs();
-
- private native void LockDisplay(long handle);
- private native void UnlockDisplay(long handle);
-
- private native void CompleteDisplay(long handle);
-
- private native void DispatchMessages(long display, long javaObjectAtom, long windowDeleteAtom);
-
- private void displayCompleted(long javaObjectAtom, long windowDeleteAtom) {
- this.javaObjectAtom=javaObjectAtom;
- this.windowDeleteAtom=windowDeleteAtom;
- }
-
- private long windowDeleteAtom;
- private long javaObjectAtom;
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/x11/X11Screen.java b/src/newt/classes/com/jogamp/javafx/newt/x11/X11Screen.java
deleted file mode 100755
index d90b1868d..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/x11/X11Screen.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.jogamp.javafx.newt.x11;
-
-import com.jogamp.javafx.newt.*;
-import com.jogamp.javafx.newt.impl.*;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-
-public class X11Screen extends Screen {
-
- static {
- X11Display.initSingleton();
- }
-
-
- public X11Screen() {
- }
-
- protected void createNative(int index) {
- long handle = GetScreen(display.getHandle(), index);
- if (handle == 0 ) {
- throw new RuntimeException("Error creating screen: "+index);
- }
- aScreen = new X11GraphicsScreen((X11GraphicsDevice)getDisplay().getGraphicsDevice(), index);
- setScreenSize(getWidth0(display.getHandle(), index),
- getHeight0(display.getHandle(), index));
- }
-
- protected void closeNative() { }
-
- //----------------------------------------------------------------------
- // Internals only
- //
-
- private native long GetScreen(long dpy, int scrn_idx);
- private native int getWidth0(long display, int scrn_idx);
- private native int getHeight0(long display, int scrn_idx);
-}
-
diff --git a/src/newt/classes/com/jogamp/javafx/newt/x11/X11Window.java b/src/newt/classes/com/jogamp/javafx/newt/x11/X11Window.java
deleted file mode 100755
index 8387160c9..000000000
--- a/src/newt/classes/com/jogamp/javafx/newt/x11/X11Window.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * 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.jogamp.javafx.newt.x11;
-
-import com.jogamp.javafx.newt.*;
-import com.jogamp.javafx.newt.impl.*;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-
-public class X11Window extends Window {
- private static final String WINDOW_CLASS_NAME = "NewtWindow";
- // non fullscreen dimensions ..
- private int nfs_width, nfs_height, nfs_x, nfs_y;
-
- static {
- X11Display.initSingleton();
- }
-
- public X11Window() {
- }
-
- protected void createNative(long parentWindowHandle, Capabilities caps) {
- X11Screen screen = (X11Screen) getScreen();
- X11Display display = (X11Display) screen.getDisplay();
- config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
- if (config == null) {
- throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
- }
- X11GraphicsConfiguration x11config = (X11GraphicsConfiguration) config;
- long visualID = x11config.getVisualID();
- long w = CreateWindow(parentWindowHandle,
- display.getHandle(), screen.getIndex(), visualID,
- display.getJavaObjectAtom(), display.getWindowDeleteAtom(), x, y, width, height);
- if (w == 0 || w!=windowHandle) {
- throw new NativeWindowException("Error creating window: "+w);
- }
- this.parentWindowHandle = parentWindowHandle;
- windowHandleClose = windowHandle;
- displayHandleClose = display.getHandle();
- }
-
- protected void closeNative() {
- if(0!=displayHandleClose && 0!=windowHandleClose && null!=getScreen() ) {
- X11Display display = (X11Display) getScreen().getDisplay();
- CloseWindow(displayHandleClose, windowHandleClose, display.getJavaObjectAtom());
- windowHandleClose = 0;
- displayHandleClose = 0;
- }
- }
-
- protected void windowDestroyed() {
- windowHandleClose = 0;
- displayHandleClose = 0;
- super.windowDestroyed();
- }
-
- public void setVisible(boolean visible) {
- if(0!=windowHandle && this.visible!=visible) {
- this.visible=visible;
- setVisible0(getDisplayHandle(), windowHandle, visible);
- clearEventMask();
- }
- }
-
- public void requestFocus() {
- super.requestFocus();
- }
-
- public void setSize(int width, int height) {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("X11Window setSize: "+this.x+"/"+this.y+" "+this.width+"x"+this.height+" -> "+width+"x"+height);
- // Exception e = new Exception("XXXXXXXXXX");
- // e.printStackTrace();
- }
- this.width = width;
- this.height = height;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- }
- if(0!=windowHandle) {
- setSize0(parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, width, height, (undecorated||fullscreen)?-1:1, false);
- }
- }
-
- public void setPosition(int x, int y) {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("X11Window setPosition: "+this.x+"/"+this.y+" -> "+x+"/"+y);
- // Exception e = new Exception("XXXXXXXXXX");
- // e.printStackTrace();
- }
- this.x = x;
- this.y = y;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
- }
- if(0!=windowHandle) {
- setPosition0(getDisplayHandle(), windowHandle, x, y);
- }
- }
-
- public boolean setFullscreen(boolean fullscreen) {
- if(0!=windowHandle && this.fullscreen!=fullscreen) {
- int x,y,w,h;
- this.fullscreen=fullscreen;
- if(fullscreen) {
- x = 0; y = 0;
- w = screen.getWidth();
- h = screen.getHeight();
- } else {
- x = nfs_x;
- y = nfs_y;
- w = nfs_width;
- h = nfs_height;
- }
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- System.err.println("X11Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
- }
- setSize0(parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, w, h, (undecorated||fullscreen)?-1:1, false);
- }
- return fullscreen;
- }
-
- //----------------------------------------------------------------------
- // Internals only
- //
-
- protected static native boolean initIDs();
- private native long CreateWindow(long parentWindowHandle, long display, int screen_index,
- long visualID, long javaObjectAtom, long windowDeleteAtom, int x, int y, int width, int height);
- private native void CloseWindow(long display, long windowHandle, long javaObjectAtom);
- private native void setVisible0(long display, long windowHandle, boolean visible);
- private native void setSize0(long parentWindowHandle, long display, int screen_index, long windowHandle,
- int x, int y, int width, int height, int decorationToggle, boolean setVisible);
- private native void setPosition0(long display, long windowHandle, int x, int y);
-
- private void windowChanged(int newX, int newY, int newWidth, int newHeight) {
- if(width != newWidth || height != newHeight) {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("X11Window windowChanged size: "+this.width+"x"+this.height+" -> "+newWidth+"x"+newHeight);
- }
- width = newWidth;
- height = newHeight;
- if(!fullscreen) {
- nfs_width=width;
- nfs_height=height;
- }
- sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
- }
- if( 0==parentWindowHandle && ( x != newX || y != newY ) ) {
- if(DEBUG_IMPLEMENTATION) {
- System.err.println("X11Window windowChanged position: "+this.x+"/"+this.y+" -> "+newX+"x"+newY);
- }
- x = newX;
- y = newY;
- if(!fullscreen) {
- nfs_x=x;
- nfs_y=y;
- }
- sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
- }
- }
-
- private void windowCreated(long windowHandle) {
- this.windowHandle = windowHandle;
- }
-
- private long windowHandleClose;
- private long displayHandleClose;
- private long parentWindowHandle;
-}
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java
new file mode 100755
index 000000000..88f6dd34b
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/Display.java
@@ -0,0 +1,276 @@
+/*
+ * 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.jogamp.newt;
+
+import javax.media.nativewindow.*;
+import com.jogamp.newt.impl.Debug;
+import com.jogamp.newt.util.EventDispatchThread;
+import java.util.*;
+
+public abstract class Display {
+ public static final boolean DEBUG = Debug.debug("Display");
+
+ private static Class getDisplayClass(String type)
+ throws ClassNotFoundException
+ {
+ Class displayClass = NewtFactory.getCustomClass(type, "Display");
+ if(null==displayClass) {
+ if (NativeWindowFactory.TYPE_EGL.equals(type)) {
+ displayClass = Class.forName("com.jogamp.newt.opengl.kd.KDDisplay");
+ } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
+ displayClass = Class.forName("com.jogamp.newt.windows.WindowsDisplay");
+ } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
+ displayClass = Class.forName("com.jogamp.newt.macosx.MacDisplay");
+ } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
+ displayClass = Class.forName("com.jogamp.newt.x11.X11Display");
+ } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
+ displayClass = Class.forName("com.jogamp.newt.awt.AWTDisplay");
+ } else {
+ throw new RuntimeException("Unknown display type \"" + type + "\"");
+ }
+ }
+ return displayClass;
+ }
+
+ // Unique Display for each thread
+ private static ThreadLocal currentDisplayMap = new ThreadLocal();
+
+ /** Returns the thread local display map */
+ public static Map getCurrentDisplayMap() {
+ Map displayMap = (Map) currentDisplayMap.get();
+ if(null==displayMap) {
+ displayMap = new HashMap();
+ currentDisplayMap.set( displayMap );
+ }
+ return displayMap;
+ }
+
+ /** maps the given display to the thread local display map
+ * and notifies all threads synchronized to this display map. */
+ protected static Display setCurrentDisplay(Display display) {
+ Map displayMap = getCurrentDisplayMap();
+ Display oldDisplay = null;
+ synchronized(displayMap) {
+ String name = display.getName();
+ if(null==name) name="nil";
+ oldDisplay = (Display) displayMap.put(name, display);
+ displayMap.notifyAll();
+ }
+ return oldDisplay;
+ }
+
+ /** removes the mapping of the given name from the thread local display map
+ * and notifies all threads synchronized to this display map. */
+ protected static Display removeCurrentDisplay(String name) {
+ if(null==name) name="nil";
+ Map displayMap = getCurrentDisplayMap();
+ Display oldDisplay = null;
+ synchronized(displayMap) {
+ oldDisplay = (Display) displayMap.remove(name);
+ displayMap.notifyAll();
+ }
+ return oldDisplay;
+ }
+
+ /** Returns the thread local display mapped to the given name */
+ public static Display getCurrentDisplay(String name) {
+ if(null==name) name="nil";
+ Map displayMap = getCurrentDisplayMap();
+ Display display = (Display) displayMap.get(name);
+ return display;
+ }
+
+ public static void dumpDisplayMap(String prefix) {
+ Map displayMap = getCurrentDisplayMap();
+ Set entrySet = displayMap.entrySet();
+ Iterator i = entrySet.iterator();
+ System.err.println(prefix+" DisplayMap["+entrySet.size()+"] "+Thread.currentThread());
+ for(int j=0; i.hasNext(); j++) {
+ Map.Entry entry = (Map.Entry) i.next();
+ System.err.println(" ["+j+"] "+entry.getKey()+" -> "+entry.getValue());
+ }
+ }
+
+ /** Returns the thread local display collection */
+ public static Collection getCurrentDisplays() {
+ return getCurrentDisplayMap().values();
+ }
+
+ /** Make sure to reuse a Display with the same name */
+ protected static Display create(String type, String name) {
+ try {
+ if(DEBUG) {
+ dumpDisplayMap("Display.create("+name+") BEGIN");
+ }
+ Display display = getCurrentDisplay(name);
+ if(null==display) {
+ Class displayClass = getDisplayClass(type);
+ display = (Display) displayClass.newInstance();
+ display.name=name;
+ display.refCount=1;
+
+ if(NewtFactory.useEDT()) {
+ Thread current = Thread.currentThread();
+ display.eventDispatchThread = new EventDispatchThread(display, current.getThreadGroup(), current.getName());
+ display.eventDispatchThread.start();
+ final Display f_dpy = display;
+ display.eventDispatchThread.invokeAndWait(new Runnable() {
+ public void run() {
+ f_dpy.createNative();
+ }
+ } );
+ } else {
+ display.createNative();
+ }
+ if(null==display.aDevice) {
+ throw new RuntimeException("Display.createNative() failed to instanciate an AbstractGraphicsDevice");
+ }
+ setCurrentDisplay(display);
+ if(DEBUG) {
+ System.err.println("Display.create("+name+") NEW: "+display+" "+Thread.currentThread());
+ }
+ } else {
+ synchronized(display) {
+ display.refCount++;
+ if(DEBUG) {
+ System.err.println("Display.create("+name+") REUSE: refCount "+display.refCount+", "+display+" "+Thread.currentThread());
+ }
+ }
+ }
+ if(DEBUG) {
+ dumpDisplayMap("Display.create("+name+") END");
+ }
+ return display;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected static Display wrapHandle(String type, String name, AbstractGraphicsDevice aDevice) {
+ try {
+ Class displayClass = getDisplayClass(type);
+ Display display = (Display) displayClass.newInstance();
+ display.name=name;
+ display.aDevice=aDevice;
+ return display;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public EventDispatchThread getEDT() { return eventDispatchThread; }
+
+ public synchronized void destroy() {
+ if(DEBUG) {
+ dumpDisplayMap("Display.destroy("+name+") BEGIN");
+ }
+ refCount--;
+ if(0==refCount) {
+ removeCurrentDisplay(name);
+ if(DEBUG) {
+ System.err.println("Display.destroy("+name+") REMOVE: "+this+" "+Thread.currentThread());
+ }
+ if(null!=eventDispatchThread) {
+ final Display f_dpy = this;
+ final EventDispatchThread f_edt = eventDispatchThread;
+ eventDispatchThread.invokeAndWait(new Runnable() {
+ public void run() {
+ f_dpy.closeNative();
+ f_edt.stop();
+ }
+ } );
+ } else {
+ closeNative();
+ }
+ if(null!=eventDispatchThread) {
+ eventDispatchThread.waitUntilStopped();
+ eventDispatchThread=null;
+ }
+ aDevice = null;
+ } else {
+ if(DEBUG) {
+ System.err.println("Display.destroy("+name+") KEEP: refCount "+refCount+", "+this+" "+Thread.currentThread());
+ }
+ }
+ if(DEBUG) {
+ dumpDisplayMap("Display.destroy("+name+") END");
+ }
+ }
+
+ protected abstract void createNative();
+ protected abstract void closeNative();
+
+ public String getName() {
+ return name;
+ }
+
+ public long getHandle() {
+ if(null!=aDevice) {
+ return aDevice.getHandle();
+ }
+ return 0;
+ }
+
+ public AbstractGraphicsDevice getGraphicsDevice() {
+ return aDevice;
+ }
+
+ public void pumpMessages() {
+ if(null!=eventDispatchThread) {
+ dispatchMessages();
+ } else {
+ synchronized(this) {
+ dispatchMessages();
+ }
+ }
+ }
+
+ public String toString() {
+ return "NEWT-Display["+name+", refCount "+refCount+", "+aDevice+"]";
+ }
+
+ protected abstract void dispatchMessages();
+
+ /** Default impl. nop - Currently only X11 needs a Display lock */
+ protected void lockDisplay() { }
+
+ /** Default impl. nop - Currently only X11 needs a Display lock */
+ protected void unlockDisplay() { }
+
+ protected EventDispatchThread eventDispatchThread = null;
+ protected String name;
+ protected int refCount;
+ protected AbstractGraphicsDevice aDevice;
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/Event.java b/src/newt/classes/com/jogamp/newt/Event.java
new file mode 100644
index 000000000..d42a95735
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/Event.java
@@ -0,0 +1,86 @@
+/*
+ * 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.jogamp.newt;
+
+public class Event {
+ private boolean isSystemEvent;
+ private int eventType;
+ private Window source;
+ private long when;
+
+ Event(boolean isSystemEvent, int eventType, Window source, long when) {
+ this.isSystemEvent = isSystemEvent;
+ this.eventType = eventType;
+ this.source = source;
+ this.when = when;
+ }
+
+ protected Event(int eventType, Window source, long when) {
+ this(false, eventType, source, when);
+ }
+
+ /** Indicates whether this event was produced by the system or
+ generated by user code. */
+ public final boolean isSystemEvent() {
+ return isSystemEvent;
+ }
+
+ /** Returns the event type of this event. */
+ public final int getEventType() {
+ return eventType;
+ }
+
+ /** Returns the source Window which produced this Event. */
+ public final Window getSource() {
+ return source;
+ }
+
+ /** Returns the timestamp, in milliseconds, of this event. */
+ public final long getWhen() {
+ return when;
+ }
+
+ public String toString() {
+ return "Event[sys:"+isSystemEvent()+", source:"+getSource()+", when:"+getWhen()+"]";
+ }
+
+ public static String toHexString(int hex) {
+ return "0x" + Integer.toHexString(hex);
+ }
+
+ public static String toHexString(long hex) {
+ return "0x" + Long.toHexString(hex);
+ }
+
+}
diff --git a/src/newt/classes/com/jogamp/newt/EventListener.java b/src/newt/classes/com/jogamp/newt/EventListener.java
new file mode 100644
index 000000000..75cb487dd
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/EventListener.java
@@ -0,0 +1,44 @@
+/*
+ * 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.jogamp.newt;
+
+public interface EventListener
+{
+ public static final int WINDOW = 1 << 0;
+ public static final int MOUSE = 1 << 1;
+ public static final int KEY = 1 << 2;
+ public static final int SURFACE = 1 << 3;
+
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/InputEvent.java b/src/newt/classes/com/jogamp/newt/InputEvent.java
new file mode 100644
index 000000000..d4c3f6905
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/InputEvent.java
@@ -0,0 +1,97 @@
+/*
+ * 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.jogamp.newt;
+
+public abstract class InputEvent extends Event
+{
+ public static final int SHIFT_MASK = 1 << 0;
+ public static final int CTRL_MASK = 1 << 1;
+ public static final int META_MASK = 1 << 2;
+ public static final int ALT_MASK = 1 << 3;
+ public static final int ALT_GRAPH_MASK = 1 << 5;
+ public static final int BUTTON1_MASK = 1 << 6;
+ public static final int BUTTON2_MASK = 1 << 7;
+ public static final int BUTTON3_MASK = 1 << 8;
+
+ protected InputEvent(boolean sysEvent, int eventType, Window source, long when, int modifiers) {
+ super(sysEvent, eventType, source, when);
+ this.consumed=false;
+ this.modifiers=modifiers;
+ }
+
+ public void consume() {
+ consumed=true;
+ }
+
+ public boolean isConsumed() {
+ return consumed;
+ }
+ public int getModifiers() {
+ return modifiers;
+ }
+ public boolean isAltDown() {
+ return (modifiers&ALT_MASK)!=0;
+ }
+ public boolean isAltGraphDown() {
+ return (modifiers&ALT_GRAPH_MASK)!=0;
+ }
+ public boolean isControlDown() {
+ return (modifiers&CTRL_MASK)!=0;
+ }
+ public boolean isMetaDown() {
+ return (modifiers&META_MASK)!=0;
+ }
+ public boolean isShiftDown() {
+ return (modifiers&SHIFT_MASK)!=0;
+ }
+
+ public boolean isButton1Down() {
+ return (modifiers&BUTTON1_MASK)!=0;
+ }
+
+ public boolean isButton2Down() {
+ return (modifiers&BUTTON2_MASK)!=0;
+ }
+
+ public boolean isButton3Down() {
+ return (modifiers&BUTTON3_MASK)!=0;
+ }
+
+ public String toString() {
+ return "InputEvent[modifiers:"+modifiers+"]";
+ }
+
+ private boolean consumed;
+ private int modifiers;
+}
diff --git a/src/newt/classes/com/jogamp/newt/Insets.java b/src/newt/classes/com/jogamp/newt/Insets.java
new file mode 100644
index 000000000..e440892f0
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/Insets.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2009 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.jogamp.newt;
+
+/**
+ * Simple class representing insets.
+ *
+ * @author tdv
+ */
+public class Insets implements Cloneable {
+ public int top;
+ public int left;
+ public int bottom;
+ public int right;
+
+ /**
+ * Creates and initializes a new Insets
object with the
+ * specified top, left, bottom, and right insets.
+ * @param top the inset from the top.
+ * @param left the inset from the left.
+ * @param bottom the inset from the bottom.
+ * @param right the inset from the right.
+ */
+ public Insets(int top, int left, int bottom, int right) {
+ this.top = top;
+ this.left = left;
+ this.bottom = bottom;
+ this.right = right;
+ }
+
+ /**
+ * Checks whether two insets objects are equal. Two instances
+ * of Insets
are equal if the four integer values
+ * of the fields top
, left
,
+ * bottom
, and right
are all equal.
+ * @return true
if the two insets are equal;
+ * otherwise false
.
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof Insets) {
+ Insets insets = (Insets)obj;
+ return ((top == insets.top) && (left == insets.left) &&
+ (bottom == insets.bottom) && (right == insets.right));
+ }
+ return false;
+ }
+
+ /**
+ * Returns the hash code for this Insets.
+ *
+ * @return a hash code for this Insets.
+ */
+ public int hashCode() {
+ int sum1 = left + bottom;
+ int sum2 = right + top;
+ int val1 = sum1 * (sum1 + 1)/2 + left;
+ int val2 = sum2 * (sum2 + 1)/2 + top;
+ int sum3 = val1 + val2;
+ return sum3 * (sum3 + 1)/2 + val2;
+ }
+
+ public String toString() {
+ return getClass().getName() + "[top=" + top + ",left=" + left +
+ ",bottom=" + bottom + ",right=" + right + "]";
+ }
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException ex) {
+ throw new InternalError();
+ }
+ }
+
+}
diff --git a/src/newt/classes/com/jogamp/newt/KeyEvent.java b/src/newt/classes/com/jogamp/newt/KeyEvent.java
new file mode 100644
index 000000000..bec77160b
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/KeyEvent.java
@@ -0,0 +1,738 @@
+/*
+ * 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.jogamp.newt;
+
+public class KeyEvent extends InputEvent
+{
+ KeyEvent(boolean sysEvent, int eventType, Window source, long when, int modifiers, int keyCode, char keyChar) {
+ super(sysEvent, eventType, source, when, modifiers);
+ this.keyCode=keyCode;
+ this.keyChar=keyChar;
+ }
+ public KeyEvent(int eventType, Window source, long when, int modifiers, int keyCode, char keyChar) {
+ this(false, eventType, source, when, modifiers, keyCode, keyChar);
+ }
+
+ public char getKeyChar() {
+ return keyChar;
+ }
+ public int getKeyCode() {
+ return keyCode;
+ }
+
+ public String toString() {
+ return "KeyEvent["+getEventTypeString(getEventType())+
+ ", code "+keyCode+"("+toHexString(keyCode)+"), char <"+keyChar+"> ("+toHexString((int)keyChar)+"), isActionKey "+isActionKey()+", "+super.toString()+"]";
+ }
+
+ public static String getEventTypeString(int type) {
+ switch(type) {
+ case EVENT_KEY_PRESSED: return "EVENT_KEY_PRESSED";
+ case EVENT_KEY_RELEASED: return "EVENT_KEY_RELEASED";
+ case EVENT_KEY_TYPED: return "EVENT_KEY_TYPED";
+ default: return "unknown (" + type + ")";
+ }
+ }
+
+ public boolean isActionKey() {
+ switch (keyCode) {
+ case VK_HOME:
+ case VK_END:
+ case VK_PAGE_UP:
+ case VK_PAGE_DOWN:
+ case VK_UP:
+ case VK_DOWN:
+ case VK_LEFT:
+ case VK_RIGHT:
+
+ case VK_F1:
+ case VK_F2:
+ case VK_F3:
+ case VK_F4:
+ case VK_F5:
+ case VK_F6:
+ case VK_F7:
+ case VK_F8:
+ case VK_F9:
+ case VK_F10:
+ case VK_F11:
+ case VK_F12:
+ case VK_F13:
+ case VK_F14:
+ case VK_F15:
+ case VK_F16:
+ case VK_F17:
+ case VK_F18:
+ case VK_F19:
+ case VK_F20:
+ case VK_F21:
+ case VK_F22:
+ case VK_F23:
+ case VK_F24:
+ case VK_PRINTSCREEN:
+ case VK_CAPS_LOCK:
+ case VK_PAUSE:
+ case VK_INSERT:
+
+ case VK_HELP:
+ case VK_WINDOWS:
+ return true;
+ }
+ return false;
+ }
+
+ private int keyCode;
+ private char keyChar;
+
+ public static final int EVENT_KEY_PRESSED = 300;
+ public static final int EVENT_KEY_RELEASED= 301;
+ public static final int EVENT_KEY_TYPED = 302;
+
+ /* Virtual key codes. */
+
+ public static final int VK_ENTER = '\n';
+ public static final int VK_BACK_SPACE = '\b';
+ public static final int VK_TAB = '\t';
+ public static final int VK_CANCEL = 0x03;
+ public static final int VK_CLEAR = 0x0C;
+ public static final int VK_SHIFT = 0x10;
+ public static final int VK_CONTROL = 0x11;
+ public static final int VK_ALT = 0x12;
+ public static final int VK_PAUSE = 0x13;
+ public static final int VK_CAPS_LOCK = 0x14;
+ public static final int VK_ESCAPE = 0x1B;
+ public static final int VK_SPACE = 0x20;
+ public static final int VK_PAGE_UP = 0x21;
+ public static final int VK_PAGE_DOWN = 0x22;
+ public static final int VK_END = 0x23;
+ public static final int VK_HOME = 0x24;
+
+ /**
+ * Constant for the non-numpad left arrow key.
+ * @see #VK_KP_LEFT
+ */
+ public static final int VK_LEFT = 0x25;
+
+ /**
+ * Constant for the non-numpad up arrow key.
+ * @see #VK_KP_UP
+ */
+ public static final int VK_UP = 0x26;
+
+ /**
+ * Constant for the non-numpad right arrow key.
+ * @see #VK_KP_RIGHT
+ */
+ public static final int VK_RIGHT = 0x27;
+
+ /**
+ * Constant for the non-numpad down arrow key.
+ * @see #VK_KP_DOWN
+ */
+ public static final int VK_DOWN = 0x28;
+
+ /**
+ * Constant for the comma key, ","
+ */
+ public static final int VK_COMMA = 0x2C;
+
+ /**
+ * Constant for the minus key, "-"
+ * @since 1.2
+ */
+ public static final int VK_MINUS = 0x2D;
+
+ /**
+ * Constant for the period key, "."
+ */
+ public static final int VK_PERIOD = 0x2E;
+
+ /**
+ * Constant for the forward slash key, "/"
+ */
+ public static final int VK_SLASH = 0x2F;
+
+ /** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
+ public static final int VK_0 = 0x30;
+ public static final int VK_1 = 0x31;
+ public static final int VK_2 = 0x32;
+ public static final int VK_3 = 0x33;
+ public static final int VK_4 = 0x34;
+ public static final int VK_5 = 0x35;
+ public static final int VK_6 = 0x36;
+ public static final int VK_7 = 0x37;
+ public static final int VK_8 = 0x38;
+ public static final int VK_9 = 0x39;
+
+ /**
+ * Constant for the semicolon key, ";"
+ */
+ public static final int VK_SEMICOLON = 0x3B;
+
+ /**
+ * Constant for the equals key, "="
+ */
+ public static final int VK_EQUALS = 0x3D;
+
+ /** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
+ public static final int VK_A = 0x41;
+ public static final int VK_B = 0x42;
+ public static final int VK_C = 0x43;
+ public static final int VK_D = 0x44;
+ public static final int VK_E = 0x45;
+ public static final int VK_F = 0x46;
+ public static final int VK_G = 0x47;
+ public static final int VK_H = 0x48;
+ public static final int VK_I = 0x49;
+ public static final int VK_J = 0x4A;
+ public static final int VK_K = 0x4B;
+ public static final int VK_L = 0x4C;
+ public static final int VK_M = 0x4D;
+ public static final int VK_N = 0x4E;
+ public static final int VK_O = 0x4F;
+ public static final int VK_P = 0x50;
+ public static final int VK_Q = 0x51;
+ public static final int VK_R = 0x52;
+ public static final int VK_S = 0x53;
+ public static final int VK_T = 0x54;
+ public static final int VK_U = 0x55;
+ public static final int VK_V = 0x56;
+ public static final int VK_W = 0x57;
+ public static final int VK_X = 0x58;
+ public static final int VK_Y = 0x59;
+ public static final int VK_Z = 0x5A;
+
+ /**
+ * Constant for the open bracket key, "["
+ */
+ public static final int VK_OPEN_BRACKET = 0x5B;
+
+ /**
+ * Constant for the back slash key, "\"
+ */
+ public static final int VK_BACK_SLASH = 0x5C;
+
+ /**
+ * Constant for the close bracket key, "]"
+ */
+ public static final int VK_CLOSE_BRACKET = 0x5D;
+
+ public static final int VK_NUMPAD0 = 0x60;
+ public static final int VK_NUMPAD1 = 0x61;
+ public static final int VK_NUMPAD2 = 0x62;
+ public static final int VK_NUMPAD3 = 0x63;
+ public static final int VK_NUMPAD4 = 0x64;
+ public static final int VK_NUMPAD5 = 0x65;
+ public static final int VK_NUMPAD6 = 0x66;
+ public static final int VK_NUMPAD7 = 0x67;
+ public static final int VK_NUMPAD8 = 0x68;
+ public static final int VK_NUMPAD9 = 0x69;
+ public static final int VK_MULTIPLY = 0x6A;
+ public static final int VK_ADD = 0x6B;
+
+ /**
+ * This constant is obsolete, and is included only for backwards
+ * compatibility.
+ * @see #VK_SEPARATOR
+ */
+ public static final int VK_SEPARATER = 0x6C;
+
+ /**
+ * Constant for the Numpad Separator key.
+ * @since 1.4
+ */
+ public static final int VK_SEPARATOR = VK_SEPARATER;
+
+ public static final int VK_SUBTRACT = 0x6D;
+ public static final int VK_DECIMAL = 0x6E;
+ public static final int VK_DIVIDE = 0x6F;
+ public static final int VK_DELETE = 0x7F; /* ASCII DEL */
+ public static final int VK_NUM_LOCK = 0x90;
+ public static final int VK_SCROLL_LOCK = 0x91;
+
+ /** Constant for the F1 function key. */
+ public static final int VK_F1 = 0x70;
+
+ /** Constant for the F2 function key. */
+ public static final int VK_F2 = 0x71;
+
+ /** Constant for the F3 function key. */
+ public static final int VK_F3 = 0x72;
+
+ /** Constant for the F4 function key. */
+ public static final int VK_F4 = 0x73;
+
+ /** Constant for the F5 function key. */
+ public static final int VK_F5 = 0x74;
+
+ /** Constant for the F6 function key. */
+ public static final int VK_F6 = 0x75;
+
+ /** Constant for the F7 function key. */
+ public static final int VK_F7 = 0x76;
+
+ /** Constant for the F8 function key. */
+ public static final int VK_F8 = 0x77;
+
+ /** Constant for the F9 function key. */
+ public static final int VK_F9 = 0x78;
+
+ /** Constant for the F10 function key. */
+ public static final int VK_F10 = 0x79;
+
+ /** Constant for the F11 function key. */
+ public static final int VK_F11 = 0x7A;
+
+ /** Constant for the F12 function key. */
+ public static final int VK_F12 = 0x7B;
+
+ /**
+ * Constant for the F13 function key.
+ * @since 1.2
+ */
+ /* F13 - F24 are used on IBM 3270 keyboard; use random range for constants. */
+ public static final int VK_F13 = 0xF000;
+
+ /**
+ * Constant for the F14 function key.
+ * @since 1.2
+ */
+ public static final int VK_F14 = 0xF001;
+
+ /**
+ * Constant for the F15 function key.
+ * @since 1.2
+ */
+ public static final int VK_F15 = 0xF002;
+
+ /**
+ * Constant for the F16 function key.
+ * @since 1.2
+ */
+ public static final int VK_F16 = 0xF003;
+
+ /**
+ * Constant for the F17 function key.
+ * @since 1.2
+ */
+ public static final int VK_F17 = 0xF004;
+
+ /**
+ * Constant for the F18 function key.
+ * @since 1.2
+ */
+ public static final int VK_F18 = 0xF005;
+
+ /**
+ * Constant for the F19 function key.
+ * @since 1.2
+ */
+ public static final int VK_F19 = 0xF006;
+
+ /**
+ * Constant for the F20 function key.
+ * @since 1.2
+ */
+ public static final int VK_F20 = 0xF007;
+
+ /**
+ * Constant for the F21 function key.
+ * @since 1.2
+ */
+ public static final int VK_F21 = 0xF008;
+
+ /**
+ * Constant for the F22 function key.
+ * @since 1.2
+ */
+ public static final int VK_F22 = 0xF009;
+
+ /**
+ * Constant for the F23 function key.
+ * @since 1.2
+ */
+ public static final int VK_F23 = 0xF00A;
+
+ /**
+ * Constant for the F24 function key.
+ * @since 1.2
+ */
+ public static final int VK_F24 = 0xF00B;
+
+ public static final int VK_PRINTSCREEN = 0x9A;
+ public static final int VK_INSERT = 0x9B;
+ public static final int VK_HELP = 0x9C;
+ public static final int VK_META = 0x9D;
+
+ public static final int VK_BACK_QUOTE = 0xC0;
+ public static final int VK_QUOTE = 0xDE;
+
+ /**
+ * Constant for the numeric keypad up arrow key.
+ * @see #VK_UP
+ * @since 1.2
+ */
+ public static final int VK_KP_UP = 0xE0;
+
+ /**
+ * Constant for the numeric keypad down arrow key.
+ * @see #VK_DOWN
+ * @since 1.2
+ */
+ public static final int VK_KP_DOWN = 0xE1;
+
+ /**
+ * Constant for the numeric keypad left arrow key.
+ * @see #VK_LEFT
+ * @since 1.2
+ */
+ public static final int VK_KP_LEFT = 0xE2;
+
+ /**
+ * Constant for the numeric keypad right arrow key.
+ * @see #VK_RIGHT
+ * @since 1.2
+ */
+ public static final int VK_KP_RIGHT = 0xE3;
+
+ /* For European keyboards */
+ /** @since 1.2 */
+ public static final int VK_DEAD_GRAVE = 0x80;
+ /** @since 1.2 */
+ public static final int VK_DEAD_ACUTE = 0x81;
+ /** @since 1.2 */
+ public static final int VK_DEAD_CIRCUMFLEX = 0x82;
+ /** @since 1.2 */
+ public static final int VK_DEAD_TILDE = 0x83;
+ /** @since 1.2 */
+ public static final int VK_DEAD_MACRON = 0x84;
+ /** @since 1.2 */
+ public static final int VK_DEAD_BREVE = 0x85;
+ /** @since 1.2 */
+ public static final int VK_DEAD_ABOVEDOT = 0x86;
+ /** @since 1.2 */
+ public static final int VK_DEAD_DIAERESIS = 0x87;
+ /** @since 1.2 */
+ public static final int VK_DEAD_ABOVERING = 0x88;
+ /** @since 1.2 */
+ public static final int VK_DEAD_DOUBLEACUTE = 0x89;
+ /** @since 1.2 */
+ public static final int VK_DEAD_CARON = 0x8a;
+ /** @since 1.2 */
+ public static final int VK_DEAD_CEDILLA = 0x8b;
+ /** @since 1.2 */
+ public static final int VK_DEAD_OGONEK = 0x8c;
+ /** @since 1.2 */
+ public static final int VK_DEAD_IOTA = 0x8d;
+ /** @since 1.2 */
+ public static final int VK_DEAD_VOICED_SOUND = 0x8e;
+ /** @since 1.2 */
+ public static final int VK_DEAD_SEMIVOICED_SOUND = 0x8f;
+
+ /** @since 1.2 */
+ public static final int VK_AMPERSAND = 0x96;
+ /** @since 1.2 */
+ public static final int VK_ASTERISK = 0x97;
+ /** @since 1.2 */
+ public static final int VK_QUOTEDBL = 0x98;
+ /** @since 1.2 */
+ public static final int VK_LESS = 0x99;
+
+ /** @since 1.2 */
+ public static final int VK_GREATER = 0xa0;
+ /** @since 1.2 */
+ public static final int VK_BRACELEFT = 0xa1;
+ /** @since 1.2 */
+ public static final int VK_BRACERIGHT = 0xa2;
+
+ /**
+ * Constant for the "@" key.
+ * @since 1.2
+ */
+ public static final int VK_AT = 0x0200;
+
+ /**
+ * Constant for the ":" key.
+ * @since 1.2
+ */
+ public static final int VK_COLON = 0x0201;
+
+ /**
+ * Constant for the "^" key.
+ * @since 1.2
+ */
+ public static final int VK_CIRCUMFLEX = 0x0202;
+
+ /**
+ * Constant for the "$" key.
+ * @since 1.2
+ */
+ public static final int VK_DOLLAR = 0x0203;
+
+ /**
+ * Constant for the Euro currency sign key.
+ * @since 1.2
+ */
+ public static final int VK_EURO_SIGN = 0x0204;
+
+ /**
+ * Constant for the "!" key.
+ * @since 1.2
+ */
+ public static final int VK_EXCLAMATION_MARK = 0x0205;
+
+ /**
+ * Constant for the inverted exclamation mark key.
+ * @since 1.2
+ */
+ public static final int VK_INVERTED_EXCLAMATION_MARK = 0x0206;
+
+ /**
+ * Constant for the "(" key.
+ * @since 1.2
+ */
+ public static final int VK_LEFT_PARENTHESIS = 0x0207;
+
+ /**
+ * Constant for the "#" key.
+ * @since 1.2
+ */
+ public static final int VK_NUMBER_SIGN = 0x0208;
+
+ /**
+ * Constant for the "+" key.
+ * @since 1.2
+ */
+ public static final int VK_PLUS = 0x0209;
+
+ /**
+ * Constant for the ")" key.
+ * @since 1.2
+ */
+ public static final int VK_RIGHT_PARENTHESIS = 0x020A;
+
+ /**
+ * Constant for the "_" key.
+ * @since 1.2
+ */
+ public static final int VK_UNDERSCORE = 0x020B;
+
+ /**
+ * Constant for the Microsoft Windows "Windows" key.
+ * It is used for both the left and right version of the key.
+ * @see #getKeyLocation()
+ * @since 1.5
+ */
+ public static final int VK_WINDOWS = 0x020C;
+
+ /**
+ * Constant for the Microsoft Windows Context Menu key.
+ * @since 1.5
+ */
+ public static final int VK_CONTEXT_MENU = 0x020D;
+
+ /* for input method support on Asian Keyboards */
+
+ /* not clear what this means - listed in Microsoft Windows API */
+ public static final int VK_FINAL = 0x0018;
+
+ /** Constant for the Convert function key. */
+ /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */
+ public static final int VK_CONVERT = 0x001C;
+
+ /** Constant for the Don't Convert function key. */
+ /* Japanese PC 106 keyboard: muhenkan */
+ public static final int VK_NONCONVERT = 0x001D;
+
+ /** Constant for the Accept or Commit function key. */
+ /* Japanese Solaris keyboard: kakutei */
+ public static final int VK_ACCEPT = 0x001E;
+
+ /* not clear what this means - listed in Microsoft Windows API */
+ public static final int VK_MODECHANGE = 0x001F;
+
+ /* replaced by VK_KANA_LOCK for Microsoft Windows and Solaris;
+ might still be used on other platforms */
+ public static final int VK_KANA = 0x0015;
+
+ /* replaced by VK_INPUT_METHOD_ON_OFF for Microsoft Windows and Solaris;
+ might still be used for other platforms */
+ public static final int VK_KANJI = 0x0019;
+
+ /**
+ * Constant for the Alphanumeric function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: eisuu */
+ public static final int VK_ALPHANUMERIC = 0x00F0;
+
+ /**
+ * Constant for the Katakana function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: katakana */
+ public static final int VK_KATAKANA = 0x00F1;
+
+ /**
+ * Constant for the Hiragana function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: hiragana */
+ public static final int VK_HIRAGANA = 0x00F2;
+
+ /**
+ * Constant for the Full-Width Characters function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: zenkaku */
+ public static final int VK_FULL_WIDTH = 0x00F3;
+
+ /**
+ * Constant for the Half-Width Characters function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: hankaku */
+ public static final int VK_HALF_WIDTH = 0x00F4;
+
+ /**
+ * Constant for the Roman Characters function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard: roumaji */
+ public static final int VK_ROMAN_CHARACTERS = 0x00F5;
+
+ /**
+ * Constant for the All Candidates function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */
+ public static final int VK_ALL_CANDIDATES = 0x0100;
+
+ /**
+ * Constant for the Previous Candidate function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */
+ public static final int VK_PREVIOUS_CANDIDATE = 0x0101;
+
+ /**
+ * Constant for the Code Input function key.
+ * @since 1.2
+ */
+ /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */
+ public static final int VK_CODE_INPUT = 0x0102;
+
+ /**
+ * Constant for the Japanese-Katakana function key.
+ * This key switches to a Japanese input method and selects its Katakana input mode.
+ * @since 1.2
+ */
+ /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */
+ public static final int VK_JAPANESE_KATAKANA = 0x0103;
+
+ /**
+ * Constant for the Japanese-Hiragana function key.
+ * This key switches to a Japanese input method and selects its Hiragana input mode.
+ * @since 1.2
+ */
+ /* Japanese Macintosh keyboard */
+ public static final int VK_JAPANESE_HIRAGANA = 0x0104;
+
+ /**
+ * Constant for the Japanese-Roman function key.
+ * This key switches to a Japanese input method and selects its Roman-Direct input mode.
+ * @since 1.2
+ */
+ /* Japanese Macintosh keyboard */
+ public static final int VK_JAPANESE_ROMAN = 0x0105;
+
+ /**
+ * Constant for the locking Kana function key.
+ * This key locks the keyboard into a Kana layout.
+ * @since 1.3
+ */
+ /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */
+ public static final int VK_KANA_LOCK = 0x0106;
+
+ /**
+ * Constant for the input method on/off key.
+ * @since 1.3
+ */
+ /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */
+ public static final int VK_INPUT_METHOD_ON_OFF = 0x0107;
+
+ /* for Sun keyboards */
+ /** @since 1.2 */
+ public static final int VK_CUT = 0xFFD1;
+ /** @since 1.2 */
+ public static final int VK_COPY = 0xFFCD;
+ /** @since 1.2 */
+ public static final int VK_PASTE = 0xFFCF;
+ /** @since 1.2 */
+ public static final int VK_UNDO = 0xFFCB;
+ /** @since 1.2 */
+ public static final int VK_AGAIN = 0xFFC9;
+ /** @since 1.2 */
+ public static final int VK_FIND = 0xFFD0;
+ /** @since 1.2 */
+ public static final int VK_PROPS = 0xFFCA;
+ /** @since 1.2 */
+ public static final int VK_STOP = 0xFFC8;
+
+ /**
+ * Constant for the Compose function key.
+ * @since 1.2
+ */
+ public static final int VK_COMPOSE = 0xFF20;
+
+ /**
+ * Constant for the AltGraph function key.
+ * @since 1.2
+ */
+ public static final int VK_ALT_GRAPH = 0xFF7E;
+
+ /**
+ * Constant for the Begin key.
+ * @since 1.5
+ */
+ public static final int VK_BEGIN = 0xFF58;
+
+ /**
+ * This value is used to indicate that the keyCode is unknown.
+ * KEY_TYPED events do not have a keyCode value; this value
+ * is used instead.
+ */
+ public static final int VK_UNDEFINED = 0x0;
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/KeyListener.java b/src/newt/classes/com/jogamp/newt/KeyListener.java
new file mode 100644
index 000000000..28e2b833b
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/KeyListener.java
@@ -0,0 +1,42 @@
+/*
+ * 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.jogamp.newt;
+
+public interface KeyListener extends EventListener
+{
+ public void keyPressed(KeyEvent e);
+ public void keyReleased(KeyEvent e);
+ public void keyTyped(KeyEvent e) ;
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/MouseEvent.java b/src/newt/classes/com/jogamp/newt/MouseEvent.java
new file mode 100644
index 000000000..d5412c0cc
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/MouseEvent.java
@@ -0,0 +1,110 @@
+/*
+ * 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.jogamp.newt;
+
+public class MouseEvent extends InputEvent
+{
+ public static final int BUTTON1 = 1;
+ public static final int BUTTON2 = 2;
+ public static final int BUTTON3 = 3;
+ public static final int BUTTON4 = 4;
+ public static final int BUTTON5 = 5;
+ public static final int BUTTON6 = 6;
+ public static final int BUTTON_NUMBER = 6;
+
+ protected MouseEvent(boolean sysEvent, int eventType, Window source, long when,
+ int modifiers, int x, int y, int clickCount, int button,
+ int rotation)
+ {
+ super(sysEvent, eventType, source, when, modifiers);
+ this.x=x;
+ this.y=y;
+ this.clickCount=clickCount;
+ this.button=button;
+ this.wheelRotation = rotation;
+ }
+ public MouseEvent(int eventType, Window source, long when, int modifiers,
+ int x, int y, int clickCount, int button, int rotation) {
+ this(false, eventType, source, when, modifiers, x, y, clickCount, button,
+ rotation);
+ }
+
+ public int getButton() {
+ return button;
+ }
+ public int getClickCount() {
+ return clickCount;
+ }
+ public int getX() {
+ return x;
+ }
+ public int getY() {
+ return y;
+ }
+ public int getWheelRotation() {
+ return wheelRotation;
+ }
+
+ public String toString() {
+ return "MouseEvent["+getEventTypeString(getEventType())+
+ ", "+x+"/"+y+", button "+button+", count "+clickCount+
+ ", wheel rotation "+wheelRotation+
+ ", "+super.toString()+"]";
+ }
+
+ public static String getEventTypeString(int type) {
+ switch(type) {
+ case EVENT_MOUSE_CLICKED: return "EVENT_MOUSE_CLICKED";
+ case EVENT_MOUSE_ENTERED: return "EVENT_MOUSE_ENTERED";
+ case EVENT_MOUSE_EXITED: return "EVENT_MOUSE_EXITED";
+ case EVENT_MOUSE_PRESSED: return "EVENT_MOUSE_PRESSED";
+ case EVENT_MOUSE_RELEASED: return "EVENT_MOUSE_RELEASED";
+ case EVENT_MOUSE_MOVED: return "EVENT_MOUSE_MOVED";
+ case EVENT_MOUSE_DRAGGED: return "EVENT_MOUSE_DRAGGED";
+ case EVENT_MOUSE_WHEEL_MOVED: return "EVENT_MOUSE_WHEEL_MOVED";
+ default: return "unknown (" + type + ")";
+ }
+ }
+
+ private int x, y, clickCount, button, wheelRotation;
+
+ public static final int EVENT_MOUSE_CLICKED = 200;
+ public static final int EVENT_MOUSE_ENTERED = 201;
+ public static final int EVENT_MOUSE_EXITED = 202;
+ public static final int EVENT_MOUSE_PRESSED = 203;
+ public static final int EVENT_MOUSE_RELEASED = 204;
+ public static final int EVENT_MOUSE_MOVED = 205;
+ public static final int EVENT_MOUSE_DRAGGED = 206;
+ public static final int EVENT_MOUSE_WHEEL_MOVED = 207;
+}
diff --git a/src/newt/classes/com/jogamp/newt/MouseListener.java b/src/newt/classes/com/jogamp/newt/MouseListener.java
new file mode 100644
index 000000000..6d931dd31
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/MouseListener.java
@@ -0,0 +1,47 @@
+/*
+ * 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.jogamp.newt;
+
+public interface MouseListener extends EventListener
+{
+ public void mouseClicked(MouseEvent e);
+ public void mouseEntered(MouseEvent e);
+ public void mouseExited(MouseEvent e);
+ public void mousePressed(MouseEvent e);
+ public void mouseReleased(MouseEvent e);
+ public void mouseMoved(MouseEvent e);
+ public void mouseDragged(MouseEvent e);
+ public void mouseWheelMoved(MouseEvent e);
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java
new file mode 100755
index 000000000..2a696aa07
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java
@@ -0,0 +1,181 @@
+/*
+ * 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.jogamp.newt;
+
+import javax.media.nativewindow.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import com.jogamp.nativewindow.impl.jvm.JVMUtil;
+
+public abstract class NewtFactory {
+ // Work-around for initialization order problems on Mac OS X
+ // between native Newt and (apparently) Fmod
+ static {
+ JVMUtil.initSingleton();
+ Window.init(NativeWindowFactory.getNativeWindowType(true));
+ }
+
+ static Class getCustomClass(String packageName, String classBaseName) {
+ Class clazz = null;
+ if(packageName!=null || classBaseName!=null) {
+ String clazzName = packageName + "." + classBaseName ;
+ try {
+ clazz = Class.forName(clazzName);
+ } catch (Throwable t) {}
+ }
+ return clazz;
+ }
+
+ private static boolean useEDT = true;
+
+ /**
+ * Toggles the usage of an EventDispatchThread while creating a Display.
+ * The default is enabled.
+ * The EventDispatchThread is thread local to the Display instance.
+ */
+ public static synchronized void setUseEDT(boolean onoff) {
+ useEDT = onoff;
+ }
+
+ /** @see #setUseEDT(boolean) */
+ public static boolean useEDT() { return useEDT; }
+
+ /**
+ * Create a Display entity, incl native creation
+ */
+ public static Display createDisplay(String name) {
+ return Display.create(NativeWindowFactory.getNativeWindowType(true), name);
+ }
+
+ /**
+ * Create a Display entity using the given implementation type, incl native creation
+ */
+ public static Display createDisplay(String type, String name) {
+ return Display.create(type, name);
+ }
+
+ /**
+ * Create a Screen entity, incl native creation
+ */
+ public static Screen createScreen(Display display, int index) {
+ return Screen.create(NativeWindowFactory.getNativeWindowType(true), display, index);
+ }
+
+ /**
+ * Create a Screen entity using the given implementation type, incl native creation
+ */
+ public static Screen createScreen(String type, Display display, int index) {
+ return Screen.create(type, display, index);
+ }
+
+ /**
+ * Create a Window entity, incl native creation
+ */
+ public static Window createWindow(Screen screen, Capabilities caps) {
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), 0, screen, caps, false);
+ }
+
+ public static Window createWindow(Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), 0, screen, caps, undecorated);
+ }
+
+ public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), parentWindowHandle, screen, caps, undecorated);
+ }
+
+ /**
+ * Ability to try a Window type with a construnctor argument, if supported .. AWTWindow(Frame frame)
,
+ * to support an external created AWT Frame, ie the browsers embedded frame.
+ */
+ public static Window createWindow(Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), cstrArguments, screen, caps, undecorated);
+ }
+
+ /**
+ * Create a Window entity using the given implementation type, incl native creation
+ */
+ public static Window createWindow(String type, Screen screen, Capabilities caps) {
+ return Window.create(type, 0, screen, caps, false);
+ }
+
+ public static Window createWindow(String type, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(type, 0, screen, caps, undecorated);
+ }
+
+ public static Window createWindow(String type, long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(type, parentWindowHandle, screen, caps, undecorated);
+ }
+
+ public static Window createWindow(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(type, cstrArguments, screen, caps, undecorated);
+ }
+
+ /**
+ * Instantiate a Display entity using the native handle.
+ */
+ public static Display wrapDisplay(String name, AbstractGraphicsDevice device) {
+ return Display.wrapHandle(NativeWindowFactory.getNativeWindowType(true), name, device);
+ }
+
+ /**
+ * Instantiate a Screen entity using the native handle.
+ */
+ public static Screen wrapScreen(Display display, AbstractGraphicsScreen screen) {
+ return Screen.wrapHandle(NativeWindowFactory.getNativeWindowType(true), display, screen);
+ }
+
+ /**
+ * Instantiate a Window entity using the native handle.
+ */
+ public static Window wrapWindow(Screen screen, AbstractGraphicsConfiguration config,
+ long windowHandle, boolean fullscreen, boolean visible,
+ int x, int y, int width, int height) {
+ return Window.wrapHandle(NativeWindowFactory.getNativeWindowType(true), screen, config,
+ windowHandle, fullscreen, visible, x, y, width, height);
+ }
+
+ private static final boolean instanceOf(Object obj, String clazzName) {
+ Class clazz = obj.getClass();
+ do {
+ if(clazz.getName().equals(clazzName)) {
+ return true;
+ }
+ clazz = clazz.getSuperclass();
+ } while (clazz!=null);
+ return false;
+ }
+
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/OffscreenWindow.java b/src/newt/classes/com/jogamp/newt/OffscreenWindow.java
new file mode 100644
index 000000000..c9c56fc61
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/OffscreenWindow.java
@@ -0,0 +1,108 @@
+/*
+ * 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.jogamp.newt;
+
+import javax.media.nativewindow.*;
+
+public class OffscreenWindow extends Window implements SurfaceChangeable {
+
+ long surfaceHandle = 0;
+
+ public OffscreenWindow() {
+ }
+
+ static long nextWindowHandle = 0x100; // start here - a marker
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ if(0!=parentWindowHandle) {
+ throw new NativeWindowException("OffscreenWindow does not support window parenting");
+ }
+ if(caps.isOnscreen()) {
+ throw new NativeWindowException("Capabilities is onscreen");
+ }
+ AbstractGraphicsScreen aScreen = screen.getGraphicsScreen();
+ config = GraphicsConfigurationFactory.getFactory(aScreen.getDevice()).chooseGraphicsConfiguration(caps, null, aScreen);
+ if (config == null) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+
+ synchronized(OffscreenWindow.class) {
+ windowHandle = nextWindowHandle++;
+ }
+ }
+
+ protected void closeNative() {
+ // nop
+ }
+
+ public void invalidate() {
+ super.invalidate();
+ surfaceHandle = 0;
+ }
+
+ public synchronized void destroy() {
+ surfaceHandle = 0;
+ }
+
+ public void setSurfaceHandle(long handle) {
+ surfaceHandle = handle ;
+ }
+
+ public long getSurfaceHandle() {
+ return surfaceHandle;
+ }
+
+ public void setVisible(boolean visible) {
+ if(!visible) {
+ this.visible = visible;
+ }
+ }
+
+ public void setSize(int width, int height) {
+ if(!visible) {
+ this.width = width;
+ this.height = height;
+ }
+ }
+
+ public void setPosition(int x, int y) {
+ // nop
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ // nop
+ return false;
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/PaintEvent.java b/src/newt/classes/com/jogamp/newt/PaintEvent.java
new file mode 100755
index 000000000..51c43725a
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/PaintEvent.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2009 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.jogamp.newt;
+
+/**
+ *
+ * @author tdv
+ */
+public class PaintEvent extends Event {
+
+ // bounds of the damage region
+ private int x, y, width, height;
+ public PaintEvent(int eventType, Window source,
+ long when, int x, int y, int w, int h)
+ {
+ super(true, eventType, source, when);
+ this.x = x;
+ this.y = y;
+ this.width = w;
+ this.height = h;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public int getX() {
+ return x;
+ }
+
+ public int getY() {
+ return y;
+ }
+
+ public String toString() {
+ return "ExposeEvent[modifiers: x="+x+" y="+y+" w="+width+" h="+height +"]";
+ }
+
+}
diff --git a/src/newt/classes/com/jogamp/newt/PaintListener.java b/src/newt/classes/com/jogamp/newt/PaintListener.java
new file mode 100755
index 000000000..6fbc9c8fc
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/PaintListener.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2009 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.jogamp.newt;
+
+/**
+ *
+ * @author tdv
+ */
+public interface PaintListener {
+ public void exposed(PaintEvent e);
+}
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java
new file mode 100755
index 000000000..b393d30de
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/Screen.java
@@ -0,0 +1,147 @@
+/*
+ * 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.jogamp.newt;
+
+import com.jogamp.newt.impl.*;
+
+import javax.media.nativewindow.*;
+import java.security.*;
+
+public abstract class Screen {
+
+ private static Class getScreenClass(String type)
+ throws ClassNotFoundException
+ {
+ Class screenClass = NewtFactory.getCustomClass(type, "Screen");
+ if(null==screenClass) {
+ if (NativeWindowFactory.TYPE_EGL.equals(type)) {
+ screenClass = Class.forName("com.jogamp.newt.opengl.kd.KDScreen");
+ } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
+ screenClass = Class.forName("com.jogamp.newt.windows.WindowsScreen");
+ } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
+ screenClass = Class.forName("com.jogamp.newt.macosx.MacScreen");
+ } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
+ screenClass = Class.forName("com.jogamp.newt.x11.X11Screen");
+ } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
+ screenClass = Class.forName("com.jogamp.newt.awt.AWTScreen");
+ } else {
+ throw new RuntimeException("Unknown window type \"" + type + "\"");
+ }
+ }
+ return screenClass;
+ }
+
+ protected static Screen create(String type, Display display, int idx) {
+ try {
+ if(usrWidth<0 || usrHeight<0) {
+ usrWidth = Debug.getIntProperty("newt.ws.swidth", true, localACC);
+ usrHeight = Debug.getIntProperty("newt.ws.sheight", true, localACC);
+ System.out.println("User screen size "+usrWidth+"x"+usrHeight);
+ }
+ Class screenClass = getScreenClass(type);
+ Screen screen = (Screen) screenClass.newInstance();
+ screen.display = display;
+ screen.createNative(idx);
+ if(null==screen.aScreen) {
+ throw new RuntimeException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen");
+ }
+ return screen;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public synchronized void destroy() {
+ closeNative();
+ display = null;
+ aScreen = null;
+ }
+
+ protected static Screen wrapHandle(String type, Display display, AbstractGraphicsScreen aScreen) {
+ try {
+ Class screenClass = getScreenClass(type);
+ Screen screen = (Screen) screenClass.newInstance();
+ screen.display = display;
+ screen.aScreen = aScreen;
+ return screen;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected abstract void createNative(int index);
+ protected abstract void closeNative();
+
+ protected void setScreenSize(int w, int h) {
+ System.out.println("Detected screen size "+w+"x"+h);
+ width=w; height=h;
+ }
+
+ public Display getDisplay() {
+ return display;
+ }
+
+ public int getIndex() {
+ return aScreen.getIndex();
+ }
+
+ public AbstractGraphicsScreen getGraphicsScreen() {
+ return aScreen;
+ }
+
+ /**
+ * The actual implementation shall return the detected display value,
+ * if not we return 800.
+ * This can be overwritten with the user property 'newt.ws.swidth',
+ */
+ public int getWidth() {
+ return (usrWidth>0) ? usrWidth : (width>0) ? width : 480;
+ }
+
+ /**
+ * The actual implementation shall return the detected display value,
+ * if not we return 480.
+ * This can be overwritten with the user property 'newt.ws.sheight',
+ */
+ public int getHeight() {
+ return (usrHeight>0) ? usrHeight : (height>0) ? height : 480;
+ }
+
+ protected Display display;
+ protected AbstractGraphicsScreen aScreen;
+ protected int width=-1, height=-1; // detected values: set using setScreenSize
+ protected static int usrWidth=-1, usrHeight=-1; // property values: newt.ws.swidth and newt.ws.sheight
+ private static AccessControlContext localACC = AccessController.getContext();
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
new file mode 100755
index 000000000..410144653
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -0,0 +1,929 @@
+/*
+ * 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.jogamp.newt;
+
+import com.jogamp.newt.impl.Debug;
+import com.jogamp.newt.util.EventDispatchThread;
+
+import javax.media.nativewindow.*;
+import com.jogamp.nativewindow.impl.NWReflection;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.lang.reflect.Method;
+
+public abstract class Window implements NativeWindow
+{
+ public static final boolean DEBUG_MOUSE_EVENT = Debug.debug("Window.MouseEvent");
+ public static final boolean DEBUG_KEY_EVENT = Debug.debug("Window.KeyEvent");
+ public static final boolean DEBUG_WINDOW_EVENT = Debug.debug("Window.WindowEvent");
+ public static final boolean DEBUG_IMPLEMENTATION = Debug.debug("Window");
+
+ // Workaround for initialization order problems on Mac OS X
+ // between native Newt and (apparently) Fmod -- if Fmod is
+ // initialized first then the connection to the window server
+ // breaks, leading to errors from deep within the AppKit
+ static void init(String type) {
+ if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
+ try {
+ getWindowClass(type);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private static Class getWindowClass(String type)
+ throws ClassNotFoundException
+ {
+ Class windowClass = NewtFactory.getCustomClass(type, "Window");
+ if(null==windowClass) {
+ if (NativeWindowFactory.TYPE_EGL.equals(type)) {
+ windowClass = Class.forName("com.jogamp.newt.opengl.kd.KDWindow");
+ } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
+ windowClass = Class.forName("com.jogamp.newt.windows.WindowsWindow");
+ } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) {
+ windowClass = Class.forName("com.jogamp.newt.macosx.MacWindow");
+ } else if (NativeWindowFactory.TYPE_X11.equals(type)) {
+ windowClass = Class.forName("com.jogamp.newt.x11.X11Window");
+ } else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
+ windowClass = Class.forName("com.jogamp.newt.awt.AWTWindow");
+ } else {
+ throw new NativeWindowException("Unknown window type \"" + type + "\"");
+ }
+ }
+ return windowClass;
+ }
+
+ protected static Window create(String type, final long parentWindowHandle, Screen screen, final Capabilities caps, boolean undecorated) {
+ try {
+ Class windowClass;
+ if(caps.isOnscreen()) {
+ windowClass = getWindowClass(type);
+ } else {
+ windowClass = OffscreenWindow.class;
+ }
+ Window window = (Window) windowClass.newInstance();
+ window.invalidate();
+ window.screen = screen;
+ window.setUndecorated(undecorated||0!=parentWindowHandle);
+ EventDispatchThread edt = screen.getDisplay().getEDT();
+ if(null!=edt) {
+ final Window f_win = window;
+ edt.invokeAndWait(new Runnable() {
+ public void run() {
+ f_win.createNative(parentWindowHandle, caps);
+ }
+ } );
+ } else {
+ window.createNative(parentWindowHandle, caps);
+ }
+ return window;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new NativeWindowException(t);
+ }
+ }
+
+ protected static Window create(String type, Object[] cstrArguments, Screen screen, final Capabilities caps, boolean undecorated) {
+ try {
+ Class windowClass = getWindowClass(type);
+ Class[] cstrArgumentTypes = getCustomConstructorArgumentTypes(windowClass);
+ if(null==cstrArgumentTypes) {
+ throw new NativeWindowException("WindowClass "+windowClass+" doesn't support custom arguments in constructor");
+ }
+ int argsChecked = verifyConstructorArgumentTypes(cstrArgumentTypes, cstrArguments);
+ if ( argsChecked < cstrArguments.length ) {
+ throw new NativeWindowException("WindowClass "+windowClass+" constructor mismatch at argument #"+argsChecked+"; Constructor: "+getTypeStrList(cstrArgumentTypes)+", arguments: "+getArgsStrList(cstrArguments));
+ }
+ Window window = (Window) NWReflection.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ;
+ window.invalidate();
+ window.screen = screen;
+ window.setUndecorated(undecorated);
+ EventDispatchThread edt = screen.getDisplay().getEDT();
+ if(null!=edt) {
+ final Window f_win = window;
+ edt.invokeAndWait(new Runnable() {
+ public void run() {
+ f_win.createNative(0, caps);
+ }
+ } );
+ } else {
+ window.createNative(0, caps);
+ }
+ return window;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new NativeWindowException(t);
+ }
+ }
+
+ protected static Window wrapHandle(String type, Screen screen, AbstractGraphicsConfiguration config,
+ long windowHandle, boolean fullscreen, boolean visible,
+ int x, int y, int width, int height)
+ {
+ try {
+ Class windowClass = getWindowClass(type);
+ Window window = (Window) windowClass.newInstance();
+ window.invalidate();
+ window.screen = screen;
+ window.config = config;
+ window.windowHandle = windowHandle;
+ window.fullscreen=fullscreen;
+ window.visible=visible;
+ window.x=x;
+ window.y=y;
+ window.width=width;
+ window.height=height;
+ return window;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new NativeWindowException(t);
+ }
+ }
+
+ public static String toHexString(int hex) {
+ return "0x" + Integer.toHexString(hex);
+ }
+
+ public static String toHexString(long hex) {
+ return "0x" + Long.toHexString(hex);
+ }
+
+ protected Screen screen;
+
+ protected AbstractGraphicsConfiguration config;
+ protected long windowHandle;
+ protected boolean fullscreen, visible;
+ protected int width, height, x, y;
+ protected int eventMask;
+
+ protected String title = "Newt Window";
+ protected boolean undecorated = false;
+
+ /**
+ * Create native windowHandle, ie creates a new native invisible window.
+ *
+ * The parentWindowHandle may be null, in which case no window parenting
+ * is requested.
+ *
+ * Shall use the capabilities to determine the graphics configuration
+ * and shall set the chosen capabilities.
+ */
+ protected abstract void createNative(long parentWindowHandle, Capabilities caps);
+
+ protected abstract void closeNative();
+
+ public Screen getScreen() {
+ return screen;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append(getClass().getName()+"[config "+config+
+ ", windowHandle "+toHexString(getWindowHandle())+
+ ", surfaceHandle "+toHexString(getSurfaceHandle())+
+ ", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
+ ", visible "+isVisible()+
+ ", undecorated "+undecorated+
+ ", fullscreen "+fullscreen+
+ ", "+screen+
+ ", wrappedWindow "+getWrappedWindow());
+
+ sb.append(", SurfaceUpdatedListeners num "+surfaceUpdatedListeners.size()+" [");
+ for (Iterator iter = surfaceUpdatedListeners.iterator(); iter.hasNext(); ) {
+ sb.append(iter.next()+", ");
+ }
+ sb.append("], WindowListeners num "+windowListeners.size()+" [");
+ for (Iterator iter = windowListeners.iterator(); iter.hasNext(); ) {
+ sb.append(iter.next()+", ");
+ }
+ sb.append("], MouseListeners num "+mouseListeners.size()+" [");
+ for (Iterator iter = mouseListeners.iterator(); iter.hasNext(); ) {
+ sb.append(iter.next()+", ");
+ }
+ sb.append("], KeyListeners num "+keyListeners.size()+" [");
+ for (Iterator iter = keyListeners.iterator(); iter.hasNext(); ) {
+ sb.append(iter.next()+", ");
+ }
+ sb.append("] ]");
+ return sb.toString();
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public void setUndecorated(boolean value) {
+ undecorated = value;
+ }
+
+ public boolean isUndecorated() {
+ return undecorated;
+ }
+
+ public void requestFocus() {
+ }
+
+ //
+ // NativeWindow impl
+ //
+ private Thread owner;
+ private int recursionCount;
+ protected Exception lockedStack = null;
+
+ /** Recursive and blocking lockSurface() implementation */
+ public synchronized int lockSurface() {
+ // We leave the ToolkitLock lock to the specializtion's discretion,
+ // ie the implicit JAWTWindow in case of AWTWindow
+ Thread cur = Thread.currentThread();
+ if (owner == cur) {
+ ++recursionCount;
+ return LOCK_SUCCESS;
+ }
+ while (owner != null) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ owner = cur;
+ lockedStack = new Exception("NEWT Surface previously locked by "+Thread.currentThread());
+ screen.getDisplay().lockDisplay();
+ return LOCK_SUCCESS;
+ }
+
+ /** Recursive and unblocking unlockSurface() implementation */
+ public synchronized void unlockSurface() throws NativeWindowException {
+ Thread cur = Thread.currentThread();
+ if (owner != cur) {
+ lockedStack.printStackTrace();
+ throw new NativeWindowException(cur+": Not owner, owner is "+owner);
+ }
+ if (recursionCount > 0) {
+ --recursionCount;
+ return;
+ }
+ owner = null;
+ lockedStack = null;
+ screen.getDisplay().unlockDisplay();
+ notifyAll();
+ // We leave the ToolkitLock unlock to the specializtion's discretion,
+ // ie the implicit JAWTWindow in case of AWTWindow
+ }
+
+ public synchronized boolean isSurfaceLocked() {
+ return null!=owner;
+ }
+
+ public synchronized Thread getSurfaceLockOwner() {
+ return owner;
+ }
+
+ public synchronized Exception getLockedStack() {
+ return lockedStack;
+ }
+
+ public synchronized void destroy() {
+ destroy(false);
+ }
+
+ /** @param deep If true, the linked Screen and Display will be destroyed as well. */
+ public synchronized void destroy(boolean deep) {
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.destroy() start (deep "+deep+" - "+Thread.currentThread());
+ }
+ synchronized(surfaceUpdatedListeners) {
+ surfaceUpdatedListeners = new ArrayList();
+ }
+ synchronized(windowListeners) {
+ windowListeners = new ArrayList();
+ }
+ synchronized(mouseListeners) {
+ mouseListeners = new ArrayList();
+ }
+ synchronized(keyListeners) {
+ keyListeners = new ArrayList();
+ }
+ Screen scr = screen;
+ Display dpy = (null!=screen) ? screen.getDisplay() : null;
+ EventDispatchThread edt = (null!=dpy) ? dpy.getEDT() : null;
+ if(null!=edt) {
+ final Window f_win = this;
+ edt.invokeAndWait(new Runnable() {
+ public void run() {
+ f_win.closeNative();
+ }
+ } );
+ } else {
+ closeNative();
+ }
+ invalidate();
+ if(deep) {
+ if(null!=scr) {
+ scr.destroy();
+ }
+ if(null!=dpy) {
+ dpy.destroy();
+ }
+ }
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.destroy() end "+Thread.currentThread());
+ }
+ }
+
+ public void invalidate() {
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ Exception e = new Exception("!!! Window Invalidate "+Thread.currentThread());
+ e.printStackTrace();
+ }
+ screen = null;
+ windowHandle = 0;
+ fullscreen=false;
+ visible=false;
+ eventMask = 0;
+
+ // Default position and dimension will be re-set immediately by user
+ width = 100;
+ height = 100;
+ x=0;
+ y=0;
+ }
+
+ public boolean surfaceSwap() {
+ return false;
+ }
+
+ protected void clearEventMask() {
+ eventMask=0;
+ }
+
+ public long getDisplayHandle() {
+ return screen.getDisplay().getHandle();
+ }
+
+ public int getScreenIndex() {
+ return screen.getIndex();
+ }
+
+ public long getWindowHandle() {
+ return windowHandle;
+ }
+
+ public long getSurfaceHandle() {
+ return windowHandle; // default: return window handle
+ }
+
+ public AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ return config;
+ }
+
+ /**
+ * Returns the width of the client area of this window
+ * @return width of the client area
+ */
+ public int getWidth() {
+ return width;
+ }
+
+ /**
+ * Returns the height of the client area of this window
+ * @return height of the client area
+ */
+ public int getHeight() {
+ return height;
+ }
+
+ /**
+ * Returns the insets for this native window (the difference between the
+ * size of the toplevel window with the decorations and the client area).
+ *
+ * @return insets for this platform window
+ */
+ // this probably belongs to NativeWindow interface
+ public Insets getInsets() {
+ return new Insets(0,0,0,0);
+ }
+
+ /** If this Window actually wraps one from another toolkit such as
+ the AWT, this will return a non-null value. */
+ public Object getWrappedWindow() {
+ return null;
+ }
+
+ //
+ // Additional methods
+ //
+
+ public int getX() {
+ return x;
+ }
+
+ public int getY() {
+ return y;
+ }
+
+ public boolean isVisible() {
+ return visible;
+ }
+
+ public boolean isFullscreen() {
+ return fullscreen;
+ }
+
+ private boolean autoDrawableMember = false;
+
+ /** If the implementation is capable of detecting a device change
+ return true and clear the status/reason of the change. */
+ public boolean hasDeviceChanged() {
+ return false;
+ }
+
+ /**
+ * If set to true,
+ * certain action will be performed by the owning
+ * AutoDrawable, ie the destroy() call within windowDestroyNotify()
+ */
+ public void setAutoDrawableClient(boolean b) {
+ autoDrawableMember = b;
+ }
+
+ protected void windowDestroyNotify() {
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.windowDestroyeNotify start "+Thread.currentThread());
+ }
+
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY);
+
+ if(!autoDrawableMember) {
+ destroy();
+ }
+
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.windowDestroyeNotify end "+Thread.currentThread());
+ }
+ }
+
+ protected void windowDestroyed() {
+ if(DEBUG_WINDOW_EVENT) {
+ System.out.println("Window.windowDestroyed "+Thread.currentThread());
+ }
+ invalidate();
+ }
+
+ public abstract void setVisible(boolean visible);
+ /**
+ * Sets the size of the client area of the window, excluding decorations
+ * Total size of the window will be
+ * {@code width+insets.left+insets.right, height+insets.top+insets.bottom}
+ * @param width of the client area of the window
+ * @param height of the client area of the window
+ */
+ public abstract void setSize(int width, int height);
+ /**
+ * Sets the location of the top left corner of the window, including
+ * decorations (so the client area will be placed at
+ * {@code x+insets.left,y+insets.top}.
+ * @param x coord of the top left corner
+ * @param y coord of the top left corner
+ */
+ public abstract void setPosition(int x, int y);
+ public abstract boolean setFullscreen(boolean fullscreen);
+
+ //
+ // SurfaceUpdatedListener Support
+ //
+ private ArrayList surfaceUpdatedListeners = new ArrayList();
+
+ public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ if(l == null) {
+ return;
+ }
+ synchronized(surfaceUpdatedListeners) {
+ ArrayList newSurfaceUpdatedListeners = (ArrayList) surfaceUpdatedListeners.clone();
+ newSurfaceUpdatedListeners.add(l);
+ surfaceUpdatedListeners = newSurfaceUpdatedListeners;
+ }
+ }
+
+ public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ if (l == null) {
+ return;
+ }
+ synchronized(surfaceUpdatedListeners) {
+ ArrayList newSurfaceUpdatedListeners = (ArrayList) surfaceUpdatedListeners.clone();
+ newSurfaceUpdatedListeners.remove(l);
+ surfaceUpdatedListeners = newSurfaceUpdatedListeners;
+ }
+ }
+
+ public SurfaceUpdatedListener[] getSurfaceUpdatedListener() {
+ synchronized(surfaceUpdatedListeners) {
+ return (SurfaceUpdatedListener[]) surfaceUpdatedListeners.toArray();
+ }
+ }
+
+ public void surfaceUpdated(Object updater, NativeWindow window, long when) {
+ ArrayList listeners = null;
+ synchronized(surfaceUpdatedListeners) {
+ listeners = surfaceUpdatedListeners;
+ }
+ for(Iterator i = listeners.iterator(); i.hasNext(); ) {
+ SurfaceUpdatedListener l = (SurfaceUpdatedListener) i.next();
+ l.surfaceUpdated(updater, window, when);
+ }
+ }
+
+ //
+ // MouseListener Support
+ //
+
+ public void addMouseListener(MouseListener l) {
+ if(l == null) {
+ return;
+ }
+ synchronized(mouseListeners) {
+ ArrayList newMouseListeners = (ArrayList) mouseListeners.clone();
+ newMouseListeners.add(l);
+ mouseListeners = newMouseListeners;
+ }
+ }
+
+ public void removeMouseListener(MouseListener l) {
+ if (l == null) {
+ return;
+ }
+ synchronized(mouseListeners) {
+ ArrayList newMouseListeners = (ArrayList) mouseListeners.clone();
+ newMouseListeners.remove(l);
+ mouseListeners = newMouseListeners;
+ }
+ }
+
+ public MouseListener[] getMouseListeners() {
+ synchronized(mouseListeners) {
+ return (MouseListener[]) mouseListeners.toArray();
+ }
+ }
+
+ private ArrayList mouseListeners = new ArrayList();
+ private int mouseButtonPressed = 0; // current pressed mouse button number
+ private long lastMousePressed = 0; // last time when a mouse button was pressed
+ private int lastMouseClickCount = 0; // last mouse button click count
+ public static final int ClickTimeout = 300;
+
+ protected void sendMouseEvent(int eventType, int modifiers,
+ int x, int y, int button, int rotation) {
+ if(x<0||y<0||x>=width||y>=height) {
+ return; // .. invalid ..
+ }
+ if(DEBUG_MOUSE_EVENT) {
+ System.out.println("sendMouseEvent: "+MouseEvent.getEventTypeString(eventType)+
+ ", mod "+modifiers+", pos "+x+"/"+y+", button "+button);
+ }
+ if(button<0||button>MouseEvent.BUTTON_NUMBER) {
+ throw new NativeWindowException("Invalid mouse button number" + button);
+ }
+ long when = System.currentTimeMillis();
+ MouseEvent eClicked = null;
+ MouseEvent e = null;
+
+ if(MouseEvent.EVENT_MOUSE_PRESSED==eventType) {
+ if(when-lastMousePressed
+ * before calling the various input EventListener callbacks (MouseListener, KeyListener,
+ * etc.).
+ * This design decision is made to favor a more performant and simplified
+ * implementation, as well as the event dispatcher shall be allowed
+ * not having a notion about OpenGL.
+ *
+ * Enable or disables running the {@link Display#pumpMessages} in the {@link #display()} call.
+ * The default behavior is to run {@link Display#pumpMessages}.
+ * This could not have been verified. No measurable difference could have been recognized.
+ *
+ * Enabling local pump messages while using the EDT,
+ * {@link com.jogamp.newt.NewtFactory#setUseEDT(boolean)},
+ * will result in an exception.
+ *
+ * @deprecated EXPERIMENTAL, semantic is about to be removed after further verification.
+ */
+ public void setRunPumpMessages(boolean onoff) {
+ if( onoff && null!=getScreen().getDisplay().getEDT() ) {
+ throw new GLException("GLWindow.setRunPumpMessages(true) - Can't do with EDT on");
+ }
+ runPumpMessages = onoff;
+ }
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ shouldNotCallThis();
+ }
+
+ protected void closeNative() {
+ shouldNotCallThis();
+ }
+
+ protected void dispose(boolean regenerate, boolean sendEvent) {
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ Exception e1 = new Exception("GLWindow.dispose("+regenerate+") "+Thread.currentThread()+", 1");
+ e1.printStackTrace();
+ }
+
+ if(sendEvent) {
+ sendDisposeEvent();
+ }
+
+ if (context != null) {
+ context.destroy();
+ }
+ if (drawable != null) {
+ drawable.setRealized(false);
+ }
+
+ if(regenerate) {
+ if(null==window) {
+ throw new GLException("GLWindow.dispose(true): null window");
+ }
+
+ // recreate GLDrawable, to reflect the new graphics configurations
+ NativeWindow nw;
+ if (window.getWrappedWindow() != null) {
+ nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
+ } else {
+ nw = window;
+ }
+ drawable = factory.createGLDrawable(nw);
+ drawable.setRealized(true);
+ context = drawable.createContext(null);
+ sendReshape = true; // ensure a reshape event is send ..
+ }
+
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ System.out.println("GLWindow.dispose("+regenerate+") "+Thread.currentThread()+", fin: "+this);
+ }
+ }
+
+ public synchronized void destroy() {
+ destroy(true);
+ }
+
+ /** @param sendDisposeEvent should be false in a [time,reliable] critical shutdown */
+ public synchronized void destroy(boolean sendDisposeEvent) {
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ Exception e1 = new Exception("GLWindow.destroy "+Thread.currentThread()+", 1: "+this);
+ e1.printStackTrace();
+ }
+
+ List newglw = (List) ((ArrayList) glwindows).clone();
+ newglw.remove(this);
+ glwindows=newglw;
+
+ dispose(false, sendDisposeEvent);
+
+ if(null!=window) {
+ if(ownerOfWinScrDpy) {
+ window.destroy(true);
+ }
+ }
+
+ drawable = null;
+ context = null;
+ window = null;
+
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ System.out.println("GLWindow.destroy "+Thread.currentThread()+", fin: "+this);
+ }
+ }
+
+ public boolean getPerfLogEnabled() { return perfLog; }
+
+ public void enablePerfLog(boolean v) {
+ perfLog = v;
+ }
+
+ public void setVisible(boolean visible) {
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ System.out.println(Thread.currentThread()+" GLWindow.setVisible("+visible+") START ; isVisible "+this.visible+" ; has context "+(null!=context));
+ }
+ this.visible=visible;
+ window.setVisible(visible);
+ if (visible && context == null) {
+ NativeWindow nw;
+ if (window.getWrappedWindow() != null) {
+ nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
+ } else {
+ nw = window;
+ }
+ GLCapabilities glCaps = (GLCapabilities) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
+ drawable = factory.createGLDrawable(nw);
+ drawable.setRealized(true);
+ context = drawable.createContext(null);
+ sendReshape = true; // ensure a reshape event is send ..
+ }
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ System.out.println(Thread.currentThread()+" GLWindow.setVisible("+visible+") END ; has context "+(null!=context));
+ }
+ }
+
+ public Screen getScreen() {
+ return window.getScreen();
+ }
+
+ public void setTitle(String title) {
+ window.setTitle(title);
+ }
+
+ public String getTitle() {
+ return window.getTitle();
+ }
+
+ public void setUndecorated(boolean value) {
+ window.setUndecorated(value);
+ }
+
+ public boolean isUndecorated() {
+ return window.isUndecorated();
+ }
+
+ public void setSize(int width, int height) {
+ window.setSize(width, height);
+ }
+
+ public void setPosition(int x, int y) {
+ window.setPosition(x, y);
+ }
+
+ public Insets getInsets() {
+ return window.getInsets();
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ return window.setFullscreen(fullscreen);
+ }
+
+ public boolean isVisible() {
+ return window.isVisible();
+ }
+
+ public int getX() {
+ return window.getX();
+ }
+
+ public int getY() {
+ return window.getY();
+ }
+
+ public int getWidth() {
+ return window.getWidth();
+ }
+
+ public int getHeight() {
+ return window.getHeight();
+ }
+
+ public boolean isFullscreen() {
+ return window.isFullscreen();
+ }
+
+ public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ window.addSurfaceUpdatedListener(l);
+ }
+ public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) {
+ window.removeSurfaceUpdatedListener(l);
+ }
+ public SurfaceUpdatedListener[] getSurfaceUpdatedListener() {
+ return window.getSurfaceUpdatedListener();
+ }
+ public void surfaceUpdated(Object updater, NativeWindow window0, long when) {
+ window.surfaceUpdated(updater, window, when);
+ }
+
+ public void addMouseListener(MouseListener l) {
+ window.addMouseListener(l);
+ }
+
+ public void removeMouseListener(MouseListener l) {
+ window.removeMouseListener(l);
+ }
+
+ public MouseListener[] getMouseListeners() {
+ return window.getMouseListeners();
+ }
+
+ public void addKeyListener(KeyListener l) {
+ window.addKeyListener(l);
+ }
+
+ public void removeKeyListener(KeyListener l) {
+ window.removeKeyListener(l);
+ }
+
+ public KeyListener[] getKeyListeners() {
+ return window.getKeyListeners();
+ }
+
+ public void addWindowListener(WindowListener l) {
+ window.addWindowListener(l);
+ }
+
+ public void removeWindowListener(WindowListener l) {
+ window.removeWindowListener(l);
+ }
+
+ public WindowListener[] getWindowListeners() {
+ return window.getWindowListeners();
+ }
+
+ public String toString() {
+ return "NEWT-GLWindow[ \n\tDrawable: "+drawable+", \n\tWindow: "+window+", \n\tHelper: "+helper+", \n\tFactory: "+factory+"]";
+ }
+
+ //----------------------------------------------------------------------
+ // OpenGL-related methods and state
+ //
+
+ private GLDrawableFactory factory;
+ private GLDrawable drawable;
+ private GLContext context;
+ private GLDrawableHelper helper = new GLDrawableHelper();
+ // To make reshape events be sent immediately before a display event
+ private boolean sendReshape=false;
+ private boolean sendDestroy=false;
+ private boolean perfLog = false;
+
+ public GLDrawableFactory getFactory() {
+ return factory;
+ }
+
+ public void setContext(GLContext newCtx) {
+ context = newCtx;
+ }
+
+ public GLContext getContext() {
+ return context;
+ }
+
+ public GL getGL() {
+ if (context == null) {
+ return null;
+ }
+ return context.getGL();
+ }
+
+ public GL setGL(GL gl) {
+ if (context != null) {
+ context.setGL(gl);
+ return gl;
+ }
+ return null;
+ }
+
+ public void addGLEventListener(GLEventListener listener) {
+ helper.addGLEventListener(listener);
+ }
+
+ public void removeGLEventListener(GLEventListener listener) {
+ helper.removeGLEventListener(listener);
+ }
+
+ public void display() {
+ display(false);
+ }
+
+ public void display(boolean forceReshape) {
+ if(window!=null && drawable!=null && context != null) {
+ if(runPumpMessages) {
+ window.getScreen().getDisplay().pumpMessages();
+ }
+ if(window.hasDeviceChanged() && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED) {
+ dispose(true, true);
+ }
+ if (sendDestroy) {
+ destroy();
+ sendDestroy=false;
+ } else {
+ if(forceReshape) {
+ sendReshape = true;
+ }
+ helper.invokeGL(drawable, context, displayAction, initAction);
+ }
+ }
+ }
+
+ private void sendDisposeEvent() {
+ if(drawable!=null && context != null) {
+ helper.invokeGL(drawable, context, disposeAction, null);
+ }
+ }
+
+ /** This implementation uses a static value */
+ public void setAutoSwapBufferMode(boolean onOrOff) {
+ helper.setAutoSwapBufferMode(onOrOff);
+ }
+
+ /** This implementation uses a static value */
+ public boolean getAutoSwapBufferMode() {
+ return helper.getAutoSwapBufferMode();
+ }
+
+ public void swapBuffers() {
+ if(drawable!=null && context != null) {
+ if (context != GLContext.getCurrent()) {
+ // Assume we should try to make the context current before swapping the buffers
+ helper.invokeGL(drawable, context, swapBuffersAction, initAction);
+ } else {
+ drawable.swapBuffers();
+ }
+ }
+ }
+
+ class InitAction implements Runnable {
+ public void run() {
+ helper.init(GLWindow.this);
+ startTime = System.currentTimeMillis();
+ curTime = startTime;
+ if(perfLog) {
+ lastCheck = startTime;
+ totalFrames = 0; lastFrames = 0;
+ }
+ }
+ }
+ private InitAction initAction = new InitAction();
+
+ class DisposeAction implements Runnable {
+ public void run() {
+ helper.dispose(GLWindow.this);
+ }
+ }
+ private DisposeAction disposeAction = new DisposeAction();
+
+ class DisplayAction implements Runnable {
+ public void run() {
+ if (sendReshape) {
+ int width = getWidth();
+ int height = getHeight();
+ getGL().glViewport(0, 0, width, height);
+ helper.reshape(GLWindow.this, 0, 0, width, height);
+ sendReshape = false;
+ }
+
+ helper.display(GLWindow.this);
+
+ curTime = System.currentTimeMillis();
+ totalFrames++;
+
+ if(perfLog) {
+ long dt0, dt1;
+ lastFrames++;
+ dt0 = curTime-lastCheck;
+ if ( dt0 > 5000 ) {
+ dt1 = curTime-startTime;
+ System.out.println(dt0/1000 +"s: "+ lastFrames + "f, " + (lastFrames*1000)/dt0 + " fps, "+dt0/lastFrames+" ms/f; "+
+ "total: "+ dt1/1000+"s, "+(totalFrames*1000)/dt1 + " fps, "+dt1/totalFrames+" ms/f");
+ lastCheck=curTime;
+ lastFrames=0;
+ }
+ }
+ }
+ }
+ private DisplayAction displayAction = new DisplayAction();
+
+ public long getStartTime() { return startTime; }
+ public long getCurrentTime() { return curTime; }
+ public long getDuration() { return curTime-startTime; }
+ public int getTotalFrames() { return totalFrames; }
+
+ private long startTime = 0;
+ private long curTime = 0;
+ private long lastCheck = 0;
+ private int totalFrames = 0, lastFrames = 0;
+
+ class SwapBuffersAction implements Runnable {
+ public void run() {
+ drawable.swapBuffers();
+ }
+ }
+ private SwapBuffersAction swapBuffersAction = new SwapBuffersAction();
+
+ //----------------------------------------------------------------------
+ // GLDrawable methods
+ //
+
+ public NativeWindow getNativeWindow() {
+ return null!=drawable ? drawable.getNativeWindow() : null;
+ }
+
+ public synchronized int lockSurface() throws NativeWindowException {
+ if(null!=drawable) return drawable.getNativeWindow().lockSurface();
+ return NativeWindow.LOCK_SURFACE_NOT_READY;
+ }
+
+ public synchronized void unlockSurface() {
+ if(null!=drawable) drawable.getNativeWindow().unlockSurface();
+ else throw new NativeWindowException("NEWT-GLWindow not locked");
+ }
+
+ public synchronized boolean isSurfaceLocked() {
+ if(null!=drawable) return drawable.getNativeWindow().isSurfaceLocked();
+ return false;
+ }
+
+ public synchronized Exception getLockedStack() {
+ if(null!=drawable) return drawable.getNativeWindow().getLockedStack();
+ return null;
+ }
+
+ public boolean surfaceSwap() {
+ if(null!=drawable) return drawable.getNativeWindow().surfaceSwap();
+ return super.surfaceSwap();
+ }
+
+ public long getWindowHandle() {
+ if(null!=drawable) return drawable.getNativeWindow().getWindowHandle();
+ return super.getWindowHandle();
+ }
+
+ public long getSurfaceHandle() {
+ if(null!=drawable) return drawable.getNativeWindow().getSurfaceHandle();
+ return super.getSurfaceHandle();
+ }
+
+ //----------------------------------------------------------------------
+ // GLDrawable methods that are not really needed
+ //
+
+ public GLContext createContext(GLContext shareWith) {
+ return drawable.createContext(shareWith);
+ }
+
+ public void setRealized(boolean realized) {
+ }
+
+ public GLCapabilities getChosenGLCapabilities() {
+ if (drawable == null) {
+ throw new GLException("No drawable yet");
+ }
+
+ return drawable.getChosenGLCapabilities();
+ }
+
+ public GLProfile getGLProfile() {
+ if (drawable == null) {
+ throw new GLException("No drawable yet");
+ }
+
+ return drawable.getGLProfile();
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only below this point
+ //
+
+ private void shouldNotCallThis() {
+ throw new NativeWindowException("Should not call this");
+ }
+}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java
new file mode 100644
index 000000000..a375181ac
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Display.java
@@ -0,0 +1,81 @@
+/*
+ * 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.jogamp.newt.opengl.broadcom.egl;
+
+import com.jogamp.newt.impl.*;
+import com.jogamp.opengl.impl.egl.*;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.egl.*;
+
+public class Display extends com.jogamp.newt.Display {
+
+ static {
+ NativeLibLoader.loadNEWT();
+
+ if (!Window.initIDs()) {
+ throw new NativeWindowException("Failed to initialize BCEGL Window jmethodIDs");
+ }
+ }
+
+ public static void initSingleton() {
+ // just exist to ensure static init has been run
+ }
+
+
+ public Display() {
+ }
+
+ protected void createNative() {
+ long handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight);
+ if (handle == EGL.EGL_NO_DISPLAY) {
+ throw new NativeWindowException("BC EGL CreateDisplay failed");
+ }
+ aDevice = new EGLGraphicsDevice(handle);
+ }
+
+ protected void closeNative() {
+ if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) {
+ DestroyDisplay(aDevice.getHandle());
+ }
+ }
+
+ protected void dispatchMessages() {
+ // n/a .. DispatchMessages();
+ }
+
+ private native long CreateDisplay(int width, int height);
+ private native void DestroyDisplay(long dpy);
+ private native void DispatchMessages();
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Screen.java b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Screen.java
new file mode 100755
index 000000000..b4f07599b
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Screen.java
@@ -0,0 +1,62 @@
+/*
+ * 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.jogamp.newt.opengl.broadcom.egl;
+
+import javax.media.nativewindow.*;
+
+public class Screen extends com.jogamp.newt.Screen {
+
+ static {
+ Display.initSingleton();
+ }
+
+
+ public Screen() {
+ }
+
+ protected void createNative(int index) {
+ aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
+ setScreenSize(fixedWidth, fixedHeight);
+ }
+
+ protected void closeNative() { }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ static final int fixedWidth = 1920;
+ static final int fixedHeight = 1080;
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Window.java b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Window.java
new file mode 100755
index 000000000..185dc97b9
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/opengl/broadcom/egl/Window.java
@@ -0,0 +1,154 @@
+/*
+ * 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.jogamp.newt.opengl.broadcom.egl;
+
+import com.jogamp.opengl.impl.egl.*;
+import javax.media.nativewindow.*;
+import javax.media.opengl.GLCapabilities;
+import javax.media.nativewindow.NativeWindowException;
+
+public class Window extends com.jogamp.newt.Window {
+ static {
+ Display.initSingleton();
+ }
+
+ public Window() {
+ }
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ if(0!=parentWindowHandle) {
+ throw new RuntimeException("Window parenting not supported (yet)");
+ }
+ // query a good configuration .. even thought we drop this one
+ // and reuse the EGLUtil choosen one later.
+ config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
+ if (config == null) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+ setSizeImpl(getScreen().getWidth(), getScreen().getHeight());
+ }
+
+ protected void closeNative() {
+ if(0!=windowHandleClose) {
+ CloseWindow(getDisplayHandle(), windowHandleClose);
+ }
+ }
+
+ public void setVisible(boolean visible) {
+ if(this.visible!=visible) {
+ this.visible=visible;
+ if ( 0==windowHandle ) {
+ windowHandle = realizeWindow(true, width, height);
+ if (0 == windowHandle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
+ }
+ clearEventMask();
+ }
+ }
+
+ public void setSize(int width, int height) {
+ System.err.println("setSize "+width+"x"+height+" n/a in BroadcomEGL");
+ }
+
+ void setSizeImpl(int width, int height) {
+ if(0!=windowHandle) {
+ // n/a in BroadcomEGL
+ System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window");
+ } else {
+ if(DEBUG_IMPLEMENTATION) {
+ Exception e = new Exception("BCEGL Window.setSizeImpl() "+this.width+"x"+this.height+" -> "+width+"x"+height);
+ e.printStackTrace();
+ }
+ this.width = width;
+ this.height = height;
+ }
+ }
+
+ public void setPosition(int x, int y) {
+ // n/a in BroadcomEGL
+ System.err.println("setPosition n/a in BroadcomEGL");
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ // n/a in BroadcomEGL
+ System.err.println("setFullscreen n/a in BroadcomEGL");
+ return false;
+ }
+
+ public boolean surfaceSwap() {
+ if ( 0!=windowHandle ) {
+ SwapWindow(getDisplayHandle(), windowHandle);
+ return true;
+ }
+ return false;
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ protected static native boolean initIDs();
+ private native long CreateWindow(long eglDisplayHandle, boolean chromaKey, int width, int height);
+ private native void CloseWindow(long eglDisplayHandle, long eglWindowHandle);
+ private native void SwapWindow(long eglDisplayHandle, long eglWindowHandle);
+
+
+ private long realizeWindow(boolean chromaKey, int width, int height) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.out.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+config);
+ }
+ long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height);
+ if (0 == handle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
+ windowHandleClose = handle;
+ return handle;
+ }
+
+ private void windowCreated(int cfgID, int width, int height) {
+ this.width = width;
+ this.height = height;
+ GLCapabilities capsReq = (GLCapabilities) config.getRequestedCapabilities();
+ config = EGLGraphicsConfiguration.create(capsReq, screen.getGraphicsScreen(), cfgID);
+ if (config == null) {
+ throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this);
+ }
+ if(DEBUG_IMPLEMENTATION) {
+ System.out.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+config);
+ }
+ }
+
+ private long windowHandleClose;
+}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java b/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java
new file mode 100755
index 000000000..b09568237
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/opengl/kd/KDDisplay.java
@@ -0,0 +1,84 @@
+/*
+ * 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.jogamp.newt.opengl.kd;
+
+import com.jogamp.newt.*;
+import com.jogamp.newt.impl.*;
+import com.jogamp.opengl.impl.egl.*;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.egl.*;
+
+public class KDDisplay extends Display {
+
+ static {
+ NativeLibLoader.loadNEWT();
+
+ if (!KDWindow.initIDs()) {
+ throw new NativeWindowException("Failed to initialize KDWindow jmethodIDs");
+ }
+ }
+
+ public static void initSingleton() {
+ // just exist to ensure static init has been run
+ }
+
+
+ public KDDisplay() {
+ }
+
+ protected void createNative() {
+ // FIXME: map name to EGL_*_DISPLAY
+ long handle = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
+ if (handle == EGL.EGL_NO_DISPLAY) {
+ throw new NativeWindowException("eglGetDisplay failed");
+ }
+ if (!EGL.eglInitialize(handle, null, null)) {
+ throw new NativeWindowException("eglInitialize failed");
+ }
+ aDevice = new EGLGraphicsDevice(handle);
+ }
+
+ protected void closeNative() {
+ if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) {
+ EGL.eglTerminate(aDevice.getHandle());
+ }
+ }
+
+ protected void dispatchMessages() {
+ DispatchMessages();
+ }
+
+ private native void DispatchMessages();
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/opengl/kd/KDScreen.java b/src/newt/classes/com/jogamp/newt/opengl/kd/KDScreen.java
new file mode 100755
index 000000000..cd53c8152
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/opengl/kd/KDScreen.java
@@ -0,0 +1,57 @@
+/*
+ * 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.jogamp.newt.opengl.kd;
+
+import com.jogamp.newt.*;
+import javax.media.nativewindow.*;
+
+public class KDScreen extends Screen {
+ static {
+ KDDisplay.initSingleton();
+ }
+
+ public KDScreen() {
+ }
+
+ protected void createNative(int index) {
+ aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
+ }
+
+ protected void closeNative() { }
+
+ // elevate access to this package ..
+ protected void setScreenSize(int w, int h) {
+ super.setScreenSize(w, h);
+ }
+}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java b/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java
new file mode 100755
index 000000000..555f54599
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/opengl/kd/KDWindow.java
@@ -0,0 +1,153 @@
+/*
+ * 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.jogamp.newt.opengl.kd;
+
+import com.jogamp.newt.*;
+import com.jogamp.newt.impl.*;
+import com.jogamp.opengl.impl.egl.*;
+import javax.media.nativewindow.*;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.nativewindow.NativeWindowException;
+
+public class KDWindow extends Window {
+ private static final String WINDOW_CLASS_NAME = "NewtWindow";
+ // non fullscreen dimensions ..
+ private int nfs_width, nfs_height, nfs_x, nfs_y;
+
+ static {
+ KDDisplay.initSingleton();
+ }
+
+ public KDWindow() {
+ }
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ if(0!=parentWindowHandle) {
+ throw new RuntimeException("Window parenting not supported (yet)");
+ }
+ config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
+ if (config == null) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+
+ GLCapabilities eglCaps = (GLCapabilities)config.getChosenCapabilities();
+ int[] eglAttribs = EGLGraphicsConfiguration.GLCapabilities2AttribList(eglCaps);
+
+ windowHandle = 0;
+ eglWindowHandle = CreateWindow(getDisplayHandle(), eglAttribs);
+ if (eglWindowHandle == 0) {
+ throw new NativeWindowException("Error creating egl window: "+config);
+ }
+ setVisible0(eglWindowHandle, false);
+ windowHandleClose = eglWindowHandle;
+ }
+
+ protected void closeNative() {
+ if(0!=windowHandleClose) {
+ CloseWindow(windowHandleClose, windowUserData);
+ windowUserData=0;
+ }
+ }
+
+ public void setVisible(boolean visible) {
+ if(0!=eglWindowHandle && this.visible!=visible) {
+ this.visible=visible;
+ setVisible0(eglWindowHandle, visible);
+ if ( 0==windowHandle ) {
+ windowHandle = RealizeWindow(eglWindowHandle);
+ if (0 == windowHandle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
+ }
+ clearEventMask();
+ }
+ }
+
+ public void setSize(int width, int height) {
+ if(0!=eglWindowHandle) {
+ setSize0(eglWindowHandle, width, height);
+ }
+ }
+
+ public void setPosition(int x, int y) {
+ // n/a in KD
+ System.err.println("setPosition n/a in KD");
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ if(0!=eglWindowHandle && this.fullscreen!=fullscreen) {
+ this.fullscreen=fullscreen;
+ if(this.fullscreen) {
+ setFullScreen0(eglWindowHandle, true);
+ } else {
+ setFullScreen0(eglWindowHandle, false);
+ setSize0(eglWindowHandle, nfs_width, nfs_height);
+ }
+ }
+ return true;
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ protected static native boolean initIDs();
+ private native long CreateWindow(long displayHandle, int[] attributes);
+ private native long RealizeWindow(long eglWindowHandle);
+ private native int CloseWindow(long eglWindowHandle, long userData);
+ private native void setVisible0(long eglWindowHandle, boolean visible);
+ private native void setSize0(long eglWindowHandle, int width, int height);
+ private native void setFullScreen0(long eglWindowHandle, boolean fullscreen);
+
+ private void windowCreated(long userData) {
+ windowUserData=userData;
+ }
+
+ private void sizeChanged(int newWidth, int newHeight) {
+ width = newWidth;
+ height = newHeight;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ } else {
+ ((KDScreen)screen).setScreenSize(width, height);
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
+ }
+
+ private long eglWindowHandle;
+ private long windowHandleClose;
+ private long windowUserData;
+}
diff --git a/src/newt/classes/com/jogamp/newt/util/EventDispatchThread.java b/src/newt/classes/com/jogamp/newt/util/EventDispatchThread.java
new file mode 100644
index 000000000..675c6f322
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/util/EventDispatchThread.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+package com.jogamp.newt.util;
+
+import com.jogamp.newt.Display;
+import com.jogamp.newt.impl.Debug;
+import java.util.*;
+
+public class EventDispatchThread {
+ public static final boolean DEBUG = Debug.debug("EDT");
+
+ private ThreadGroup threadGroup;
+ private volatile boolean shouldStop = false;
+ private TaskWorker taskWorker = null;
+ private Object taskWorkerLock = new Object();
+ private ArrayList tasks = new ArrayList(); // one shot tasks
+ private Display display = null;
+ private String name;
+ private long edtPollGranularity = 10;
+
+ public EventDispatchThread(Display display, ThreadGroup tg, String name) {
+ this.display = display;
+ this.threadGroup = tg;
+ this.name=new String("EDT-Display_"+display.getName()+"-"+name);
+ }
+
+ public String getName() { return name; }
+
+ public ThreadGroup getThreadGroup() { return threadGroup; }
+
+ public void start() {
+ start(false);
+ }
+
+ /**
+ * @param externalStimuli true indicates that another thread stimulates,
+ * ie. calls this TaskManager's run() loop method.
+ * Hence no own thread is started in this case.
+ *
+ * @return The started Runnable, which handles the run-loop.
+ * Usefull in combination with externalStimuli=true,
+ * so an external stimuli can call it.
+ */
+ public Runnable start(boolean externalStimuli) {
+ synchronized(taskWorkerLock) {
+ if(null==taskWorker) {
+ taskWorker = new TaskWorker(threadGroup, name);
+ }
+ if(!taskWorker.isRunning()) {
+ shouldStop = false;
+ taskWorker.start(externalStimuli);
+ }
+ taskWorkerLock.notifyAll();
+ }
+ return taskWorker;
+ }
+
+ public void stop() {
+ synchronized(taskWorkerLock) {
+ if(null!=taskWorker && taskWorker.isRunning()) {
+ shouldStop = true;
+ }
+ taskWorkerLock.notifyAll();
+ if(DEBUG) {
+ System.out.println(Thread.currentThread()+": EDT signal STOP");
+ }
+ }
+ }
+
+ public boolean isThreadEDT(Thread thread) {
+ return null!=taskWorker && taskWorker == thread;
+ }
+
+ public boolean isCurrentThreadEDT() {
+ return null!=taskWorker && taskWorker == Thread.currentThread();
+ }
+
+ public boolean isRunning() {
+ return null!=taskWorker && taskWorker.isRunning() ;
+ }
+
+ public void invokeLater(Runnable task) {
+ if(task == null) {
+ return;
+ }
+ synchronized(taskWorkerLock) {
+ if(null!=taskWorker && taskWorker.isRunning() && taskWorker != Thread.currentThread() ) {
+ tasks.add(task);
+ taskWorkerLock.notifyAll();
+ } else {
+ // if !running or isEDTThread, do it right away
+ task.run();
+ }
+ }
+ }
+
+ public void invokeAndWait(Runnable task) {
+ if(task == null) {
+ return;
+ }
+ invokeLater(task);
+ waitOnWorker();
+ }
+
+ public void waitOnWorker() {
+ synchronized(taskWorkerLock) {
+ if(null!=taskWorker && taskWorker.isRunning() && tasks.size()>0 && taskWorker != Thread.currentThread() ) {
+ try {
+ taskWorkerLock.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public void waitUntilStopped() {
+ synchronized(taskWorkerLock) {
+ while(null!=taskWorker && taskWorker.isRunning() && taskWorker != Thread.currentThread() ) {
+ try {
+ taskWorkerLock.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ class TaskWorker extends Thread {
+ boolean isRunning = false;
+ boolean externalStimuli = false;
+
+ public TaskWorker(ThreadGroup tg, String name) {
+ super(tg, name);
+ }
+
+ public synchronized boolean isRunning() {
+ return isRunning;
+ }
+
+ public void start(boolean externalStimuli) throws IllegalThreadStateException {
+ synchronized(this) {
+ this.externalStimuli = externalStimuli;
+ isRunning = true;
+ }
+ if(!externalStimuli) {
+ super.start();
+ }
+ }
+
+ /**
+ * Utilizing taskWorkerLock only for local resources and task execution,
+ * not for event dispatching.
+ */
+ public void run() {
+ if(DEBUG) {
+ System.out.println(Thread.currentThread()+": EDT run() START");
+ }
+ while(!shouldStop) {
+ try {
+ // wait for something todo
+ while(!shouldStop && tasks.size()==0) {
+ synchronized(taskWorkerLock) {
+ if(!shouldStop && tasks.size()==0) {
+ try {
+ taskWorkerLock.wait(edtPollGranularity);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ display.pumpMessages(); // event dispatch
+ }
+ if(!shouldStop && tasks.size()>0) {
+ synchronized(taskWorkerLock) {
+ if(!shouldStop && tasks.size()>0) {
+ Runnable task = (Runnable) tasks.remove(0);
+ task.run();
+ taskWorkerLock.notifyAll();
+ }
+ }
+ display.pumpMessages(); // event dispatch
+ }
+ } catch (Throwable t) {
+ // handle errors ..
+ t.printStackTrace();
+ } finally {
+ // epilog - unlock locked stuff
+ }
+ if(externalStimuli) break; // no loop if called by external stimuli
+ }
+ synchronized(this) {
+ isRunning = !shouldStop;
+ }
+ if(!isRunning) {
+ synchronized(taskWorkerLock) {
+ taskWorkerLock.notifyAll();
+ }
+ }
+ if(DEBUG) {
+ System.out.println(Thread.currentThread()+": EDT run() EXIT");
+ }
+ }
+ }
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java
new file mode 100644
index 000000000..6cd4f8c69
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java
@@ -0,0 +1,307 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+package com.jogamp.newt.util;
+
+import java.util.*;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.security.*;
+
+import javax.media.nativewindow.*;
+
+import com.jogamp.newt.*;
+import com.jogamp.newt.impl.*;
+import com.jogamp.newt.macosx.MacDisplay;
+import com.jogamp.nativewindow.impl.NWReflection;
+
+/**
+ * NEWT Utility class MainThread
+ *
+ * Such behavior is necessary for native windowing toolkits,
+ * where the windowing management must happen on the so called
+ * main thread e.g. for Mac OS X !
+ *
+ * Utilizing this class as a launchpad, now you are able to
+ * use a NEWT multithreaded application with window handling within the different threads,
+ * even on these restricted platforms.
+ *
+ * To support your NEWT Window platform,
+ * you have to pass your main thread actions to {@link #invoke invoke(..)},
+ * have a look at the {@link com.jogamp.newt.macosx.MacWindow MacWindow} implementation.
+ * TODO: Some hardcoded dependencies exist in this implementation,
+ * where you have to patch this code or factor it out. newt.MainThread.force
to true
.newt.MainThread.force
to true
.
+ java -XstartOnFirstThread com.jogamp.newt.util.MainThread demos.es1.RedSquare -GL2 -GL2 -GL2 -GL2
+
+ * Which starts 4 threads, each with a window and OpenGL rendering.
+ */
+public class MainThread {
+ private static AccessControlContext localACC = AccessController.getContext();
+ public static final boolean USE_MAIN_THREAD = NativeWindowFactory.TYPE_MACOSX.equals(NativeWindowFactory.getNativeWindowType(false)) ||
+ Debug.getBooleanProperty("newt.MainThread.force", true, localACC);
+
+ protected static final boolean DEBUG = Debug.debug("MainThread");
+
+ private static boolean isExit=false;
+ private static volatile boolean isRunning=false;
+ private static Object taskWorkerLock=new Object();
+ private static boolean shouldStop;
+ private static ArrayList tasks;
+ private static ArrayList tasksBlock;
+ private static Thread mainThread;
+
+ static class MainAction extends Thread {
+ private String mainClassName;
+ private String[] mainClassArgs;
+
+ private Class mainClass;
+ private Method mainClassMain;
+
+ public MainAction(String mainClassName, String[] mainClassArgs) {
+ this.mainClassName=mainClassName;
+ this.mainClassArgs=mainClassArgs;
+ }
+
+ public void run() {
+ if ( USE_MAIN_THREAD ) {
+ // we have to start first to provide the service ..
+ MainThread.waitUntilRunning();
+ }
+
+ // start user app ..
+ try {
+ Class mainClass = NWReflection.getClass(mainClassName, true);
+ if(null==mainClass) {
+ throw new RuntimeException(new ClassNotFoundException("MainThread couldn't find main class "+mainClassName));
+ }
+ try {
+ mainClassMain = mainClass.getDeclaredMethod("main", new Class[] { String[].class });
+ mainClassMain.setAccessible(true);
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" invoke "+mainClassName);
+ mainClassMain.invoke(null, new Object[] { mainClassArgs } );
+ } catch (InvocationTargetException ite) {
+ ite.getTargetException().printStackTrace();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+
+ if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" user app fin");
+
+ if ( USE_MAIN_THREAD ) {
+ MainThread.exit();
+ if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" MainThread fin - exit");
+ System.exit(0);
+ }
+ }
+ }
+ private static MainAction mainAction;
+
+ /** Your new java application main entry, which pipelines your application */
+ public static void main(String[] args) {
+ if(DEBUG) System.err.println("MainThread.main(): "+Thread.currentThread().getName()+" USE_MAIN_THREAD "+ USE_MAIN_THREAD );
+
+ if(args.length==0) {
+ return;
+ }
+
+ String mainClassName=args[0];
+ String[] mainClassArgs=new String[args.length-1];
+ if(args.length>1) {
+ System.arraycopy(args, 1, mainClassArgs, 0, args.length-1);
+ }
+
+ NativeLibLoader.loadNEWT();
+
+ shouldStop = false;
+ tasks = new ArrayList();
+ tasksBlock = new ArrayList();
+ mainThread = Thread.currentThread();
+
+ mainAction = new MainAction(mainClassName, mainClassArgs);
+
+ if(NativeWindowFactory.TYPE_MACOSX.equals(NativeWindowFactory.getNativeWindowType(false))) {
+ MacDisplay.initSingleton();
+ }
+
+ if ( USE_MAIN_THREAD ) {
+ // dispatch user's main thread ..
+ mainAction.start();
+
+ // do our main thread task scheduling
+ run();
+ } else {
+ // run user's main in this thread
+ mainAction.run();
+ }
+ }
+
+ /** invokes the given Runnable */
+ public static void invoke(boolean wait, Runnable r) {
+ if(r == null) {
+ return;
+ }
+
+ // if this main thread is not being used or
+ // if this is already the main thread .. just execute.
+ if( !isRunning() || mainThread == Thread.currentThread() ) {
+ r.run();
+ return;
+ }
+
+ synchronized(taskWorkerLock) {
+ tasks.add(r);
+ if(wait) {
+ tasksBlock.add(r);
+ }
+ taskWorkerLock.notifyAll();
+ if(wait) {
+ while(tasksBlock.size()>0) {
+ try {
+ taskWorkerLock.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
+ public static void exit() {
+ if(DEBUG) System.err.println("MainThread.exit(): "+Thread.currentThread().getName()+" start");
+ synchronized(taskWorkerLock) {
+ if(isRunning) {
+ shouldStop = true;
+ }
+ taskWorkerLock.notifyAll();
+ }
+ if(DEBUG) System.err.println("MainThread.exit(): "+Thread.currentThread().getName()+" end");
+ }
+
+ public static boolean isRunning() {
+ synchronized(taskWorkerLock) {
+ return isRunning;
+ }
+ }
+
+ private static void waitUntilRunning() {
+ synchronized(taskWorkerLock) {
+ if(isExit) return;
+
+ while(!isRunning) {
+ try {
+ taskWorkerLock.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public static void run() {
+ if(DEBUG) System.err.println("MainThread.run(): "+Thread.currentThread().getName());
+ synchronized(taskWorkerLock) {
+ isRunning = true;
+ taskWorkerLock.notifyAll();
+ }
+ while(!shouldStop) {
+ try {
+ ArrayList localTasks=null;
+
+ // wait for something todo ..
+ synchronized(taskWorkerLock) {
+ while(!shouldStop && tasks.size()==0) {
+ try {
+ taskWorkerLock.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ // seq. process all tasks until no blocking one exists in the list
+ for(Iterator i = tasks.iterator(); tasksBlock.size()>0 && i.hasNext(); ) {
+ Runnable task = (Runnable) i.next();
+ task.run();
+ i.remove();
+ tasksBlock.remove(task);
+ }
+
+ // take over the tasks ..
+ if(tasks.size()>0) {
+ localTasks = tasks;
+ tasks = new ArrayList();
+ }
+ taskWorkerLock.notifyAll();
+ }
+
+ // seq. process all unblocking tasks ..
+ if(null!=localTasks) {
+ for(Iterator i = localTasks.iterator(); i.hasNext(); ) {
+ Runnable task = (Runnable) i.next();
+ task.run();
+ }
+ }
+ } catch (Throwable t) {
+ // handle errors ..
+ t.printStackTrace();
+ } finally {
+ // epilog - unlock locked stuff
+ }
+ }
+ if(DEBUG) System.err.println("MainThread.run(): "+Thread.currentThread().getName()+" fin");
+ synchronized(taskWorkerLock) {
+ isRunning = false;
+ isExit = true;
+ taskWorkerLock.notifyAll();
+ }
+ }
+}
+
+
diff --git a/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java b/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java
new file mode 100755
index 000000000..05cab1a0a
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/windows/WindowsDisplay.java
@@ -0,0 +1,105 @@
+/*
+ * 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.jogamp.newt.windows;
+
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.windows.*;
+import com.jogamp.newt.*;
+import com.jogamp.newt.impl.*;
+
+public class WindowsDisplay extends Display {
+
+ protected static final String WINDOW_CLASS_NAME = "NewtWindowClass";
+ private static int windowClassAtom;
+ private static long hInstance;
+
+ static {
+ NativeLibLoader.loadNEWT();
+
+ if (!WindowsWindow.initIDs()) {
+ throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs");
+ }
+ }
+
+ public static void initSingleton() {
+ // just exist to ensure static init has been run
+ }
+
+
+ public WindowsDisplay() {
+ }
+
+ protected void createNative() {
+ aDevice = new WindowsGraphicsDevice();
+ }
+
+ protected void closeNative() {
+ // Can't do .. only at application shutdown
+ // UnregisterWindowClass(getWindowClassAtom(), getHInstance());
+ }
+
+ protected void dispatchMessages() {
+ DispatchMessages();
+ }
+
+ protected static synchronized int getWindowClassAtom() {
+ if(0 == windowClassAtom) {
+ windowClassAtom = RegisterWindowClass(WINDOW_CLASS_NAME, getHInstance());
+ if (0 == windowClassAtom) {
+ throw new NativeWindowException("Error while registering window class");
+ }
+ }
+ return windowClassAtom;
+ }
+
+ protected static synchronized long getHInstance() {
+ if(0 == hInstance) {
+ hInstance = LoadLibraryW("newt");
+ if (0 == hInstance) {
+ throw new NativeWindowException("Error finding HINSTANCE for \"newt\"");
+ }
+ }
+ return hInstance;
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+ private static native long LoadLibraryW(String libraryName);
+ private static native int RegisterWindowClass(String windowClassName, long hInstance);
+ private static native void UnregisterWindowClass(int wndClassAtom, long hInstance);
+
+ private static native void DispatchMessages();
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/windows/WindowsScreen.java b/src/newt/classes/com/jogamp/newt/windows/WindowsScreen.java
new file mode 100755
index 000000000..aea3cd439
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/windows/WindowsScreen.java
@@ -0,0 +1,57 @@
+/*
+ * 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.jogamp.newt.windows;
+
+import com.jogamp.newt.*;
+import javax.media.nativewindow.*;
+
+public class WindowsScreen extends Screen {
+ static {
+ WindowsDisplay.initSingleton();
+ }
+
+
+ public WindowsScreen() {
+ }
+
+ protected void createNative(int index) {
+ aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
+ setScreenSize(getWidthImpl(getIndex()), getHeightImpl(getIndex()));
+ }
+
+ protected void closeNative() { }
+
+ private native int getWidthImpl(int scrn_idx);
+ private native int getHeightImpl(int scrn_idx);
+}
diff --git a/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java
new file mode 100755
index 000000000..4a468ae86
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/windows/WindowsWindow.java
@@ -0,0 +1,289 @@
+/*
+ * 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.jogamp.newt.windows;
+
+import javax.media.nativewindow.*;
+import com.jogamp.newt.*;
+
+public class WindowsWindow extends Window {
+
+ private long hmon;
+ private long hdc;
+ private long windowHandleClose;
+ private long parentWindowHandle;
+ // non fullscreen dimensions ..
+ private int nfs_width, nfs_height, nfs_x, nfs_y;
+ private final Insets insets = new Insets(0, 0, 0, 0);
+
+ static {
+ WindowsDisplay.initSingleton();
+ }
+
+ public WindowsWindow() {
+ }
+
+ Thread hdcOwner = null;
+
+ public synchronized int lockSurface() throws NativeWindowException {
+ int res = super.lockSurface();
+ if(LOCK_SUCCESS==res && 0!=windowHandle) {
+ if(hdc!=0) {
+ throw new NativeWindowException("NEWT Surface handle set HDC "+toHexString(hdc)+" - "+Thread.currentThread().getName()+" ; "+this);
+ }
+ hdc = GetDC(windowHandle);
+ hmon = MonitorFromWindow(windowHandle);
+ hdcOwner = Thread.currentThread();
+ }
+ return res;
+ }
+
+ public synchronized void unlockSurface() {
+ // prevalidate, before we change data ..
+ Thread cur = Thread.currentThread();
+ if ( getSurfaceLockOwner() != cur ) {
+ getLockedStack().printStackTrace();
+ throw new NativeWindowException(cur+": Not owner, owner is "+getSurfaceLockOwner());
+ }
+ if (0!=hdc && 0!=windowHandle) {
+ if(hdcOwner != cur) {
+ throw new NativeWindowException("NEWT Surface handle set HDC "+toHexString(hdc)+" by other thread "+hdcOwner+", this "+cur+" ; "+this);
+ }
+ ReleaseDC(windowHandle, hdc);
+ hdc=0;
+ hdcOwner=null;
+ }
+ super.unlockSurface();
+ }
+
+ public long getSurfaceHandle() {
+ return hdc;
+ }
+
+ public boolean hasDeviceChanged() {
+ if(0!=windowHandle) {
+ long _hmon = MonitorFromWindow(windowHandle);
+ if (hmon != _hmon) {
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ Exception e = new Exception("!!! Window Device Changed "+Thread.currentThread().getName()+
+ ", HMON "+toHexString(hmon)+" -> "+toHexString(_hmon));
+ e.printStackTrace();
+ }
+ hmon = _hmon;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ WindowsScreen screen = (WindowsScreen) getScreen();
+ WindowsDisplay display = (WindowsDisplay) screen.getDisplay();
+ config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
+ if (config == null) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+ windowHandle = CreateWindow(parentWindowHandle,
+ display.getWindowClassAtom(), display.WINDOW_CLASS_NAME, display.getHInstance(),
+ 0, undecorated, x, y, width, height);
+ if (windowHandle == 0) {
+ throw new NativeWindowException("Error creating window");
+ }
+ this.parentWindowHandle = parentWindowHandle;
+ windowHandleClose = windowHandle;
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ Exception e = new Exception("!!! Window new window handle "+Thread.currentThread().getName()+
+ " (Parent HWND "+toHexString(parentWindowHandle)+
+ ") : HWND "+toHexString(windowHandle)+", "+Thread.currentThread());
+ e.printStackTrace();
+ }
+ }
+
+ protected void closeNative() {
+ if (hdc != 0) {
+ if(windowHandleClose != 0) {
+ ReleaseDC(windowHandleClose, hdc);
+ }
+ hdc = 0;
+ }
+ if(windowHandleClose != 0) {
+ DestroyWindow(windowHandleClose);
+ windowHandleClose = 0;
+ }
+ }
+
+ protected void windowDestroyed() {
+ windowHandleClose = 0;
+ super.windowDestroyed();
+ }
+
+ public void setVisible(boolean visible) {
+ if(this.visible!=visible && 0!=windowHandle) {
+ this.visible=visible;
+ setVisible0(windowHandle, visible);
+ }
+ }
+
+ // @Override
+ public void setSize(int width, int height) {
+ if (0!=windowHandle && (width != this.width || this.height != height)) {
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ this.width = width;
+ this.height = height;
+ setSize0(parentWindowHandle, windowHandle, x, y, width, height);
+ }
+ }
+
+ //@Override
+ public void setPosition(int x, int y) {
+ if (0!=windowHandle && (this.x != x || this.y != y)) {
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ this.x = x;
+ this.y = y;
+ setPosition(parentWindowHandle, windowHandle, x , y);
+ }
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ if(0!=windowHandle && (this.fullscreen!=fullscreen)) {
+ int x,y,w,h;
+ this.fullscreen=fullscreen;
+ if(fullscreen) {
+ x = 0; y = 0;
+ w = screen.getWidth();
+ h = screen.getHeight();
+ } else {
+ x = nfs_x;
+ y = nfs_y;
+ w = nfs_width;
+ h = nfs_height;
+ }
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ System.err.println("WindowsWindow fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
+ }
+ setFullscreen0(parentWindowHandle, windowHandle, x, y, w, h, undecorated, fullscreen);
+ }
+ return fullscreen;
+ }
+
+ // @Override
+ public void requestFocus() {
+ super.requestFocus();
+ if (windowHandle != 0L) {
+ requestFocus(windowHandle);
+ }
+ }
+
+ // @Override
+ public void setTitle(String title) {
+ if (title == null) {
+ title = "";
+ }
+ if (0!=windowHandle && !title.equals(getTitle())) {
+ super.setTitle(title);
+ setTitle(windowHandle, title);
+ }
+ }
+
+ public Insets getInsets() {
+ return (Insets)insets.clone();
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+ protected static native boolean initIDs();
+ private native long CreateWindow(long parentWindowHandle,
+ int wndClassAtom, String wndName,
+ long hInstance, long visualID,
+ boolean isUndecorated,
+ int x, int y, int width, int height);
+ private native void DestroyWindow(long windowHandle);
+ private native long GetDC(long windowHandle);
+ private native void ReleaseDC(long windowHandle, long hdc);
+ private native long MonitorFromWindow(long windowHandle);
+ private static native void setVisible0(long windowHandle, boolean visible);
+ private native void setSize0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height);
+ private native void setPosition(long parentWindowHandle, long windowHandle, int x, int y);
+ private native void setFullscreen0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height, boolean isUndecorated, boolean on);
+ private static native void setTitle(long windowHandle, String title);
+ private static native void requestFocus(long windowHandle);
+
+ private void insetsChanged(int left, int top, int right, int bottom) {
+ if (left != -1 && top != -1 && right != -1 && bottom != -1) {
+ insets.left = left;
+ insets.top = top;
+ insets.right = right;
+ insets.bottom = bottom;
+ }
+ }
+ private void sizeChanged(int newWidth, int newHeight) {
+ width = newWidth;
+ height = newHeight;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
+ }
+
+ private void positionChanged(int newX, int newY) {
+ x = newX;
+ y = newY;
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
+ }
+
+ /**
+ *
+ * @param focusOwner if focusGained is true, focusOwner is the previous
+ * focus owner, if focusGained is false, focusOwner is the new focus owner
+ * @param focusGained
+ */
+ private void focusChanged(long focusOwner, boolean focusGained) {
+ if (focusGained) {
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
+ } else {
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_LOST_FOCUS);
+ }
+ }
+}
diff --git a/src/newt/classes/com/jogamp/newt/x11/X11Display.java b/src/newt/classes/com/jogamp/newt/x11/X11Display.java
new file mode 100755
index 000000000..b8eb80b39
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/x11/X11Display.java
@@ -0,0 +1,120 @@
+/*
+ * 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.jogamp.newt.x11;
+
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.x11.*;
+import com.jogamp.newt.*;
+import com.jogamp.newt.impl.*;
+import com.jogamp.nativewindow.impl.x11.X11Util;
+
+public class X11Display extends Display {
+ static {
+ NativeLibLoader.loadNEWT();
+
+ if (!initIDs()) {
+ throw new NativeWindowException("Failed to initialize X11Display jmethodIDs");
+ }
+
+ if (!X11Window.initIDs()) {
+ throw new NativeWindowException("Failed to initialize X11Window jmethodIDs");
+ }
+ }
+
+ public static void initSingleton() {
+ // just exist to ensure static init has been run
+ }
+
+
+ public X11Display() {
+ }
+
+ protected void createNative() {
+ long handle= X11Util.getThreadLocalDisplay(name);
+ if (handle == 0 ) {
+ throw new RuntimeException("Error creating display: "+name);
+ }
+ try {
+ CompleteDisplay(handle);
+ } catch(RuntimeException e) {
+ X11Util.closeThreadLocalDisplay(name);
+ throw e;
+ }
+ aDevice = new X11GraphicsDevice(handle);
+ }
+
+ protected void closeNative() {
+ if(0==X11Util.closeThreadLocalDisplay(name)) {
+ throw new NativeWindowException(this+" was not mapped");
+ }
+ }
+
+ protected void dispatchMessages() {
+ DispatchMessages(getHandle(), javaObjectAtom, windowDeleteAtom);
+ }
+
+ protected void lockDisplay() {
+ super.lockDisplay();
+ LockDisplay(getHandle());
+ }
+
+ protected void unlockDisplay() {
+ UnlockDisplay(getHandle());
+ super.unlockDisplay();
+ }
+
+ protected long getJavaObjectAtom() { return javaObjectAtom; }
+ protected long getWindowDeleteAtom() { return windowDeleteAtom; }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+ private static native boolean initIDs();
+
+ private native void LockDisplay(long handle);
+ private native void UnlockDisplay(long handle);
+
+ private native void CompleteDisplay(long handle);
+
+ private native void DispatchMessages(long display, long javaObjectAtom, long windowDeleteAtom);
+
+ private void displayCompleted(long javaObjectAtom, long windowDeleteAtom) {
+ this.javaObjectAtom=javaObjectAtom;
+ this.windowDeleteAtom=windowDeleteAtom;
+ }
+
+ private long windowDeleteAtom;
+ private long javaObjectAtom;
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/x11/X11Screen.java b/src/newt/classes/com/jogamp/newt/x11/X11Screen.java
new file mode 100755
index 000000000..e053d99c0
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/x11/X11Screen.java
@@ -0,0 +1,69 @@
+/*
+ * 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.jogamp.newt.x11;
+
+import com.jogamp.newt.*;
+import javax.media.nativewindow.x11.*;
+
+public class X11Screen extends Screen {
+
+ static {
+ X11Display.initSingleton();
+ }
+
+
+ public X11Screen() {
+ }
+
+ protected void createNative(int index) {
+ long handle = GetScreen(display.getHandle(), index);
+ if (handle == 0 ) {
+ throw new RuntimeException("Error creating screen: "+index);
+ }
+ aScreen = new X11GraphicsScreen((X11GraphicsDevice)getDisplay().getGraphicsDevice(), index);
+ setScreenSize(getWidth0(display.getHandle(), index),
+ getHeight0(display.getHandle(), index));
+ }
+
+ protected void closeNative() { }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ private native long GetScreen(long dpy, int scrn_idx);
+ private native int getWidth0(long display, int scrn_idx);
+ private native int getHeight0(long display, int scrn_idx);
+}
+
diff --git a/src/newt/classes/com/jogamp/newt/x11/X11Window.java b/src/newt/classes/com/jogamp/newt/x11/X11Window.java
new file mode 100755
index 000000000..cc3aa58a2
--- /dev/null
+++ b/src/newt/classes/com/jogamp/newt/x11/X11Window.java
@@ -0,0 +1,202 @@
+/*
+ * 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.jogamp.newt.x11;
+
+import com.jogamp.newt.*;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.x11.*;
+
+public class X11Window extends Window {
+ private static final String WINDOW_CLASS_NAME = "NewtWindow";
+ // non fullscreen dimensions ..
+ private int nfs_width, nfs_height, nfs_x, nfs_y;
+
+ static {
+ X11Display.initSingleton();
+ }
+
+ public X11Window() {
+ }
+
+ protected void createNative(long parentWindowHandle, Capabilities caps) {
+ X11Screen screen = (X11Screen) getScreen();
+ X11Display display = (X11Display) screen.getDisplay();
+ config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
+ if (config == null) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+ X11GraphicsConfiguration x11config = (X11GraphicsConfiguration) config;
+ long visualID = x11config.getVisualID();
+ long w = CreateWindow(parentWindowHandle,
+ display.getHandle(), screen.getIndex(), visualID,
+ display.getJavaObjectAtom(), display.getWindowDeleteAtom(), x, y, width, height);
+ if (w == 0 || w!=windowHandle) {
+ throw new NativeWindowException("Error creating window: "+w);
+ }
+ this.parentWindowHandle = parentWindowHandle;
+ windowHandleClose = windowHandle;
+ displayHandleClose = display.getHandle();
+ }
+
+ protected void closeNative() {
+ if(0!=displayHandleClose && 0!=windowHandleClose && null!=getScreen() ) {
+ X11Display display = (X11Display) getScreen().getDisplay();
+ CloseWindow(displayHandleClose, windowHandleClose, display.getJavaObjectAtom());
+ windowHandleClose = 0;
+ displayHandleClose = 0;
+ }
+ }
+
+ protected void windowDestroyed() {
+ windowHandleClose = 0;
+ displayHandleClose = 0;
+ super.windowDestroyed();
+ }
+
+ public void setVisible(boolean visible) {
+ if(0!=windowHandle && this.visible!=visible) {
+ this.visible=visible;
+ setVisible0(getDisplayHandle(), windowHandle, visible);
+ clearEventMask();
+ }
+ }
+
+ public void requestFocus() {
+ super.requestFocus();
+ }
+
+ public void setSize(int width, int height) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("X11Window setSize: "+this.x+"/"+this.y+" "+this.width+"x"+this.height+" -> "+width+"x"+height);
+ // Exception e = new Exception("XXXXXXXXXX");
+ // e.printStackTrace();
+ }
+ this.width = width;
+ this.height = height;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ if(0!=windowHandle) {
+ setSize0(parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, width, height, (undecorated||fullscreen)?-1:1, false);
+ }
+ }
+
+ public void setPosition(int x, int y) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("X11Window setPosition: "+this.x+"/"+this.y+" -> "+x+"/"+y);
+ // Exception e = new Exception("XXXXXXXXXX");
+ // e.printStackTrace();
+ }
+ this.x = x;
+ this.y = y;
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ if(0!=windowHandle) {
+ setPosition0(getDisplayHandle(), windowHandle, x, y);
+ }
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ if(0!=windowHandle && this.fullscreen!=fullscreen) {
+ int x,y,w,h;
+ this.fullscreen=fullscreen;
+ if(fullscreen) {
+ x = 0; y = 0;
+ w = screen.getWidth();
+ h = screen.getHeight();
+ } else {
+ x = nfs_x;
+ y = nfs_y;
+ w = nfs_width;
+ h = nfs_height;
+ }
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ System.err.println("X11Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
+ }
+ setSize0(parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, w, h, (undecorated||fullscreen)?-1:1, false);
+ }
+ return fullscreen;
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ protected static native boolean initIDs();
+ private native long CreateWindow(long parentWindowHandle, long display, int screen_index,
+ long visualID, long javaObjectAtom, long windowDeleteAtom, int x, int y, int width, int height);
+ private native void CloseWindow(long display, long windowHandle, long javaObjectAtom);
+ private native void setVisible0(long display, long windowHandle, boolean visible);
+ private native void setSize0(long parentWindowHandle, long display, int screen_index, long windowHandle,
+ int x, int y, int width, int height, int decorationToggle, boolean setVisible);
+ private native void setPosition0(long display, long windowHandle, int x, int y);
+
+ private void windowChanged(int newX, int newY, int newWidth, int newHeight) {
+ if(width != newWidth || height != newHeight) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("X11Window windowChanged size: "+this.width+"x"+this.height+" -> "+newWidth+"x"+newHeight);
+ }
+ width = newWidth;
+ height = newHeight;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
+ }
+ if( 0==parentWindowHandle && ( x != newX || y != newY ) ) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("X11Window windowChanged position: "+this.x+"/"+this.y+" -> "+newX+"x"+newY);
+ }
+ x = newX;
+ y = newY;
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
+ }
+ }
+
+ private void windowCreated(long windowHandle) {
+ this.windowHandle = windowHandle;
+ }
+
+ private long windowHandleClose;
+ private long displayHandleClose;
+ private long parentWindowHandle;
+}
diff --git a/src/newt/native/BroadcomEGL.c b/src/newt/native/BroadcomEGL.c
index 8a9c5f948..9aac90abb 100755
--- a/src/newt/native/BroadcomEGL.c
+++ b/src/newt/native/BroadcomEGL.c
@@ -41,7 +41,7 @@
#include XVisualInfo * XGetVisualInfo(Display * , long, XVisualInfo * , int * );
*/
private static native java.nio.ByteBuffer XGetVisualInfoCopied1(long arg0, long arg1, java.nio.ByteBuffer arg2, Object arg3, int arg3_byte_offset);
+ public static native long XOpenDisplay(String arg0);
+ public static native int XCloseDisplay(long display);
+ public static native long dlopen(String name);
+ public static native long dlsym(String name);
+
diff --git a/make/config/nativewindow/x11-lib.cfg b/make/config/nativewindow/x11-lib.cfg
index 7a64307da..394dd230a 100644
--- a/make/config/nativewindow/x11-lib.cfg
+++ b/make/config/nativewindow/x11-lib.cfg
@@ -20,8 +20,9 @@ Opaque long Display *
Opaque boolean Bool
Opaque long GLXFBConfig
-CustomJavaCode X11Lib public static native long dlopen(String name);
-CustomJavaCode X11Lib public static native long dlsym(String name);
+# Manually implement XOpenDisplay, XCloseDisplay, catching XIOError
+ManuallyImplement XCloseDisplay
+ManuallyImplement XOpenDisplay
IncludeAs CustomJavaCode X11Lib x11-CustomJavaCode.java
IncludeAs CustomCCode x11-CustomCCode.c
diff --git a/make/stub_includes/win32/wingdi.h b/make/stub_includes/win32/wingdi.h
index 46aeec2b6..fbf2ec5ec 100644
--- a/make/stub_includes/win32/wingdi.h
+++ b/make/stub_includes/win32/wingdi.h
@@ -212,7 +212,7 @@ WINGDIAPI HGDIOBJ WINAPI SelectObject(HDC, HGDIOBJ);
// Routines for creation of a dummy window, device context and OpenGL
// context for the purposes of getting wglChoosePixelFormatARB and
// associated routines
-HDC CreateDummyWindow(int,int,int,int);
+HWND CreateDummyWindow( int x, int y, int width, int height ) ;
WINUSERAPI BOOL WINAPI ShowWindow(HWND hWnd, int nCmdShow);
WINUSERAPI HDC WINAPI GetDC(HWND);
WINUSERAPI int WINAPI ReleaseDC(HWND hWnd, HDC hDC);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
index 893827a8c..7543a1084 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
@@ -41,6 +41,7 @@ package com.jogamp.opengl.impl;
import com.jogamp.common.os.DynamicLookupHelper;
import java.nio.*;
+import java.util.*;
import javax.media.opengl.*;
import com.jogamp.nativewindow.impl.NWReflection;
@@ -346,13 +347,30 @@ public abstract class GLContextImpl extends GLContext {
/** Maps the given "platform-independent" function name to a real function
name. Currently this is only used to map "glAllocateMemoryNV" and
associated routines to wglAllocateMemoryNV / glXAllocateMemoryNV. */
- protected abstract String mapToRealGLFunctionName(String glFunctionName);
+ protected String mapToRealGLFunctionName(String glFunctionName) {
+ Map/* XVisualInfo * XGetVisualInfo(Display * , long, XVisualInfo * , int * );
*/
private static native java.nio.ByteBuffer XGetVisualInfoCopied1(long arg0, long arg1, java.nio.ByteBuffer arg2, Object arg3, int arg3_byte_offset);
- public static native long XOpenDisplay(String arg0);
- public static native int XCloseDisplay(long display);
+ public static native long DefaultVisualID(long display, int screen);
+
+ /**
+ public static native long CreateDummyWindow(long display, int screen_index, long visualID);
+ public static native void DestroyDummyWindow(long display, long window); */
+
public static native long dlopen(String name);
public static native long dlsym(String name);
+ public static native int XCloseDisplay(long display);
+ public static native void XUnlockDisplay(long display);
+ public static native void XLockDisplay(long display);
+
diff --git a/make/config/nativewindow/x11-lib.cfg b/make/config/nativewindow/x11-lib.cfg
index 394dd230a..cf9642398 100644
--- a/make/config/nativewindow/x11-lib.cfg
+++ b/make/config/nativewindow/x11-lib.cfg
@@ -20,25 +20,25 @@ Opaque long Display *
Opaque boolean Bool
Opaque long GLXFBConfig
-# Manually implement XOpenDisplay, XCloseDisplay, catching XIOError
-ManuallyImplement XCloseDisplay
-ManuallyImplement XOpenDisplay
-
IncludeAs CustomJavaCode X11Lib x11-CustomJavaCode.java
-IncludeAs CustomCCode x11-CustomCCode.c
+# Now resides in x11/Xmisc.c: IncludeAs CustomCCode x11-CustomCCode.c
ArgumentIsString XOpenDisplay 0
-# Need to expose DefaultScreen and RootWindow macros to Java
-CustomJavaCode X11Lib public static native int DefaultScreen(long display);
-CustomJavaCode X11Lib public static native long DefaultVisualID(long display, int screen);
-CustomJavaCode X11Lib public static native long RootWindow(long display, int screen);
-
# We have Custom code for the following
Ignore XGetVisualInfo
+ManuallyImplement XCloseDisplay
+ManuallyImplement XUnlockDisplay
+ManuallyImplement XLockDisplay
+
# Helper routine to make the ReturnedArrayLength expression below work correctly
CustomJavaCode X11Lib private static int getFirstElement(IntBuffer buf) { return buf.get(buf.position()); }
CustomJavaCode X11Lib private static int getFirstElement(int[] arr, int offset) { return arr[offset]; }
CustomJavaCode XVisualInfo public static XVisualInfo create(XVisualInfo s) { XVisualInfo d = XVisualInfo.create(); d.getBuffer().put(s.getBuffer()); d.getBuffer().rewind(); s.getBuffer().rewind(); return d; }
+
+CustomCCode #include
+ * as well as the static global display connection.
*
* The TLS variant is thread safe per se, but be aware of the memory leak risk
* where an application heavily utilizing this class on temporary new threads.
@@ -51,27 +54,98 @@ public class X11Util {
static {
NativeLibLoaderBase.loadNativeWindow("x11");
+ installIOErrorHandler();
}
private X11Util() {}
private static ThreadLocal currentDisplayMap = new ThreadLocal();
+ // not exactly thread safe, but good enough for our purpose,
+ // which is to tag a NamedDisplay uncloseable after creation.
+ private static Object globalLock = new Object();
+ private static Collection globalNamedDisplayActive = new ArrayList();
+ private static Collection globalNamedDisplayPassive = new ArrayList();
+
+ public static final String nullDeviceName = "nil" ;
+
public static class NamedDisplay implements Cloneable {
- private String name;
- private long handle;
+ String name;
+ long handle;
+ int refCount;
+ boolean unCloseable;
protected NamedDisplay(String name, long handle) {
this.name=name;
this.handle=handle;
+ this.refCount=1;
+ this.unCloseable=false;
}
- public String getName() { return name; }
- public long getHandle() { return handle; }
+ public final String getName() { return name; }
+ public final String getNameSafe() { return null == name ? nullDeviceName : name; }
+ public final long getHandle() { return handle; }
+ public final int getRefCount() { return refCount; }
+ public final boolean isUncloseable() { return unCloseable; }
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
+
+ public String toString() {
+ return "NamedX11Display["+name+", 0x"+Long.toHexString(handle)+", refCount "+refCount+", unCloseable "+unCloseable+"]";
+ }
+ }
+
+ /** Returns the number of unclosed X11 Displays.
+ * @param realXClosePendingDisplays if true, call XCloseDisplay on the remaining ones
+ */
+ public static int shutdown(boolean realXClosePendingDisplays, boolean verbose) {
+ int num=0;
+ String msg;
+ if(DEBUG||verbose) {
+ msg = "X11Util.Display: Shutdown (active: "+globalNamedDisplayActive.size()+
+ ", passive: "+globalNamedDisplayPassive.size() + ")";
+ if(DEBUG) {
+ Exception e = new Exception(msg);
+ e.printStackTrace();
+ } else if(verbose) {
+ System.err.println(msg);
+ }
+ }
+
+ msg = realXClosePendingDisplays ? "Close" : "Keep" ;
+
+ synchronized(globalLock) {
+ // for all passive displays ..
+ Collection namedDisplays = globalNamedDisplayPassive;
+ globalNamedDisplayPassive = new ArrayList();
+ for(Iterator iter=namedDisplays.iterator(); iter.hasNext(); ) {
+ NamedDisplay ndpy = (NamedDisplay)iter.next();
+ if(DEBUG||verbose) {
+ System.err.println(msg+" passive: "+ndpy);
+ }
+ if(realXClosePendingDisplays) {
+ X11Lib.XCloseDisplay(ndpy.getHandle());
+ }
+ num++;
+ }
+
+ // for all active displays ..
+ namedDisplays = globalNamedDisplayActive;
+ globalNamedDisplayActive = new ArrayList();
+ for(Iterator iter=namedDisplays.iterator(); iter.hasNext(); ) {
+ NamedDisplay ndpy = (NamedDisplay)iter.next();
+ if(DEBUG||verbose) {
+ System.err.println(msg+" active: "+ndpy);
+ }
+ if(realXClosePendingDisplays) {
+ X11Lib.XCloseDisplay(ndpy.getHandle());
+ }
+ num++;
+ }
+ }
+ return num;
}
/** Returns a clone of the thread local display map, you may {@link Object#wait()} on it */
@@ -79,48 +153,120 @@ public class X11Util {
return (Map) ((HashMap)getCurrentDisplayMapImpl()).clone();
}
- /** Returns this thread current default display. If it doesn not exist, it is being created */
- public static long getThreadLocalDefaultDisplay() {
- return getThreadLocalDisplay(null);
+ /** Returns this thread current default display. If it doesn not exist, it is being created, otherwise the reference count is increased */
+ public static long createThreadLocalDefaultDisplay() {
+ return createThreadLocalDisplay(null);
}
- /** Returns this thread named display. If it doesn not exist, it is being created */
- public static long getThreadLocalDisplay(String name) {
+ /** Returns this thread named display. If it doesn not exist, it is being created, otherwise the reference count is increased */
+ public static long createThreadLocalDisplay(String name) {
NamedDisplay namedDpy = getCurrentDisplay(name);
+ if(null==namedDpy) {
+ synchronized(globalLock) {
+ namedDpy = getNamedDisplay(globalNamedDisplayPassive, name);
+ if(null != namedDpy) {
+ if(!globalNamedDisplayPassive.remove(namedDpy)) { throw new RuntimeException("Internal: "+namedDpy); }
+ globalNamedDisplayActive.add(namedDpy);
+ addCurrentDisplay( namedDpy );
+ }
+ }
+ }
if(null==namedDpy) {
long dpy = X11Lib.XOpenDisplay(name);
if(0==dpy) {
throw new NativeWindowException("X11Util.Display: Unable to create a display("+name+") connection in Thread "+Thread.currentThread().getName());
}
namedDpy = new NamedDisplay(name, dpy);
- setCurrentDisplay( namedDpy );
+ synchronized(globalLock) {
+ globalNamedDisplayActive.add(namedDpy);
+ addCurrentDisplay( namedDpy );
+ }
if(DEBUG) {
- Exception e = new Exception("X11Util.Display: Created new TLS display("+name+") connection 0x"+Long.toHexString(dpy)+" in thread "+Thread.currentThread().getName());
+ Exception e = new Exception("X11Util.Display: Created new TLS "+namedDpy+" in thread "+Thread.currentThread().getName());
+ e.printStackTrace();
+ }
+ } else {
+ namedDpy.refCount++;
+ if(DEBUG) {
+ Exception e = new Exception("X11Util.Display: Reused TLS "+namedDpy+" in thread "+Thread.currentThread().getName());
e.printStackTrace();
}
}
return namedDpy.getHandle();
}
- /** Closes this thread named display. It returns the handle of the closed display or 0, if it does not exist. */
+ /** Decrease the reference count of this thread named display. If it reaches 0, close it.
+ It returns the handle of the to be closed display.
+ It throws a RuntimeException in case the named display does not exist,
+ or the reference count goes below 0.
+ */
public static long closeThreadLocalDisplay(String name) {
- NamedDisplay namedDpy = removeCurrentDisplay(name);
+ NamedDisplay namedDpy = getCurrentDisplay(name);
if(null==namedDpy) {
+ throw new RuntimeException("X11Util.Display: Display("+name+") with given handle is not mapped to TLS in thread "+Thread.currentThread().getName());
+ }
+ if(0==namedDpy.refCount) {
+ throw new RuntimeException("X11Util.Display: "+namedDpy+" has refCount already 0 in thread "+Thread.currentThread().getName());
+ }
+ long dpy = namedDpy.getHandle();
+ namedDpy.refCount--;
+ if(0==namedDpy.refCount) {
+ synchronized(globalLock) {
+ if(!globalNamedDisplayActive.remove(namedDpy)) { throw new RuntimeException("Internal: "+namedDpy); }
+ if(namedDpy.isUncloseable()) {
+ globalNamedDisplayPassive.add(namedDpy);
+ } else {
+ X11Lib.XCloseDisplay(dpy);
+ }
+ removeCurrentDisplay(namedDpy);
+ }
if(DEBUG) {
- Exception e = new Exception("X11Util.Display: Display("+name+") with given handle is not mapped to TLS in thread "+Thread.currentThread().getName());
+ String type = namedDpy.isUncloseable() ? "passive" : "real" ;
+ Exception e = new Exception("X11Util.Display: Closing ( "+type+" ) TLS "+namedDpy+" in thread "+Thread.currentThread().getName());
e.printStackTrace();
}
- return 0;
- }
- long dpy = namedDpy.getHandle();
- if(DEBUG) {
- Exception e = new Exception("X11Util.Display: Closing TLS Display("+name+") with handle 0x"+Long.toHexString(dpy)+" in thread "+Thread.currentThread().getName());
+ } else if(DEBUG) {
+ Exception e = new Exception("X11Util.Display: Keep TLS "+namedDpy+" in thread "+Thread.currentThread().getName());
e.printStackTrace();
}
- X11Lib.XCloseDisplay(dpy);
return dpy;
}
+ public static String getThreadLocalDisplayName(long handle) {
+ NamedDisplay ndpy = getNamedDisplay(getCurrentDisplayMapImpl().values(), handle);
+ return null != ndpy ? ndpy.getName() : null;
+ }
+
+ public static boolean markThreadLocalDisplayUndeletable(long handle) {
+ NamedDisplay ndpy = getNamedDisplay(getCurrentDisplayMapImpl().values(), handle);
+ if( null != ndpy ) {
+ ndpy.unCloseable=true;
+ return true;
+ }
+ return false;
+ }
+
+ public static String getGlobalDisplayName(long handle, boolean active) {
+ String name;
+ synchronized(globalLock) {
+ NamedDisplay ndpy = getNamedDisplay(active ? globalNamedDisplayActive : globalNamedDisplayPassive, handle);
+ name = null != ndpy ? ndpy.getName() : null;
+ }
+ return name;
+ }
+
+ public static boolean markGlobalDisplayUndeletable(long handle) {
+ boolean r=false;
+ synchronized(globalLock) {
+ NamedDisplay ndpy = getNamedDisplay(globalNamedDisplayActive, handle);
+ if( null != ndpy ) {
+ ndpy.unCloseable=true;
+ r=true;
+ }
+ }
+ return r;
+ }
+
private static Map getCurrentDisplayMapImpl() {
Map displayMap = (Map) currentDisplayMap.get();
if(null==displayMap) {
@@ -132,12 +278,11 @@ public class X11Util {
/** maps the given display to the thread local display map
* and notifies all threads synchronized to this display map. */
- private static NamedDisplay setCurrentDisplay(NamedDisplay newDisplay) {
+ private static NamedDisplay addCurrentDisplay(NamedDisplay newDisplay) {
Map displayMap = getCurrentDisplayMapImpl();
NamedDisplay oldDisplay = null;
synchronized(displayMap) {
- String name = (null==newDisplay.getName())?"nil":newDisplay.getName();
- oldDisplay = (NamedDisplay) displayMap.put(name, newDisplay);
+ oldDisplay = (NamedDisplay) displayMap.put(newDisplay.getNameSafe(), newDisplay);
displayMap.notifyAll();
}
return oldDisplay;
@@ -145,22 +290,45 @@ public class X11Util {
/** removes the mapping of the given name from the thread local display map
* and notifies all threads synchronized to this display map. */
- private static NamedDisplay removeCurrentDisplay(String name) {
+ private static NamedDisplay removeCurrentDisplay(NamedDisplay ndpy) {
Map displayMap = getCurrentDisplayMapImpl();
- NamedDisplay oldDisplay = null;
synchronized(displayMap) {
- if(null==name) name="nil";
- oldDisplay = (NamedDisplay) displayMap.remove(name);
+ NamedDisplay ndpyDel = (NamedDisplay) displayMap.remove(ndpy.getNameSafe());
+ if(ndpyDel!=ndpy) {
+ throw new RuntimeException("Wrong mapping req: "+ndpy+", got "+ndpyDel);
+ }
displayMap.notifyAll();
}
- return oldDisplay;
+ return ndpy;
}
/** Returns the thread local display mapped to the given name */
private static NamedDisplay getCurrentDisplay(String name) {
- if(null==name) name="nil";
+ if(null==name) name=nullDeviceName;
Map displayMap = getCurrentDisplayMapImpl();
return (NamedDisplay) displayMap.get(name);
}
+ private static NamedDisplay getNamedDisplay(Collection namedDisplays, String name) {
+ if(null==name) name=nullDeviceName;
+ for(Iterator iter=namedDisplays.iterator(); iter.hasNext(); ) {
+ NamedDisplay ndpy = (NamedDisplay)iter.next();
+ if (ndpy.getNameSafe().equals(name)) {
+ return ndpy;
+ }
+ }
+ return null;
+ }
+
+ private static NamedDisplay getNamedDisplay(Collection namedDisplays, long handle) {
+ for(Iterator iter=namedDisplays.iterator(); iter.hasNext(); ) {
+ NamedDisplay ndpy = (NamedDisplay)iter.next();
+ if (ndpy.getHandle()==handle) {
+ return ndpy;
+ }
+ }
+ return null;
+ }
+
+ private static native void installIOErrorHandler();
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
index 52f48660a..69ace3c52 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
@@ -57,7 +57,7 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl
/** Creates a new X11GraphicsScreen using a thread local display connection */
public static AbstractGraphicsScreen createDefault() {
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- long display = X11Util.getThreadLocalDefaultDisplay();
+ long display = X11Util.createThreadLocalDefaultDisplay();
try {
X11Lib.XLockDisplay(display);
int scrnIdx = X11Lib.DefaultScreen(display);
diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c
new file mode 100644
index 000000000..4320a8f12
--- /dev/null
+++ b/src/nativewindow/native/x11/Xmisc.c
@@ -0,0 +1,471 @@
+/*
+ * Copyright (c) 2010 Sven Gothel. 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 Sven Gothel 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
+ * SVEN GOTHEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include
LPVOID glMapBuffer(GLenum target, GLenum access);
*/
-public java.nio.ByteBuffer glMapBuffer(int target, int access) {
- final long __addr_ = ((GL2ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer;
- if (__addr_ == 0) {
- throw new GLException("Method \"glMapBuffer\" not available");
- }
- int sz = bufferSizeTracker.getBufferSize(bufferStateTracker,
- target,
- this);
- long addr;
- addr = dispatch_glMapBuffer(target, access, __addr_);
- if (addr == 0 || sz == 0) {
- return null;
- }
- ARBVBOKey key = new ARBVBOKey(addr, sz);
- ByteBuffer _res = (ByteBuffer) arbVBOCache.get(key);
- if (_res == null) {
- _res = newDirectByteBuffer(addr, sz);
- InternalBufferUtil.nativeOrder(_res);
- arbVBOCache.put(key, _res);
- }
- _res.position(0);
- return _res;
-}
-
-/** Encapsulates function pointer for OpenGL function
: LPVOID glMapBuffer(GLenum target, GLenum access);
*/
-native private long dispatch_glMapBuffer(int target, int access, long glProcAddress);
-
-native private ByteBuffer newDirectByteBuffer(long addr, int capacity);
-
- /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
- public void glShaderBinary(int n, java.nio.IntBuffer shaders, int binaryformat, java.nio.Buffer binary, int length) {
- throw new GLException("Method \"glShaderBinary\" not available");
- }
-
- /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
- public void glShaderBinary(int n, int[] shaders, int shaders_offset, int binaryformat, java.nio.Buffer binary, int length) {
- throw new GLException("Method \"glShaderBinary\" not available");
- }
-
- public void glReleaseShaderCompiler() {
- // nothing to do
- }
-
- public void glVertexPointer(GLArrayData array) {
- if(array.getComponentNumber()==0) return;
- if(array.isVBO()) {
- glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
- } else {
- glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
- }
- }
- public void glColorPointer(GLArrayData array) {
- if(array.getComponentNumber()==0) return;
- if(array.isVBO()) {
- glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
- } else {
- glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
- }
-
- }
- public void glNormalPointer(GLArrayData array) {
- if(array.getComponentNumber()==0) return;
- if(array.getComponentNumber()!=3) {
- throw new GLException("Only 3 components per normal allowed");
- }
- if(array.isVBO()) {
- glNormalPointer(array.getComponentType(), array.getStride(), array.getOffset());
- } else {
- glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer());
- }
- }
- public void glTexCoordPointer(GLArrayData array) {
- if(array.getComponentNumber()==0) return;
- if(array.isVBO()) {
- glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
- } else {
- glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
- }
- }
-
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java b/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java
deleted file mode 100644
index 54c7bd92b..000000000
--- a/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java
+++ /dev/null
@@ -1,455 +0,0 @@
-// Tracks glBegin/glEnd calls to determine whether it is legal to
-// query Vertex Buffer Object state
-private boolean inBeginEndPair;
-
-/* FIXME: refactor dependence on Java 2D / JOGL bridge
-
-// Tracks creation and destruction of server-side OpenGL objects when
-// the Java2D/OpenGL pipeline is enabled and it is using frame buffer
-// objects (FBOs) to do its rendering
-private GLObjectTracker tracker;
-
-public void setObjectTracker(GLObjectTracker tracker) {
- this.tracker = tracker;
-}
-
-*/
-
-public GL2ES12Impl(GLProfile glp, GLContextImpl context) {
- this._context = context;
- this.bufferSizeTracker = context.getBufferSizeTracker();
- this.bufferStateTracker = context.getBufferStateTracker();
- this.glStateTracker = context.getGLStateTracker();
- this.isGL2ES2 = glp.isGL2ES2();
- this.glProfile = glp;
-}
-
-private boolean isGL2ES2;
-
-public final boolean isGL() {
- return true;
-}
-
-public final boolean isGL4bc() {
- return false;
-}
-
-public final boolean isGL4() {
- return false;
-}
-
-public final boolean isGL3bc() {
- return false;
-}
-
-public final boolean isGL3() {
- return false;
-}
-
-public final boolean isGL2() {
- return false;
-}
-
-public final boolean isGLES1() {
- return false;
-}
-
-public final boolean isGLES2() {
- return false;
-}
-
-public final boolean isGLES() {
- return false;
-}
-
-public final boolean isGL2ES1() {
- return !isGL2ES2;
-}
-
-public final boolean isGL2ES2() {
- return isGL2ES2;
-}
-
-public final boolean isGL2GL3() {
- return false;
-}
-
-public final boolean hasGLSL() {
- return isGL2ES2;
-}
-
-public final GL getGL() throws GLException {
- return this;
-}
-
-public final GL4bc getGL4bc() throws GLException {
- throw new GLException("Not a GL4bc implementation");
-}
-
-public final GL4 getGL4() throws GLException {
- throw new GLException("Not a GL4 implementation");
-}
-
-public final GL3bc getGL3bc() throws GLException {
- throw new GLException("Not a GL3bc implementation");
-}
-
-public final GL3 getGL3() throws GLException {
- throw new GLException("Not a GL3 implementation");
-}
-
-public final GL2 getGL2() throws GLException {
- throw new GLException("Not a GL2 implementation");
-}
-
-public final GLES1 getGLES1() throws GLException {
- throw new GLException("Not a GLES1 implementation");
-}
-
-public final GLES2 getGLES2() throws GLException {
- throw new GLException("Not a GLES2 implementation");
-}
-
-public final GL2ES1 getGL2ES1() throws GLException {
- if (isGL2ES1()) {
- return this;
- }
- throw new GLException("Not a GL2ES1 implementation");
-}
-
-public final GL2ES2 getGL2ES2() throws GLException {
- if (isGL2ES2()) {
- return this;
- }
- throw new GLException("Not a GL2ES2 implementation");
-}
-
-public final GL2GL3 getGL2GL3() throws GLException {
- throw new GLException("Not a GL2GL3 implementation");
-}
-
-public boolean isFunctionAvailable(String glFunctionName) {
- return _context.isFunctionAvailable(glFunctionName);
-}
-
-public boolean isExtensionAvailable(String glExtensionName) {
- return _context.isExtensionAvailable(glExtensionName);
-}
-
-public Object getExtension(String extensionName) {
- // At this point we don't expose any extensions using this mechanism
- return null;
-}
-
-/** Returns the context this GL object is associated with for better
- error checking by DebugGL. */
-public GLContext getContext() {
- return _context;
-}
-
-private GLContextImpl _context;
-
-public void setSwapInterval(int interval) {
- _context.setSwapInterval(interval);
-}
-
-public int getSwapInterval() {
- return _context.getSwapInterval();
-}
-
-public Object getPlatformGLExtensions() {
- return _context.getPlatformGLExtensions();
-}
-
-//
-// Helpers for ensuring the correct amount of texture data
-//
-
-/** Returns the number of bytes required to fill in the appropriate
- texture. This is computed as closely as possible based on the
- pixel pack or unpack parameters. The logic in this routine is
- based on code in the SGI OpenGL sample implementation. */
-
-private int imageSizeInBytes(int format, int type, int w, int h, int d,
- boolean pack) {
- int elements = 0;
- int esize = 0;
-
- if (w < 0) return 0;
- if (h < 0) return 0;
- if (d < 0) return 0;
- switch (format) {
- case GL_STENCIL_INDEX:
- elements = 1;
- break;
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_DEPTH_COMPONENT:
- elements = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- elements = 2;
- break;
- case GL_RGB:
- elements = 3;
- break;
- case GL_RGBA:
- elements = 4;
- break;
- /* FIXME ??
- case GL_HILO_NV:
- elements = 2;
- break; */
- default:
- return 0;
- }
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- esize = 1;
- break;
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- esize = 2;
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- esize = 2;
- elements = 1;
- break;
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- esize = 4;
- break;
- default:
- return 0;
- }
- return imageSizeInBytes(elements * esize, w, h, d, pack);
-}
-
-private GLBufferSizeTracker bufferSizeTracker;
-private GLBufferStateTracker bufferStateTracker;
-private GLStateTracker glStateTracker;
-
-private boolean bufferObjectExtensionsInitialized = false;
-private boolean haveGL15;
-private boolean haveGL21;
-private boolean haveARBVertexBufferObject;
-
-private void initBufferObjectExtensionChecks() {
- if (bufferObjectExtensionsInitialized)
- return;
- bufferObjectExtensionsInitialized = true;
- haveGL15 = isExtensionAvailable("GL_VERSION_1_5");
- haveGL21 = isExtensionAvailable("GL_VERSION_2_1");
- haveARBVertexBufferObject = isExtensionAvailable("GL_ARB_vertex_buffer_object");
-}
-
-private boolean checkBufferObject(boolean extension1,
- boolean extension2,
- boolean extension3,
- boolean enabled,
- int state,
- String kind, boolean throwException) {
- if (inBeginEndPair) {
- throw new GLException("May not call this between glBegin and glEnd");
- }
- boolean avail = (extension1 || extension2 || extension3);
- if (!avail) {
- if (!enabled)
- return true;
- if(throwException) {
- throw new GLException("Required extensions not available to call this function");
- }
- return false;
- }
- int buffer = bufferStateTracker.getBoundBufferObject(state, this);
- if (enabled) {
- if (buffer == 0) {
- if(throwException) {
- throw new GLException(kind + " must be enabled to call this method");
- }
- return false;
- }
- } else {
- if (buffer != 0) {
- if(throwException) {
- throw new GLException(kind + " must be disabled to call this method");
- }
- return false;
- }
- }
- return true;
-}
-
-private boolean checkArrayVBODisabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveGL15,
- haveARBVertexBufferObject,
- false,
- false,
- GL.GL_ARRAY_BUFFER,
- "array vertex_buffer_object", throwException);
-}
-
-private boolean checkArrayVBOEnabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveGL15,
- haveARBVertexBufferObject,
- false,
- true,
- GL.GL_ARRAY_BUFFER,
- "array vertex_buffer_object", throwException);
-}
-
-private boolean checkElementVBODisabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveGL15,
- haveARBVertexBufferObject,
- false,
- false,
- GL.GL_ELEMENT_ARRAY_BUFFER,
- "element vertex_buffer_object", throwException);
-}
-
-private boolean checkElementVBOEnabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveGL15,
- haveARBVertexBufferObject,
- false,
- true,
- GL.GL_ELEMENT_ARRAY_BUFFER,
- "element vertex_buffer_object", throwException);
-}
-
-private boolean checkUnpackPBODisabled(boolean throwException) {
- // PBO n/a for ES 1.1 or ES 2.0
- return true;
-}
-
-private boolean checkUnpackPBOEnabled(boolean throwException) {
- // PBO n/a for ES 1.1 or ES 2.0
- return false;
-}
-
-private boolean checkPackPBODisabled(boolean throwException) {
- // PBO n/a for ES 1.1 or ES 2.0
- return true;
-}
-
-private boolean checkPackPBOEnabled(boolean throwException) {
- // PBO n/a for ES 1.1 or ES 2.0
- return false;
-}
-
-// Attempt to return the same ByteBuffer object from glMapBuffer if
-// the vertex buffer object's base address and size haven't changed
-private static class ARBVBOKey {
- private long addr;
- private int capacity;
-
- ARBVBOKey(long addr, int capacity) {
- this.addr = addr;
- this.capacity = capacity;
- }
-
- public int hashCode() {
- return (int) addr;
- }
-
- public boolean equals(Object o) {
- if ((o == null) || (!(o instanceof ARBVBOKey))) {
- return false;
- }
-
- ARBVBOKey other = (ARBVBOKey) o;
- return ((addr == other.addr) && (capacity == other.capacity));
- }
-}
-
-private Map/*
LPVOID glMapBuffer(GLenum target, GLenum access);
*/
-public java.nio.ByteBuffer glMapBuffer(int target, int access) {
- final long __addr_ = ((GL2ES12ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer;
- if (__addr_ == 0) {
- throw new GLException("Method \"glMapBuffer\" not available");
- }
- int sz = bufferSizeTracker.getBufferSize(bufferStateTracker,
- target,
- this);
- long addr;
- addr = dispatch_glMapBuffer(target, access, __addr_);
- if (addr == 0 || sz == 0) {
- return null;
- }
- ARBVBOKey key = new ARBVBOKey(addr, sz);
- ByteBuffer _res = (ByteBuffer) arbVBOCache.get(key);
- if (_res == null) {
- _res = newDirectByteBuffer(addr, sz);
- InternalBufferUtil.nativeOrder(_res);
- arbVBOCache.put(key, _res);
- }
- _res.position(0);
- return _res;
-}
-
-/** Encapsulates function pointer for OpenGL function
: LPVOID glMapBuffer(GLenum target, GLenum access);
*/
-native private long dispatch_glMapBuffer(int target, int access, long glProcAddress);
-
-native private ByteBuffer newDirectByteBuffer(long addr, int capacity);
-
- /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
- public void glShaderBinary(int n, java.nio.IntBuffer shaders, int binaryformat, java.nio.Buffer binary, int length) {
- throw new GLException("Method \"glShaderBinary\" not available");
- }
-
- /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
- public void glShaderBinary(int n, int[] shaders, int shaders_offset, int binaryformat, java.nio.Buffer binary, int length) {
- throw new GLException("Method \"glShaderBinary\" not available");
- }
-
- public void glReleaseShaderCompiler() {
- // nothing to do
- }
-
- public void glVertexPointer(GLArrayData array) {
- if(array.getComponentNumber()==0) return;
- if(array.isVBO()) {
- glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
- } else {
- glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
- }
- }
- public void glColorPointer(GLArrayData array) {
- if(array.getComponentNumber()==0) return;
- if(array.isVBO()) {
- glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
- } else {
- glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
- }
-
- }
- public void glNormalPointer(GLArrayData array) {
- if(array.getComponentNumber()==0) return;
- if(array.getComponentNumber()!=3) {
- throw new GLException("Only 3 components per normal allowed");
- }
- if(array.isVBO()) {
- glNormalPointer(array.getComponentType(), array.getStride(), array.getOffset());
- } else {
- glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer());
- }
- }
- public void glTexCoordPointer(GLArrayData array) {
- if(array.getComponentNumber()==0) return;
- if(array.isVBO()) {
- glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
- } else {
- glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
- }
- }
-
-
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl3.java b/make/config/jogl/gl-impl-CustomJavaCode-gl3.java
deleted file mode 100644
index cff0b0f94..000000000
--- a/make/config/jogl/gl-impl-CustomJavaCode-gl3.java
+++ /dev/null
@@ -1,468 +0,0 @@
-// Tracks glBegin/glEnd calls to determine whether it is legal to
-// query Vertex Buffer Object state
-private boolean inBeginEndPair;
-
-/* FIXME: refactor dependence on Java 2D / JOGL bridge
-
-// Tracks creation and destruction of server-side OpenGL objects when
-// the Java2D/OpenGL pipeline is enabled and it is using frame buffer
-// objects (FBOs) to do its rendering
-private GLObjectTracker tracker;
-
-public void setObjectTracker(GLObjectTracker tracker) {
- this.tracker = tracker;
-}
-
-*/
-
-public GL3Impl(GLProfile glp, GLContextImpl context) {
- this._context = context;
- this.bufferSizeTracker = context.getBufferSizeTracker();
- this.bufferStateTracker = context.getBufferStateTracker();
- this.glStateTracker = context.getGLStateTracker();
- this.glProfile = glp;
-}
-
-public final boolean isGL() {
- return true;
-}
-
-public final boolean isGL4bc() {
- return false;
-}
-
-public final boolean isGL4() {
- return false;
-}
-
-public final boolean isGL3bc() {
- return false;
-}
-
-public final boolean isGL3() {
- return true;
-}
-
-public final boolean isGL2() {
- return false;
-}
-
-public final boolean isGLES1() {
- return false;
-}
-
-public final boolean isGLES2() {
- return false;
-}
-
-public final boolean isGLES() {
- return false;
-}
-
-public final boolean isGL2ES1() {
- return false;
-}
-
-public final boolean isGL2ES2() {
- return true;
-}
-
-public final boolean isGL2GL3() {
- return true;
-}
-
-public final boolean hasGLSL() {
- return true;
-}
-
-public final GL getGL() throws GLException {
- return this;
-}
-
-public final GL4bc getGL4bc() throws GLException {
- throw new GLException("Not a GL4bc implementation");
-}
-
-public final GL4 getGL4() throws GLException {
- throw new GLException("Not a GL4 implementation");
-}
-
-public final GL3bc getGL3bc() throws GLException {
- throw new GLException("Not a GL3bc implementation");
-}
-
-public final GL3 getGL3() throws GLException {
- return this;
-}
-
-public final GL2 getGL2() throws GLException {
- throw new GLException("Not a GL2 implementation");
-}
-
-public final GLES1 getGLES1() throws GLException {
- throw new GLException("Not a GLES1 implementation");
-}
-
-public final GLES2 getGLES2() throws GLException {
- throw new GLException("Not a GLES2 implementation");
-}
-
-public final GL2ES1 getGL2ES1() throws GLException {
- throw new GLException("Not a GLES2ES1 implementation");
-}
-
-public final GL2ES2 getGL2ES2() throws GLException {
- return this;
-}
-
-public final GL2GL3 getGL2GL3() throws GLException {
- return this;
-}
-
-public boolean isFunctionAvailable(String glFunctionName) {
- return _context.isFunctionAvailable(glFunctionName);
-}
-
-public boolean isExtensionAvailable(String glExtensionName) {
- return _context.isExtensionAvailable(glExtensionName);
-}
-
-public Object getExtension(String extensionName) {
- // At this point we don't expose any extensions using this mechanism
- return null;
-}
-
-/** Returns the context this GL object is associated with for better
- error checking by DebugGL. */
-public GLContext getContext() {
- return _context;
-}
-
-private GLContextImpl _context;
-
-/**
- * Provides platform-independent access to the wglAllocateMemoryNV /
- * glXAllocateMemoryNV extension.
- */
-public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
- return _context.glAllocateMemoryNV(arg0, arg1, arg2, arg3);
-}
-
-public void setSwapInterval(int interval) {
- _context.setSwapInterval(interval);
-}
-
-public int getSwapInterval() {
- return _context.getSwapInterval();
-}
-
-public Object getPlatformGLExtensions() {
- return _context.getPlatformGLExtensions();
-}
-
-//
-// Helpers for ensuring the correct amount of texture data
-//
-
-/** Returns the number of bytes required to fill in the appropriate
- texture. This is computed as closely as possible based on the
- pixel pack or unpack parameters. The logic in this routine is
- based on code in the SGI OpenGL sample implementation. */
-
-private int imageSizeInBytes(int format, int type, int w, int h, int d,
- boolean pack) {
- int elements = 0;
- int esize = 0;
-
- if (w < 0) return 0;
- if (h < 0) return 0;
- if (d < 0) return 0;
- switch (format) {
- case GL_STENCIL_INDEX:
- elements = 1;
- break;
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_DEPTH_COMPONENT:
- elements = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- elements = 2;
- break;
- case GL_RGB:
- case GL_BGR:
- elements = 3;
- break;
- case GL_RGBA:
- case GL_BGRA:
- elements = 4;
- break;
- /* FIXME ??
- case GL_HILO_NV:
- elements = 2;
- break; */
- default:
- return 0;
- }
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- esize = 1;
- break;
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- esize = 1;
- elements = 1;
- break;
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- esize = 2;
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- esize = 2;
- elements = 1;
- break;
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- esize = 4;
- break;
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- esize = 4;
- elements = 1;
- break;
- default:
- return 0;
- }
- return imageSizeInBytes(elements * esize, w, h, d, pack);
-}
-
-private GLBufferSizeTracker bufferSizeTracker;
-private GLBufferStateTracker bufferStateTracker;
-private GLStateTracker glStateTracker;
-
-private boolean bufferObjectExtensionsInitialized = false;
-private boolean haveARBPixelBufferObject;
-private boolean haveEXTPixelBufferObject;
-private boolean haveGL15;
-private boolean haveGL21;
-private boolean haveARBVertexBufferObject;
-
-private void initBufferObjectExtensionChecks() {
- if (bufferObjectExtensionsInitialized)
- return;
- bufferObjectExtensionsInitialized = true;
- haveARBPixelBufferObject = isExtensionAvailable("GL_ARB_pixel_buffer_object");
- haveEXTPixelBufferObject = isExtensionAvailable("GL_EXT_pixel_buffer_object");
- haveGL15 = isExtensionAvailable("GL_VERSION_1_5");
- haveGL21 = isExtensionAvailable("GL_VERSION_2_1");
- haveARBVertexBufferObject = isExtensionAvailable("GL_ARB_vertex_buffer_object");
-}
-
-private boolean checkBufferObject(boolean extension1,
- boolean extension2,
- boolean extension3,
- boolean enabled,
- int state,
- String kind, boolean throwException) {
- if (inBeginEndPair) {
- throw new GLException("May not call this between glBegin and glEnd");
- }
- boolean avail = (extension1 || extension2 || extension3);
- if (!avail) {
- if (!enabled)
- return true;
- if(throwException) {
- throw new GLException("Required extensions not available to call this function");
- }
- return false;
- }
- int buffer = bufferStateTracker.getBoundBufferObject(state, this);
- if (enabled) {
- if (buffer == 0) {
- if(throwException) {
- throw new GLException(kind + " must be enabled to call this method");
- }
- return false;
- }
- } else {
- if (buffer != 0) {
- if(throwException) {
- throw new GLException(kind + " must be disabled to call this method");
- }
- return false;
- }
- }
- return true;
-}
-
-private boolean checkArrayVBODisabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveGL15,
- haveARBVertexBufferObject,
- false,
- false,
- GL.GL_ARRAY_BUFFER,
- "array vertex_buffer_object", throwException);
-}
-
-private boolean checkArrayVBOEnabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveGL15,
- haveARBVertexBufferObject,
- false,
- true,
- GL.GL_ARRAY_BUFFER,
- "array vertex_buffer_object", throwException);
-}
-
-private boolean checkElementVBODisabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveGL15,
- haveARBVertexBufferObject,
- false,
- false,
- GL.GL_ELEMENT_ARRAY_BUFFER,
- "element vertex_buffer_object", throwException);
-}
-
-private boolean checkElementVBOEnabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveGL15,
- haveARBVertexBufferObject,
- false,
- true,
- GL.GL_ELEMENT_ARRAY_BUFFER,
- "element vertex_buffer_object", throwException);
-}
-
-private boolean checkUnpackPBODisabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveARBPixelBufferObject,
- haveEXTPixelBufferObject,
- haveGL21,
- false,
- GL2.GL_PIXEL_UNPACK_BUFFER,
- "unpack pixel_buffer_object", throwException);
-}
-
-private boolean checkUnpackPBOEnabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveARBPixelBufferObject,
- haveEXTPixelBufferObject,
- haveGL21,
- true,
- GL2.GL_PIXEL_UNPACK_BUFFER,
- "unpack pixel_buffer_object", throwException);
-}
-
-private boolean checkPackPBODisabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveARBPixelBufferObject,
- haveEXTPixelBufferObject,
- haveGL21,
- false,
- GL2.GL_PIXEL_PACK_BUFFER,
- "pack pixel_buffer_object", throwException);
-}
-
-private boolean checkPackPBOEnabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveARBPixelBufferObject,
- haveEXTPixelBufferObject,
- haveGL21,
- true,
- GL2.GL_PIXEL_PACK_BUFFER,
- "pack pixel_buffer_object", throwException);
-}
-
-public boolean glIsPBOPackEnabled() {
- return checkPackPBOEnabled(false);
-}
-
-public boolean glIsPBOUnpackEnabled() {
- return checkUnpackPBOEnabled(false);
-}
-
-// Attempt to return the same ByteBuffer object from glMapBuffer if
-// the vertex buffer object's base address and size haven't changed
-private static class ARBVBOKey {
- private long addr;
- private int capacity;
-
- ARBVBOKey(long addr, int capacity) {
- this.addr = addr;
- this.capacity = capacity;
- }
-
- public int hashCode() {
- return (int) addr;
- }
-
- public boolean equals(Object o) {
- if ((o == null) || (!(o instanceof ARBVBOKey))) {
- return false;
- }
-
- ARBVBOKey other = (ARBVBOKey) o;
- return ((addr == other.addr) && (capacity == other.capacity));
- }
-}
-
-private Map/*
LPVOID glMapBuffer(GLenum target, GLenum access);
*/
-public java.nio.ByteBuffer glMapBuffer(int target, int access) {
- final long __addr_ = ((GL3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer;
- if (__addr_ == 0) {
- throw new GLException("Method \"glMapBuffer\" not available");
- }
- int sz = bufferSizeTracker.getBufferSize(bufferStateTracker,
- target,
- this);
- long addr;
- addr = dispatch_glMapBuffer(target, access, __addr_);
- if (addr == 0 || sz == 0) {
- return null;
- }
- ARBVBOKey key = new ARBVBOKey(addr, sz);
- ByteBuffer _res = (ByteBuffer) arbVBOCache.get(key);
- if (_res == null) {
- _res = newDirectByteBuffer(addr, sz);
- InternalBufferUtil.nativeOrder(_res);
- arbVBOCache.put(key, _res);
- }
- _res.position(0);
- return _res;
-}
-
-/** Encapsulates function pointer for OpenGL function
: LPVOID glMapBuffer(GLenum target, GLenum access);
*/
-native private long dispatch_glMapBuffer(int target, int access, long glProcAddress);
-
-native private ByteBuffer newDirectByteBuffer(long addr, int capacity);
-
- /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
- public void glShaderBinary(int n, java.nio.IntBuffer shaders, int binaryformat, java.nio.Buffer binary, int length) {
- throw new GLException("Method \"glShaderBinary\" not available");
- }
-
- /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
- public void glShaderBinary(int n, int[] shaders, int shaders_offset, int binaryformat, java.nio.Buffer binary, int length) {
- throw new GLException("Method \"glShaderBinary\" not available");
- }
-
- public void glReleaseShaderCompiler() {
- // nothing to do
- }
-
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl3bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl3bc.java
deleted file mode 100644
index 2f804a218..000000000
--- a/make/config/jogl/gl-impl-CustomJavaCode-gl3bc.java
+++ /dev/null
@@ -1,514 +0,0 @@
-// Tracks glBegin/glEnd calls to determine whether it is legal to
-// query Vertex Buffer Object state
-private boolean inBeginEndPair;
-
-/* FIXME: refactor dependence on Java 2D / JOGL bridge
-
-// Tracks creation and destruction of server-side OpenGL objects when
-// the Java2D/OpenGL pipeline is enabled and it is using frame buffer
-// objects (FBOs) to do its rendering
-private GLObjectTracker tracker;
-
-public void setObjectTracker(GLObjectTracker tracker) {
- this.tracker = tracker;
-}
-
-*/
-
-
-public GL3bcImpl(GLProfile glp, GLContextImpl context) {
- this._context = context;
- this.bufferSizeTracker = context.getBufferSizeTracker();
- this.bufferStateTracker = context.getBufferStateTracker();
- this.glStateTracker = context.getGLStateTracker();
- this.glProfile = glp;
-}
-
-public final boolean isGL() {
- return true;
-}
-
-public final boolean isGL4bc() {
- return false;
-}
-
-public final boolean isGL4() {
- return false;
-}
-
-public final boolean isGL3bc() {
- return true;
-}
-
-public final boolean isGL3() {
- return true;
-}
-
-public final boolean isGL2() {
- return true;
-}
-
-public final boolean isGLES1() {
- return false;
-}
-
-public final boolean isGLES2() {
- return false;
-}
-
-public final boolean isGLES() {
- return false;
-}
-
-public final boolean isGL2ES1() {
- return true;
-}
-
-public final boolean isGL2ES2() {
- return true;
-}
-
-public final boolean isGL2GL3() {
- return true;
-}
-
-public final boolean hasGLSL() {
- return true;
-}
-
-public final GL getGL() throws GLException {
- return this;
-}
-
-public final GL4bc getGL4bc() throws GLException {
- throw new GLException("Not a GL4bc implementation");
-}
-
-public final GL4 getGL4() throws GLException {
- throw new GLException("Not a GL4 implementation");
-}
-
-public final GL3bc getGL3bc() throws GLException {
- return this;
-}
-
-public final GL3 getGL3() throws GLException {
- return this;
-}
-
-public final GL2 getGL2() throws GLException {
- return this;
-}
-
-public final GLES1 getGLES1() throws GLException {
- throw new GLException("Not a GLES1 implementation");
-}
-
-public final GLES2 getGLES2() throws GLException {
- throw new GLException("Not a GLES2 implementation");
-}
-
-public final GL2ES1 getGL2ES1() throws GLException {
- return this;
-}
-
-public final GL2ES2 getGL2ES2() throws GLException {
- return this;
-}
-
-public final GL2GL3 getGL2GL3() throws GLException {
- return this;
-}
-
-public boolean isFunctionAvailable(String glFunctionName) {
- return _context.isFunctionAvailable(glFunctionName);
-}
-
-public boolean isExtensionAvailable(String glExtensionName) {
- return _context.isExtensionAvailable(glExtensionName);
-}
-
-public Object getExtension(String extensionName) {
- // At this point we don't expose any extensions using this mechanism
- return null;
-}
-
-/** Returns the context this GL object is associated with for better
- error checking by DebugGL. */
-public GLContext getContext() {
- return _context;
-}
-
-private GLContextImpl _context;
-
-/**
- * Provides platform-independent access to the wglAllocateMemoryNV /
- * glXAllocateMemoryNV extension.
- */
-public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
- return _context.glAllocateMemoryNV(arg0, arg1, arg2, arg3);
-}
-
-public void setSwapInterval(int interval) {
- _context.setSwapInterval(interval);
-}
-
-public int getSwapInterval() {
- return _context.getSwapInterval();
-}
-
-public Object getPlatformGLExtensions() {
- return _context.getPlatformGLExtensions();
-}
-
-//
-// Helpers for ensuring the correct amount of texture data
-//
-
-/** Returns the number of bytes required to fill in the appropriate
- texture. This is computed as closely as possible based on the
- pixel pack or unpack parameters. The logic in this routine is
- based on code in the SGI OpenGL sample implementation. */
-
-private int imageSizeInBytes(int format, int type, int w, int h, int d,
- boolean pack) {
- int elements = 0;
- int esize = 0;
-
- if (w < 0) return 0;
- if (h < 0) return 0;
- if (d < 0) return 0;
- switch (format) {
- case GL_COLOR_INDEX:
- case GL_STENCIL_INDEX:
- elements = 1;
- break;
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_DEPTH_COMPONENT:
- elements = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- elements = 2;
- break;
- case GL_RGB:
- case GL_BGR:
- elements = 3;
- break;
- case GL_RGBA:
- case GL_BGRA:
- case GL_ABGR_EXT:
- elements = 4;
- break;
- /* FIXME ??
- case GL_HILO_NV:
- elements = 2;
- break; */
- default:
- return 0;
- }
- switch (type) {
- case GL_BITMAP:
- if (format == GL_COLOR_INDEX) {
- return (d * (h * ((w+7)/8)));
- } else {
- return 0;
- }
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- esize = 1;
- break;
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- esize = 1;
- elements = 1;
- break;
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- esize = 2;
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- esize = 2;
- elements = 1;
- break;
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- esize = 4;
- break;
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- esize = 4;
- elements = 1;
- break;
- default:
- return 0;
- }
- return imageSizeInBytes(elements * esize, w, h, d, pack);
-}
-
-private GLBufferSizeTracker bufferSizeTracker;
-private GLBufferStateTracker bufferStateTracker;
-private GLStateTracker glStateTracker;
-
-private boolean bufferObjectExtensionsInitialized = false;
-private boolean haveARBPixelBufferObject;
-private boolean haveEXTPixelBufferObject;
-private boolean haveGL15;
-private boolean haveGL21;
-private boolean haveARBVertexBufferObject;
-
-private void initBufferObjectExtensionChecks() {
- if (bufferObjectExtensionsInitialized)
- return;
- bufferObjectExtensionsInitialized = true;
- haveARBPixelBufferObject = isExtensionAvailable("GL_ARB_pixel_buffer_object");
- haveEXTPixelBufferObject = isExtensionAvailable("GL_EXT_pixel_buffer_object");
- haveGL15 = isExtensionAvailable("GL_VERSION_1_5");
- haveGL21 = isExtensionAvailable("GL_VERSION_2_1");
- haveARBVertexBufferObject = isExtensionAvailable("GL_ARB_vertex_buffer_object");
-}
-
-private boolean checkBufferObject(boolean extension1,
- boolean extension2,
- boolean extension3,
- boolean enabled,
- int state,
- String kind, boolean throwException) {
- if (inBeginEndPair) {
- throw new GLException("May not call this between glBegin and glEnd");
- }
- boolean avail = (extension1 || extension2 || extension3);
- if (!avail) {
- if (!enabled)
- return true;
- if(throwException) {
- throw new GLException("Required extensions not available to call this function");
- }
- return false;
- }
- int buffer = bufferStateTracker.getBoundBufferObject(state, this);
- if (enabled) {
- if (buffer == 0) {
- if(throwException) {
- throw new GLException(kind + " must be enabled to call this method");
- }
- return false;
- }
- } else {
- if (buffer != 0) {
- if(throwException) {
- throw new GLException(kind + " must be disabled to call this method");
- }
- return false;
- }
- }
- return true;
-}
-
-private boolean checkArrayVBODisabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveGL15,
- haveARBVertexBufferObject,
- false,
- false,
- GL.GL_ARRAY_BUFFER,
- "array vertex_buffer_object", throwException);
-}
-
-private boolean checkArrayVBOEnabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveGL15,
- haveARBVertexBufferObject,
- false,
- true,
- GL.GL_ARRAY_BUFFER,
- "array vertex_buffer_object", throwException);
-}
-
-private boolean checkElementVBODisabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveGL15,
- haveARBVertexBufferObject,
- false,
- false,
- GL.GL_ELEMENT_ARRAY_BUFFER,
- "element vertex_buffer_object", throwException);
-}
-
-private boolean checkElementVBOEnabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveGL15,
- haveARBVertexBufferObject,
- false,
- true,
- GL.GL_ELEMENT_ARRAY_BUFFER,
- "element vertex_buffer_object", throwException);
-}
-
-private boolean checkUnpackPBODisabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveARBPixelBufferObject,
- haveEXTPixelBufferObject,
- haveGL21,
- false,
- GL2.GL_PIXEL_UNPACK_BUFFER,
- "unpack pixel_buffer_object", throwException);
-}
-
-private boolean checkUnpackPBOEnabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveARBPixelBufferObject,
- haveEXTPixelBufferObject,
- haveGL21,
- true,
- GL2.GL_PIXEL_UNPACK_BUFFER,
- "unpack pixel_buffer_object", throwException);
-}
-
-private boolean checkPackPBODisabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveARBPixelBufferObject,
- haveEXTPixelBufferObject,
- haveGL21,
- false,
- GL2.GL_PIXEL_PACK_BUFFER,
- "pack pixel_buffer_object", throwException);
-}
-
-private boolean checkPackPBOEnabled(boolean throwException) {
- initBufferObjectExtensionChecks();
- return checkBufferObject(haveARBPixelBufferObject,
- haveEXTPixelBufferObject,
- haveGL21,
- true,
- GL2.GL_PIXEL_PACK_BUFFER,
- "pack pixel_buffer_object", throwException);
-}
-
-public boolean glIsPBOPackEnabled() {
- return checkPackPBOEnabled(false);
-}
-
-public boolean glIsPBOUnpackEnabled() {
- return checkUnpackPBOEnabled(false);
-}
-
-// Attempt to return the same ByteBuffer object from glMapBuffer if
-// the vertex buffer object's base address and size haven't changed
-private static class ARBVBOKey {
- private long addr;
- private int capacity;
-
- ARBVBOKey(long addr, int capacity) {
- this.addr = addr;
- this.capacity = capacity;
- }
-
- public int hashCode() {
- return (int) addr;
- }
-
- public boolean equals(Object o) {
- if ((o == null) || (!(o instanceof ARBVBOKey))) {
- return false;
- }
-
- ARBVBOKey other = (ARBVBOKey) o;
- return ((addr == other.addr) && (capacity == other.capacity));
- }
-}
-
-private Map/*
LPVOID glMapBuffer(GLenum target, GLenum access);
*/
-public java.nio.ByteBuffer glMapBuffer(int target, int access) {
- final long __addr_ = ((GL3bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer;
- if (__addr_ == 0) {
- throw new GLException("Method \"glMapBuffer\" not available");
- }
- int sz = bufferSizeTracker.getBufferSize(bufferStateTracker,
- target,
- this);
- long addr;
- addr = dispatch_glMapBuffer(target, access, __addr_);
- if (addr == 0 || sz == 0) {
- return null;
- }
- ARBVBOKey key = new ARBVBOKey(addr, sz);
- ByteBuffer _res = (ByteBuffer) arbVBOCache.get(key);
- if (_res == null) {
- _res = newDirectByteBuffer(addr, sz);
- InternalBufferUtil.nativeOrder(_res);
- arbVBOCache.put(key, _res);
- }
- _res.position(0);
- return _res;
-}
-
-/** Encapsulates function pointer for OpenGL function
: LPVOID glMapBuffer(GLenum target, GLenum access);
*/
-native private long dispatch_glMapBuffer(int target, int access, long glProcAddress);
-
-native private ByteBuffer newDirectByteBuffer(long addr, int capacity);
-
- /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
- public void glShaderBinary(int n, java.nio.IntBuffer shaders, int binaryformat, java.nio.Buffer binary, int length) {
- throw new GLException("Method \"glShaderBinary\" not available");
- }
-
- /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
- public void glShaderBinary(int n, int[] shaders, int shaders_offset, int binaryformat, java.nio.Buffer binary, int length) {
- throw new GLException("Method \"glShaderBinary\" not available");
- }
-
- public void glReleaseShaderCompiler() {
- // nothing to do
- }
-
- public void glVertexPointer(GLArrayData array) {
- if(array.getComponentNumber()==0) return;
- if(array.isVBO()) {
- glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
- } else {
- glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
- }
- }
- public void glColorPointer(GLArrayData array) {
- if(array.getComponentNumber()==0) return;
- if(array.isVBO()) {
- glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
- } else {
- glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
- }
-
- }
- public void glNormalPointer(GLArrayData array) {
- if(array.getComponentNumber()==0) return;
- if(array.getComponentNumber()!=3) {
- throw new GLException("Only 3 components per normal allowed");
- }
- if(array.isVBO()) {
- glNormalPointer(array.getComponentType(), array.getStride(), array.getOffset());
- } else {
- glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer());
- }
- }
- public void glTexCoordPointer(GLArrayData array) {
- if(array.getComponentNumber()==0) return;
- if(array.isVBO()) {
- glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
- } else {
- glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
- }
- }
-
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4.java
new file mode 100644
index 000000000..a2c70eeee
--- /dev/null
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4.java
@@ -0,0 +1,339 @@
+// Tracks glBegin/glEnd calls to determine whether it is legal to
+// query Vertex Buffer Object state
+private boolean inBeginEndPair;
+
+/* FIXME: refactor dependence on Java 2D / JOGL bridge
+
+// Tracks creation and destruction of server-side OpenGL objects when
+// the Java2D/OpenGL pipeline is enabled and it is using frame buffer
+// objects (FBOs) to do its rendering
+private GLObjectTracker tracker;
+
+public void setObjectTracker(GLObjectTracker tracker) {
+ this.tracker = tracker;
+}
+
+*/
+
+public GL3Impl(GLProfile glp, GLContextImpl context) {
+ this._context = context;
+ this.bufferSizeTracker = context.getBufferSizeTracker();
+ this.bufferStateTracker = context.getBufferStateTracker();
+ this.glStateTracker = context.getGLStateTracker();
+ this.glProfile = glp;
+}
+
+/**
+ * Provides platform-independent access to the wglAllocateMemoryNV /
+ * glXAllocateMemoryNV extension.
+ */
+public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
+ return _context.glAllocateMemoryNV(arg0, arg1, arg2, arg3);
+}
+
+//
+// Helpers for ensuring the correct amount of texture data
+//
+
+/** Returns the number of bytes required to fill in the appropriate
+ texture. This is computed as closely as possible based on the
+ pixel pack or unpack parameters. The logic in this routine is
+ based on code in the SGI OpenGL sample implementation. */
+
+private int imageSizeInBytes(int format, int type, int w, int h, int d,
+ boolean pack) {
+ int elements = 0;
+ int esize = 0;
+
+ if (w < 0) return 0;
+ if (h < 0) return 0;
+ if (d < 0) return 0;
+ switch (format) {
+ case GL_STENCIL_INDEX:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_DEPTH_COMPONENT:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ case GL_BGR:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_BGRA:
+ elements = 4;
+ break;
+ /* FIXME ??
+ case GL_HILO_NV:
+ elements = 2;
+ break; */
+ default:
+ return 0;
+ }
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return 0;
+ }
+ return imageSizeInBytes(elements * esize, w, h, d, pack);
+}
+
+private GLBufferSizeTracker bufferSizeTracker;
+private GLBufferStateTracker bufferStateTracker;
+private GLStateTracker glStateTracker;
+
+private boolean bufferObjectExtensionsInitialized = false;
+private boolean haveARBPixelBufferObject;
+private boolean haveEXTPixelBufferObject;
+private boolean haveGL15;
+private boolean haveGL21;
+private boolean haveARBVertexBufferObject;
+
+private void initBufferObjectExtensionChecks() {
+ if (bufferObjectExtensionsInitialized)
+ return;
+ bufferObjectExtensionsInitialized = true;
+ haveARBPixelBufferObject = isExtensionAvailable("GL_ARB_pixel_buffer_object");
+ haveEXTPixelBufferObject = isExtensionAvailable("GL_EXT_pixel_buffer_object");
+ haveGL15 = isExtensionAvailable("GL_VERSION_1_5");
+ haveGL21 = isExtensionAvailable("GL_VERSION_2_1");
+ haveARBVertexBufferObject = isExtensionAvailable("GL_ARB_vertex_buffer_object");
+}
+
+private boolean checkBufferObject(boolean extension1,
+ boolean extension2,
+ boolean extension3,
+ boolean enabled,
+ int state,
+ String kind, boolean throwException) {
+ if (inBeginEndPair) {
+ throw new GLException("May not call this between glBegin and glEnd");
+ }
+ boolean avail = (extension1 || extension2 || extension3);
+ if (!avail) {
+ if (!enabled)
+ return true;
+ if(throwException) {
+ throw new GLException("Required extensions not available to call this function");
+ }
+ return false;
+ }
+ int buffer = bufferStateTracker.getBoundBufferObject(state, this);
+ if (enabled) {
+ if (buffer == 0) {
+ if(throwException) {
+ throw new GLException(kind + " must be enabled to call this method");
+ }
+ return false;
+ }
+ } else {
+ if (buffer != 0) {
+ if(throwException) {
+ throw new GLException(kind + " must be disabled to call this method");
+ }
+ return false;
+ }
+ }
+ return true;
+}
+
+private boolean checkArrayVBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ false,
+ GL.GL_ARRAY_BUFFER,
+ "array vertex_buffer_object", throwException);
+}
+
+private boolean checkArrayVBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ true,
+ GL.GL_ARRAY_BUFFER,
+ "array vertex_buffer_object", throwException);
+}
+
+private boolean checkElementVBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ false,
+ GL.GL_ELEMENT_ARRAY_BUFFER,
+ "element vertex_buffer_object", throwException);
+}
+
+private boolean checkElementVBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ true,
+ GL.GL_ELEMENT_ARRAY_BUFFER,
+ "element vertex_buffer_object", throwException);
+}
+
+private boolean checkUnpackPBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveARBPixelBufferObject,
+ haveEXTPixelBufferObject,
+ haveGL21,
+ false,
+ GL2.GL_PIXEL_UNPACK_BUFFER,
+ "unpack pixel_buffer_object", throwException);
+}
+
+private boolean checkUnpackPBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveARBPixelBufferObject,
+ haveEXTPixelBufferObject,
+ haveGL21,
+ true,
+ GL2.GL_PIXEL_UNPACK_BUFFER,
+ "unpack pixel_buffer_object", throwException);
+}
+
+private boolean checkPackPBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveARBPixelBufferObject,
+ haveEXTPixelBufferObject,
+ haveGL21,
+ false,
+ GL2.GL_PIXEL_PACK_BUFFER,
+ "pack pixel_buffer_object", throwException);
+}
+
+private boolean checkPackPBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveARBPixelBufferObject,
+ haveEXTPixelBufferObject,
+ haveGL21,
+ true,
+ GL2.GL_PIXEL_PACK_BUFFER,
+ "pack pixel_buffer_object", throwException);
+}
+
+public boolean glIsPBOPackEnabled() {
+ return checkPackPBOEnabled(false);
+}
+
+public boolean glIsPBOUnpackEnabled() {
+ return checkUnpackPBOEnabled(false);
+}
+
+// Attempt to return the same ByteBuffer object from glMapBuffer if
+// the vertex buffer object's base address and size haven't changed
+private static class ARBVBOKey {
+ private long addr;
+ private int capacity;
+
+ ARBVBOKey(long addr, int capacity) {
+ this.addr = addr;
+ this.capacity = capacity;
+ }
+
+ public int hashCode() {
+ return (int) addr;
+ }
+
+ public boolean equals(Object o) {
+ if ((o == null) || (!(o instanceof ARBVBOKey))) {
+ return false;
+ }
+
+ ARBVBOKey other = (ARBVBOKey) o;
+ return ((addr == other.addr) && (capacity == other.capacity));
+ }
+}
+
+private Map/*
LPVOID glMapBuffer(GLenum target, GLenum access);
*/
+public java.nio.ByteBuffer glMapBuffer(int target, int access) {
+ final long __addr_ = ((GL3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer;
+ if (__addr_ == 0) {
+ throw new GLException("Method \"glMapBuffer\" not available");
+ }
+ int sz = bufferSizeTracker.getBufferSize(bufferStateTracker,
+ target,
+ this);
+ long addr;
+ addr = dispatch_glMapBuffer(target, access, __addr_);
+ if (addr == 0 || sz == 0) {
+ return null;
+ }
+ ARBVBOKey key = new ARBVBOKey(addr, sz);
+ ByteBuffer _res = (ByteBuffer) arbVBOCache.get(key);
+ if (_res == null) {
+ _res = newDirectByteBuffer(addr, sz);
+ InternalBufferUtil.nativeOrder(_res);
+ arbVBOCache.put(key, _res);
+ }
+ _res.position(0);
+ return _res;
+}
+
+/** Encapsulates function pointer for OpenGL function
: LPVOID glMapBuffer(GLenum target, GLenum access);
*/
+native private long dispatch_glMapBuffer(int target, int access, long glProcAddress);
+
+native private ByteBuffer newDirectByteBuffer(long addr, int capacity);
+
+ /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
+ public void glShaderBinary(int n, java.nio.IntBuffer shaders, int binaryformat, java.nio.Buffer binary, int length) {
+ throw new GLException("Method \"glShaderBinary\" not available");
+ }
+
+ /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
+ public void glShaderBinary(int n, int[] shaders, int shaders_offset, int binaryformat, java.nio.Buffer binary, int length) {
+ throw new GLException("Method \"glShaderBinary\" not available");
+ }
+
+ public void glReleaseShaderCompiler() {
+ // nothing to do
+ }
+
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java
new file mode 100644
index 000000000..bceb12fe5
--- /dev/null
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java
@@ -0,0 +1,385 @@
+// Tracks glBegin/glEnd calls to determine whether it is legal to
+// query Vertex Buffer Object state
+private boolean inBeginEndPair;
+
+/* FIXME: refactor dependence on Java 2D / JOGL bridge
+
+// Tracks creation and destruction of server-side OpenGL objects when
+// the Java2D/OpenGL pipeline is enabled and it is using frame buffer
+// objects (FBOs) to do its rendering
+private GLObjectTracker tracker;
+
+public void setObjectTracker(GLObjectTracker tracker) {
+ this.tracker = tracker;
+}
+
+*/
+
+
+public GL4bcImpl(GLProfile glp, GLContextImpl context) {
+ this._context = context;
+ this.bufferSizeTracker = context.getBufferSizeTracker();
+ this.bufferStateTracker = context.getBufferStateTracker();
+ this.glStateTracker = context.getGLStateTracker();
+ this.glProfile = glp;
+}
+
+/**
+ * Provides platform-independent access to the wglAllocateMemoryNV /
+ * glXAllocateMemoryNV extension.
+ */
+public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
+ return _context.glAllocateMemoryNV(arg0, arg1, arg2, arg3);
+}
+
+//
+// Helpers for ensuring the correct amount of texture data
+//
+
+/** Returns the number of bytes required to fill in the appropriate
+ texture. This is computed as closely as possible based on the
+ pixel pack or unpack parameters. The logic in this routine is
+ based on code in the SGI OpenGL sample implementation. */
+
+private int imageSizeInBytes(int format, int type, int w, int h, int d,
+ boolean pack) {
+ int elements = 0;
+ int esize = 0;
+
+ if (w < 0) return 0;
+ if (h < 0) return 0;
+ if (d < 0) return 0;
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_DEPTH_COMPONENT:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ case GL_BGR:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ elements = 4;
+ break;
+ /* FIXME ??
+ case GL_HILO_NV:
+ elements = 2;
+ break; */
+ default:
+ return 0;
+ }
+ switch (type) {
+ case GL_BITMAP:
+ if (format == GL_COLOR_INDEX) {
+ return (d * (h * ((w+7)/8)));
+ } else {
+ return 0;
+ }
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return 0;
+ }
+ return imageSizeInBytes(elements * esize, w, h, d, pack);
+}
+
+private GLBufferSizeTracker bufferSizeTracker;
+private GLBufferStateTracker bufferStateTracker;
+private GLStateTracker glStateTracker;
+
+private boolean bufferObjectExtensionsInitialized = false;
+private boolean haveARBPixelBufferObject;
+private boolean haveEXTPixelBufferObject;
+private boolean haveGL15;
+private boolean haveGL21;
+private boolean haveARBVertexBufferObject;
+
+private void initBufferObjectExtensionChecks() {
+ if (bufferObjectExtensionsInitialized)
+ return;
+ bufferObjectExtensionsInitialized = true;
+ haveARBPixelBufferObject = isExtensionAvailable("GL_ARB_pixel_buffer_object");
+ haveEXTPixelBufferObject = isExtensionAvailable("GL_EXT_pixel_buffer_object");
+ haveGL15 = isExtensionAvailable("GL_VERSION_1_5");
+ haveGL21 = isExtensionAvailable("GL_VERSION_2_1");
+ haveARBVertexBufferObject = isExtensionAvailable("GL_ARB_vertex_buffer_object");
+}
+
+private boolean checkBufferObject(boolean extension1,
+ boolean extension2,
+ boolean extension3,
+ boolean enabled,
+ int state,
+ String kind, boolean throwException) {
+ if (inBeginEndPair) {
+ throw new GLException("May not call this between glBegin and glEnd");
+ }
+ boolean avail = (extension1 || extension2 || extension3);
+ if (!avail) {
+ if (!enabled)
+ return true;
+ if(throwException) {
+ throw new GLException("Required extensions not available to call this function");
+ }
+ return false;
+ }
+ int buffer = bufferStateTracker.getBoundBufferObject(state, this);
+ if (enabled) {
+ if (buffer == 0) {
+ if(throwException) {
+ throw new GLException(kind + " must be enabled to call this method");
+ }
+ return false;
+ }
+ } else {
+ if (buffer != 0) {
+ if(throwException) {
+ throw new GLException(kind + " must be disabled to call this method");
+ }
+ return false;
+ }
+ }
+ return true;
+}
+
+private boolean checkArrayVBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ false,
+ GL.GL_ARRAY_BUFFER,
+ "array vertex_buffer_object", throwException);
+}
+
+private boolean checkArrayVBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ true,
+ GL.GL_ARRAY_BUFFER,
+ "array vertex_buffer_object", throwException);
+}
+
+private boolean checkElementVBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ false,
+ GL.GL_ELEMENT_ARRAY_BUFFER,
+ "element vertex_buffer_object", throwException);
+}
+
+private boolean checkElementVBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ true,
+ GL.GL_ELEMENT_ARRAY_BUFFER,
+ "element vertex_buffer_object", throwException);
+}
+
+private boolean checkUnpackPBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveARBPixelBufferObject,
+ haveEXTPixelBufferObject,
+ haveGL21,
+ false,
+ GL2.GL_PIXEL_UNPACK_BUFFER,
+ "unpack pixel_buffer_object", throwException);
+}
+
+private boolean checkUnpackPBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveARBPixelBufferObject,
+ haveEXTPixelBufferObject,
+ haveGL21,
+ true,
+ GL2.GL_PIXEL_UNPACK_BUFFER,
+ "unpack pixel_buffer_object", throwException);
+}
+
+private boolean checkPackPBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveARBPixelBufferObject,
+ haveEXTPixelBufferObject,
+ haveGL21,
+ false,
+ GL2.GL_PIXEL_PACK_BUFFER,
+ "pack pixel_buffer_object", throwException);
+}
+
+private boolean checkPackPBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveARBPixelBufferObject,
+ haveEXTPixelBufferObject,
+ haveGL21,
+ true,
+ GL2.GL_PIXEL_PACK_BUFFER,
+ "pack pixel_buffer_object", throwException);
+}
+
+public boolean glIsPBOPackEnabled() {
+ return checkPackPBOEnabled(false);
+}
+
+public boolean glIsPBOUnpackEnabled() {
+ return checkUnpackPBOEnabled(false);
+}
+
+// Attempt to return the same ByteBuffer object from glMapBuffer if
+// the vertex buffer object's base address and size haven't changed
+private static class ARBVBOKey {
+ private long addr;
+ private int capacity;
+
+ ARBVBOKey(long addr, int capacity) {
+ this.addr = addr;
+ this.capacity = capacity;
+ }
+
+ public int hashCode() {
+ return (int) addr;
+ }
+
+ public boolean equals(Object o) {
+ if ((o == null) || (!(o instanceof ARBVBOKey))) {
+ return false;
+ }
+
+ ARBVBOKey other = (ARBVBOKey) o;
+ return ((addr == other.addr) && (capacity == other.capacity));
+ }
+}
+
+private Map/*
LPVOID glMapBuffer(GLenum target, GLenum access);
*/
+public java.nio.ByteBuffer glMapBuffer(int target, int access) {
+ final long __addr_ = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer;
+ if (__addr_ == 0) {
+ throw new GLException("Method \"glMapBuffer\" not available");
+ }
+ int sz = bufferSizeTracker.getBufferSize(bufferStateTracker,
+ target,
+ this);
+ long addr;
+ addr = dispatch_glMapBuffer(target, access, __addr_);
+ if (addr == 0 || sz == 0) {
+ return null;
+ }
+ ARBVBOKey key = new ARBVBOKey(addr, sz);
+ ByteBuffer _res = (ByteBuffer) arbVBOCache.get(key);
+ if (_res == null) {
+ _res = newDirectByteBuffer(addr, sz);
+ InternalBufferUtil.nativeOrder(_res);
+ arbVBOCache.put(key, _res);
+ }
+ _res.position(0);
+ return _res;
+}
+
+/** Encapsulates function pointer for OpenGL function
: LPVOID glMapBuffer(GLenum target, GLenum access);
*/
+native private long dispatch_glMapBuffer(int target, int access, long glProcAddress);
+
+native private ByteBuffer newDirectByteBuffer(long addr, int capacity);
+
+ /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
+ public void glShaderBinary(int n, java.nio.IntBuffer shaders, int binaryformat, java.nio.Buffer binary, int length) {
+ throw new GLException("Method \"glShaderBinary\" not available");
+ }
+
+ /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
+ public void glShaderBinary(int n, int[] shaders, int shaders_offset, int binaryformat, java.nio.Buffer binary, int length) {
+ throw new GLException("Method \"glShaderBinary\" not available");
+ }
+
+ public void glReleaseShaderCompiler() {
+ // nothing to do
+ }
+
+ public void glVertexPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.isVBO()) {
+ glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
+ } else {
+ glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+ }
+ public void glColorPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.isVBO()) {
+ glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
+ } else {
+ glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+
+ }
+ public void glNormalPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.getComponentNumber()!=3) {
+ throw new GLException("Only 3 components per normal allowed");
+ }
+ if(array.isVBO()) {
+ glNormalPointer(array.getComponentType(), array.getStride(), array.getOffset());
+ } else {
+ glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+ }
+ public void glTexCoordPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.isVBO()) {
+ glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
+ } else {
+ glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+ }
+
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
index 6fb8a32ef..b4efac8a1 100755
--- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
@@ -6,10 +6,6 @@ public GLES1Impl(GLProfile glp, GLContextImpl context) {
this.glProfile = glp;
}
-public final boolean isGL() {
- return true;
-}
-
public final boolean isGL4bc() {
return false;
}
@@ -58,10 +54,6 @@ public final boolean hasGLSL() {
return false;
}
-public final GL getGL() throws GLException {
- return this;
-}
-
public final GL4bc getGL4bc() throws GLException {
throw new GLException("Not a GL4bc implementation");
}
@@ -102,39 +94,6 @@ public final GL2GL3 getGL2GL3() throws GLException {
throw new GLException("Not a GL2GL3 implementation");
}
-public boolean isFunctionAvailable(String glFunctionName) {
- return _context.isFunctionAvailable(glFunctionName);
-}
-
-public boolean isExtensionAvailable(String glExtensionName) {
- return _context.isExtensionAvailable(glExtensionName);
-}
-
-public Object getExtension(String extensionName) {
- // At this point we don't expose any extensions using this mechanism
- return null;
-}
-
-/** Returns the context this GL object is associated with for better
- error checking by DebugGL. */
-public GLContext getContext() {
- return _context;
-}
-
-private GLContextImpl _context;
-
-public void setSwapInterval(int interval) {
- _context.setSwapInterval(interval);
-}
-
-public int getSwapInterval() {
- return _context.getSwapInterval();
-}
-
-public Object getPlatformGLExtensions() {
- return _context.getPlatformGLExtensions();
-}
-
//
// Helpers for ensuring the correct amount of texture data
//
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java
index 8204bd1ae..bb8ddb7ef 100755
--- a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java
@@ -10,10 +10,6 @@ public GLES2Impl(GLProfile glp, GLContextImpl context) {
this.glProfile = glp;
}
-public final boolean isGL() {
- return true;
-}
-
public final boolean isGL4bc() {
return false;
}
@@ -62,10 +58,6 @@ public final boolean hasGLSL() {
return true;
}
-public final GL getGL() throws GLException {
- return this;
-}
-
public final GL4bc getGL4bc() throws GLException {
throw new GLException("Not a GL4bc implementation");
}
@@ -106,39 +98,6 @@ public final GL2GL3 getGL2GL3() throws GLException {
throw new GLException("Not a GL2GL3 implementation");
}
-public boolean isFunctionAvailable(String glFunctionName) {
- return _context.isFunctionAvailable(glFunctionName);
-}
-
-public boolean isExtensionAvailable(String glExtensionName) {
- return _context.isExtensionAvailable(glExtensionName);
-}
-
-public Object getExtension(String extensionName) {
- // At this point we don't expose any extensions using this mechanism
- return null;
-}
-
-/** Returns the context this GL object is associated with for better
- error checking by DebugGL. */
-public GLContext getContext() {
- return _context;
-}
-
-private GLContextImpl _context;
-
-public void setSwapInterval(int interval) {
- _context.setSwapInterval(interval);
-}
-
-public int getSwapInterval() {
- return _context.getSwapInterval();
-}
-
-public Object getPlatformGLExtensions() {
- return _context.getPlatformGLExtensions();
-}
-
//
// Helpers for ensuring the correct amount of texture data
//
diff --git a/make/config/jogl/gl3-common.cfg b/make/config/jogl/gl3-common.cfg
index fac8323bb..c2cc2968e 100644
--- a/make/config/jogl/gl3-common.cfg
+++ b/make/config/jogl/gl3-common.cfg
@@ -16,6 +16,9 @@ RenameExtensionIntoCore GL_ARB_geometry_shader4
RenameExtensionIntoCore GL_ARB_sync
# <<< OpenGL 3.2
+# >>> OpenGL 3.3
+# <<< OpenGL 3.3
+
# Ignore GL functions that deal with explicit pointer values in such a
# way that we cannot implement the functionality in Java
Ignore glMultiDrawElementsBaseVertex
diff --git a/make/config/jogl/gl3-desktop-tracker.cfg b/make/config/jogl/gl3-desktop-tracker.cfg
deleted file mode 100644
index 4b9a7edb7..000000000
--- a/make/config/jogl/gl3-desktop-tracker.cfg
+++ /dev/null
@@ -1,38 +0,0 @@
-
-# Track server-side object creation and deletion when necessary
-# Note that this is only necessary when the Java 2D / JOGL bridge is active,
-# so will never be needed for the embedded OpenGL variants
-JavaEpilogue glGenBuffers if (tracker != null) tracker.addBuffers({0}, {1});
-JavaEpilogue glGenFencesAPPLE if (tracker != null) tracker.addFencesAPPLE({0}, {1});
-JavaEpilogue glGenFencesNV if (tracker != null) tracker.addFencesNV({0}, {1});
-JavaEpilogue glGenFragmentShadersATI if (tracker != null) tracker.addFragmentShadersATI(_res, {0});
-JavaEpilogue glGenFramebuffersEXT if (tracker != null) tracker.addFramebuffersEXT({0}, {1});
-JavaEpilogue glGenLists if (tracker != null) tracker.addLists(_res, {0});
-JavaEpilogue glGenOcclusionQueriesNV if (tracker != null) tracker.addOcclusionQueriesNV({0}, {1});
-JavaEpilogue glCreateProgram if (tracker != null) tracker.addProgramObject(_res);
-JavaEpilogue glGenPrograms if (tracker != null) tracker.addPrograms({0}, {1});
-JavaEpilogue glGenQueries if (tracker != null) tracker.addQueries({0}, {1});
-JavaEpilogue glGenRenderbuffersEXT if (tracker != null) tracker.addRenderbuffersEXT({0}, {1});
-JavaEpilogue glCreateShader if (tracker != null) tracker.addShaderObject(_res);
-JavaEpilogue glGenTextures if (tracker != null) tracker.addTextures({0}, {1});
-JavaEpilogue glGenVertexArraysAPPLE if (tracker != null) tracker.addVertexArraysAPPLE({0}, {1});
-JavaEpilogue glGenVertexShadersEXT if (tracker != null) tracker.addVertexShadersEXT(_res, {0});
-
-JavaEpilogue glDeleteBuffers if (tracker != null) tracker.removeBuffers({0}, {1});
-JavaEpilogue glDeleteFencesAPPLE if (tracker != null) tracker.removeFencesAPPLE({0}, {1});
-JavaEpilogue glDeleteFencesNV if (tracker != null) tracker.removeFencesNV({0}, {1});
-JavaEpilogue glDeleteFragmentShaderATI if (tracker != null) tracker.removeFragmentShaderATI({0});
-JavaEpilogue glDeleteFramebuffersEXT if (tracker != null) tracker.removeFramebuffersEXT({0}, {1});
-JavaEpilogue glDeleteLists if (tracker != null) tracker.removeLists({0}, {1});
-JavaEpilogue glDeleteOcclusionQueriesNV if (tracker != null) tracker.removeOcclusionQueriesNV({0}, {1});
-JavaEpilogue glDeleteProgram if (tracker != null) tracker.removeProgramObject({0});
-JavaEpilogue glDeleteObject if (tracker != null) tracker.removeProgramOrShaderObject({0});
-JavaEpilogue glDeletePrograms if (tracker != null) tracker.removePrograms({0}, {1});
-JavaEpilogue glDeleteProgramsNV if (tracker != null) tracker.removeProgramsNV({0}, {1});
-JavaEpilogue glDeleteQueries if (tracker != null) tracker.removeQueries({0}, {1});
-JavaEpilogue glDeleteRenderbuffersEXT if (tracker != null) tracker.removeRenderbuffersEXT({0}, {1});
-JavaEpilogue glDeleteShader if (tracker != null) tracker.removeShaderObject({0});
-JavaEpilogue glDeleteTextures if (tracker != null) tracker.removeTextures({0}, {1});
-JavaEpilogue glDeleteVertexArraysAPPLE if (tracker != null) tracker.removeVertexArraysAPPLE({0}, {1});
-JavaEpilogue glDeleteVertexShaderEXT if (tracker != null) tracker.removeVertexShaderEXT({0});
-
diff --git a/make/config/jogl/gl4-common.cfg b/make/config/jogl/gl4-common.cfg
new file mode 100644
index 000000000..2c119da30
--- /dev/null
+++ b/make/config/jogl/gl4-common.cfg
@@ -0,0 +1,5 @@
+
+# >>> OpenGL 4.0
+# <<< OpenGL 4.0
+
+
diff --git a/make/config/jogl/gl4-desktop-tracker.cfg b/make/config/jogl/gl4-desktop-tracker.cfg
new file mode 100644
index 000000000..4b9a7edb7
--- /dev/null
+++ b/make/config/jogl/gl4-desktop-tracker.cfg
@@ -0,0 +1,38 @@
+
+# Track server-side object creation and deletion when necessary
+# Note that this is only necessary when the Java 2D / JOGL bridge is active,
+# so will never be needed for the embedded OpenGL variants
+JavaEpilogue glGenBuffers if (tracker != null) tracker.addBuffers({0}, {1});
+JavaEpilogue glGenFencesAPPLE if (tracker != null) tracker.addFencesAPPLE({0}, {1});
+JavaEpilogue glGenFencesNV if (tracker != null) tracker.addFencesNV({0}, {1});
+JavaEpilogue glGenFragmentShadersATI if (tracker != null) tracker.addFragmentShadersATI(_res, {0});
+JavaEpilogue glGenFramebuffersEXT if (tracker != null) tracker.addFramebuffersEXT({0}, {1});
+JavaEpilogue glGenLists if (tracker != null) tracker.addLists(_res, {0});
+JavaEpilogue glGenOcclusionQueriesNV if (tracker != null) tracker.addOcclusionQueriesNV({0}, {1});
+JavaEpilogue glCreateProgram if (tracker != null) tracker.addProgramObject(_res);
+JavaEpilogue glGenPrograms if (tracker != null) tracker.addPrograms({0}, {1});
+JavaEpilogue glGenQueries if (tracker != null) tracker.addQueries({0}, {1});
+JavaEpilogue glGenRenderbuffersEXT if (tracker != null) tracker.addRenderbuffersEXT({0}, {1});
+JavaEpilogue glCreateShader if (tracker != null) tracker.addShaderObject(_res);
+JavaEpilogue glGenTextures if (tracker != null) tracker.addTextures({0}, {1});
+JavaEpilogue glGenVertexArraysAPPLE if (tracker != null) tracker.addVertexArraysAPPLE({0}, {1});
+JavaEpilogue glGenVertexShadersEXT if (tracker != null) tracker.addVertexShadersEXT(_res, {0});
+
+JavaEpilogue glDeleteBuffers if (tracker != null) tracker.removeBuffers({0}, {1});
+JavaEpilogue glDeleteFencesAPPLE if (tracker != null) tracker.removeFencesAPPLE({0}, {1});
+JavaEpilogue glDeleteFencesNV if (tracker != null) tracker.removeFencesNV({0}, {1});
+JavaEpilogue glDeleteFragmentShaderATI if (tracker != null) tracker.removeFragmentShaderATI({0});
+JavaEpilogue glDeleteFramebuffersEXT if (tracker != null) tracker.removeFramebuffersEXT({0}, {1});
+JavaEpilogue glDeleteLists if (tracker != null) tracker.removeLists({0}, {1});
+JavaEpilogue glDeleteOcclusionQueriesNV if (tracker != null) tracker.removeOcclusionQueriesNV({0}, {1});
+JavaEpilogue glDeleteProgram if (tracker != null) tracker.removeProgramObject({0});
+JavaEpilogue glDeleteObject if (tracker != null) tracker.removeProgramOrShaderObject({0});
+JavaEpilogue glDeletePrograms if (tracker != null) tracker.removePrograms({0}, {1});
+JavaEpilogue glDeleteProgramsNV if (tracker != null) tracker.removeProgramsNV({0}, {1});
+JavaEpilogue glDeleteQueries if (tracker != null) tracker.removeQueries({0}, {1});
+JavaEpilogue glDeleteRenderbuffersEXT if (tracker != null) tracker.removeRenderbuffersEXT({0}, {1});
+JavaEpilogue glDeleteShader if (tracker != null) tracker.removeShaderObject({0});
+JavaEpilogue glDeleteTextures if (tracker != null) tracker.removeTextures({0}, {1});
+JavaEpilogue glDeleteVertexArraysAPPLE if (tracker != null) tracker.removeVertexArraysAPPLE({0}, {1});
+JavaEpilogue glDeleteVertexShaderEXT if (tracker != null) tracker.removeVertexShaderEXT({0});
+
diff --git a/make/config/jogl/glu-CustomJavaCode-base.java b/make/config/jogl/glu-CustomJavaCode-base.java
index aeb4f2ef9..480f5d117 100755
--- a/make/config/jogl/glu-CustomJavaCode-base.java
+++ b/make/config/jogl/glu-CustomJavaCode-base.java
@@ -169,7 +169,7 @@ protected static boolean checkedGLUtessellatorImpl = false;
protected static final void validateGLUtessellatorImpl() {
if(!checkedGLUtessellatorImpl) {
- availableGLUtessellatorImpl = NWReflection.isClassAvailable("com.jogamp.opengl.impl.glu.tessellator.GLUtessellatorImpl");
+ availableGLUtessellatorImpl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.glu.tessellator.GLUtessellatorImpl");
checkedGLUtessellatorImpl = true;
}
if(!availableGLUtessellatorImpl) {
@@ -1220,7 +1220,7 @@ protected static final void validateGLUquadricImpl() {
if(!checkedGLUquadricImpl) {
synchronized (syncObject) {
if(!checkedGLUquadricImpl) {
- availableGLUquadricImpl = NWReflection.isClassAvailable("com.jogamp.opengl.impl.glu.GLUquadricImpl");
+ availableGLUquadricImpl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.glu.GLUquadricImpl");
checkedGLUquadricImpl = true;
}
}
diff --git a/make/config/jogl/glu-CustomJavaCode-gl2es1.java b/make/config/jogl/glu-CustomJavaCode-gl2es1.java
index b5cb3b2f8..f3b4322d9 100755
--- a/make/config/jogl/glu-CustomJavaCode-gl2es1.java
+++ b/make/config/jogl/glu-CustomJavaCode-gl2es1.java
@@ -86,7 +86,7 @@ protected static boolean checkedMipmap = false;
protected static final void validateMipmap() {
if(!checkedMipmap) {
- availableMipmap = NWReflection.isClassAvailable("com.jogamp.opengl.impl.glu.mipmap.Mipmap");
+ availableMipmap = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.glu.mipmap.Mipmap");
checkedMipmap = true;
}
if(!availableMipmap) {
diff --git a/make/config/jogl/glu-common.cfg b/make/config/jogl/glu-common.cfg
index 937ca0348..f5fc7c1b3 100644
--- a/make/config/jogl/glu-common.cfg
+++ b/make/config/jogl/glu-common.cfg
@@ -14,7 +14,7 @@ Import javax.media.opengl.glu.*
Import com.jogamp.opengl.impl.*
Import com.jogamp.opengl.impl.glu.*
Import com.jogamp.opengl.impl.glu.tessellator.GLUtessellatorImpl
-Import com.jogamp.nativewindow.impl.NWReflection
+Import com.jogamp.common.util.ReflectionUtil
# Raise GLException instead of RuntimeException in glue code
RuntimeExceptionType GLException
diff --git a/make/config/jogl/obsolete/gl-gl2es12.cfg b/make/config/jogl/obsolete/gl-gl2es12.cfg
new file mode 100644
index 000000000..3942b1419
--- /dev/null
+++ b/make/config/jogl/obsolete/gl-gl2es12.cfg
@@ -0,0 +1,90 @@
+# This .cfg file is used to generate the GL interface and implementing class.
+JavaOutputDir gensrc/classes
+NativeOutputDir gensrc/native/jogl/gl2es12
+
+ExtendedInterfaceSymbolsOnly ../build-temp/gensrc/classes/javax/media/opengl/GL.java
+ExtendedInterfaceSymbolsOnly ../build-temp/gensrc/classes/javax/media/opengl/GL2ES1.java
+ExtendedInterfaceSymbolsOnly ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java
+ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/GLBase.java
+ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java
+ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java
+ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java
+
+Style ImplOnly
+ImplPackage com.jogamp.opengl.impl.gl2es12
+ImplJavaClass GL2ES12Impl
+Implements GL2ES12Impl GLBase
+Implements GL2ES12Impl GL
+Implements GL2ES12Impl GL2ES1
+Implements GL2ES12Impl GL2ES2
+
+Include gl-common.cfg
+Include gl-common-extensions.cfg
+Include gl-desktop.cfg
+
+# Because we're manually implementing glMapBuffer but only producing
+# the implementing class, GlueGen doesn't notice that it has to emit a
+# proc address table entry for it. Force it to here.
+ForceProcAddressGen glMapBuffer
+
+# Force all of the methods to be emitted using dynamic linking so we
+# don't need to link against any emulation library on the desktop or
+# depend on the presence of an import library for a particular device
+ForceProcAddressGen __ALL__
+
+# Also force the calling conventions of the locally generated function
+# pointer typedefs for these routines to APIENTRY
+LocalProcAddressCallingConvention __ALL__ APIENTRY
+
+EmitProcAddressTable true
+ProcAddressTableClassName GL2ES12ProcAddressTable
+GetProcAddressTableExpr ((GL2ES12ProcAddressTable)_context.getGLProcAddressTable())
+
+# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums
+TagNativeBinding true
+
+# There seem to be some errors in the glue code generation where we are not ignoring
+# enough routines from desktop GL in GL2ES12Impl. For now manually ignore those which
+# we know shouldn't be in there
+Ignore glGetTexImage
+Ignore glPixelStoref
+
+# Add PixelStorei StateTracker
+#
+# Add input validation to glPixelStorei to make sure that, even if we
+# are running on top of desktop OpenGL, parameters not exposed in
+# OpenGL ES can not be changed
+CustomJavaCode GL2ES12Impl private static final int params_offset = 0; // just a helper for JavaPrologue ..
+
+JavaPrologue glPixelStorei if (pname != GL_PACK_ALIGNMENT && pname != GL_UNPACK_ALIGNMENT) {
+JavaPrologue glPixelStorei throw new GLException("Unsupported pixel store parameter name 0x" + Integer.toHexString(pname));
+JavaPrologue glPixelStorei }
+JavaPrologue glPixelStorei glStateTracker.setInt(pname, param);
+
+JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; }
+
+CustomJavaCode GL2ES12Impl public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) {
+CustomJavaCode GL2ES12Impl glFrustum((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); }
+
+CustomJavaCode GL2ES12Impl public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) {
+CustomJavaCode GL2ES12Impl glOrtho((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); }
+
+CustomJavaCode GL2ES12Impl public void glClearDepthf(float depth) {
+CustomJavaCode GL2ES12Impl glClearDepth((double)depth); }
+
+CustomJavaCode GL2ES12Impl public void glDepthRangef(float zNear, float zFar) {
+CustomJavaCode GL2ES12Impl glDepthRange((double)zNear, (double)zFar); }
+
+Include gl-headers.cfg
+Include ../intptr.cfg
+
+IncludeAs CustomJavaCode GL2ES12Impl gl-impl-CustomJavaCode-common.java
+IncludeAs CustomJavaCode GL2ES12Impl gl-impl-CustomJavaCode-gl2es12.java
+IncludeAs CustomJavaCode GL2ES12Impl gl-impl-CustomJavaCode-embedded.java
+IncludeAs CustomJavaCode GL2ES12Impl gl-impl-CustomJavaCode-gl2_es2.java
+IncludeAs CustomCCode gl-impl-CustomCCode-gl2es12.c
+
+Import javax.media.opengl.GLES1
+Import javax.media.opengl.GLES2
+Import com.jogamp.opengl.impl.InternalBufferUtil
+Import java.io.PrintStream
diff --git a/make/config/jogl/obsolete/gl-impl-CustomCCode-gl2.c b/make/config/jogl/obsolete/gl-impl-CustomCCode-gl2.c
new file mode 100644
index 000000000..91fd0078b
--- /dev/null
+++ b/make/config/jogl/obsolete/gl-impl-CustomCCode-gl2.c
@@ -0,0 +1,24 @@
+/* Java->C glue code:
+ * Java package: com.jogamp.opengl.impl.gl2.GL2Impl
+ * Java method: long dispatch_glMapBuffer(int target, int access)
+ * C function: void * glMapBuffer(GLenum target, GLenum access);
+ */
+JNIEXPORT jlong JNICALL
+Java_com_jogamp_opengl_impl_gl2_GL2Impl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unused, jint target, jint access, jlong glProcAddress) {
+ PFNGLMAPBUFFERPROC ptr_glMapBuffer;
+ void * _res;
+ ptr_glMapBuffer = (PFNGLMAPBUFFERPROC) (intptr_t) glProcAddress;
+ assert(ptr_glMapBuffer != NULL);
+ _res = (* ptr_glMapBuffer) ((GLenum) target, (GLenum) access);
+ return (jlong) (intptr_t) _res;
+}
+
+/* Java->C glue code:
+ * Java package: com.jogamp.opengl.impl.gl2.GL2Impl
+ * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity);
+ * C function: jobject newDirectByteBuffer(jlong addr, jint capacity);
+ */
+JNIEXPORT jobject JNICALL
+Java_com_jogamp_opengl_impl_gl2_GL2Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) {
+ return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity);
+}
diff --git a/make/config/jogl/obsolete/gl-impl-CustomCCode-gl2es12.c b/make/config/jogl/obsolete/gl-impl-CustomCCode-gl2es12.c
new file mode 100644
index 000000000..07b821802
--- /dev/null
+++ b/make/config/jogl/obsolete/gl-impl-CustomCCode-gl2es12.c
@@ -0,0 +1,24 @@
+/* Java->C glue code:
+ * Java package: com.jogamp.opengl.impl.gl2es12.GL2ES12Impl
+ * Java method: long dispatch_glMapBuffer(int target, int access)
+ * C function: void * glMapBuffer(GLenum target, GLenum access);
+ */
+JNIEXPORT jlong JNICALL
+Java_com_jogamp_opengl_impl_gl2es12_GL2ES12Impl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unused, jint target, jint access, jlong glProcAddress) {
+ PFNGLMAPBUFFERPROC ptr_glMapBuffer;
+ void * _res;
+ ptr_glMapBuffer = (PFNGLMAPBUFFERPROC) (intptr_t) glProcAddress;
+ assert(ptr_glMapBuffer != NULL);
+ _res = (* ptr_glMapBuffer) ((GLenum) target, (GLenum) access);
+ return (jlong) (intptr_t) _res;
+}
+
+/* Java->C glue code:
+ * Java package: com.jogamp.opengl.impl.gl2es12.GL2ES12Impl
+ * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity);
+ * C function: jobject newDirectByteBuffer(jlong addr, jint capacity);
+ */
+JNIEXPORT jobject JNICALL
+Java_com_jogamp_opengl_impl_gl2es12_GL2ES12Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) {
+ return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity);
+}
diff --git a/make/config/jogl/obsolete/gl-impl-CustomCCode-gl3.c b/make/config/jogl/obsolete/gl-impl-CustomCCode-gl3.c
new file mode 100644
index 000000000..f540a7d4a
--- /dev/null
+++ b/make/config/jogl/obsolete/gl-impl-CustomCCode-gl3.c
@@ -0,0 +1,24 @@
+/* Java->C glue code:
+ * Java package: com.jogamp.opengl.impl.gl3.GL3Impl
+ * Java method: long dispatch_glMapBuffer(int target, int access)
+ * C function: void * glMapBuffer(GLenum target, GLenum access);
+ */
+JNIEXPORT jlong JNICALL
+Java_com_jogamp_opengl_impl_gl3_GL3Impl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unused, jint target, jint access, jlong glProcAddress) {
+ PFNGLMAPBUFFERPROC ptr_glMapBuffer;
+ void * _res;
+ ptr_glMapBuffer = (PFNGLMAPBUFFERPROC) (intptr_t) glProcAddress;
+ assert(ptr_glMapBuffer != NULL);
+ _res = (* ptr_glMapBuffer) ((GLenum) target, (GLenum) access);
+ return (jlong) (intptr_t) _res;
+}
+
+/* Java->C glue code:
+ * Java package: com.jogamp.opengl.impl.gl3.GL3Impl
+ * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity);
+ * C function: jobject newDirectByteBuffer(jlong addr, jint capacity);
+ */
+JNIEXPORT jobject JNICALL
+Java_com_jogamp_opengl_impl_gl3_GL3Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) {
+ return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity);
+}
diff --git a/make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2.java b/make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2.java
new file mode 100644
index 000000000..a1a6917df
--- /dev/null
+++ b/make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2.java
@@ -0,0 +1,385 @@
+// Tracks glBegin/glEnd calls to determine whether it is legal to
+// query Vertex Buffer Object state
+private boolean inBeginEndPair;
+
+/* FIXME: refactor dependence on Java 2D / JOGL bridge
+
+// Tracks creation and destruction of server-side OpenGL objects when
+// the Java2D/OpenGL pipeline is enabled and it is using frame buffer
+// objects (FBOs) to do its rendering
+private GLObjectTracker tracker;
+
+public void setObjectTracker(GLObjectTracker tracker) {
+ this.tracker = tracker;
+}
+
+*/
+
+
+public GL2Impl(GLProfile glp, GLContextImpl context) {
+ this._context = context;
+ this.bufferSizeTracker = context.getBufferSizeTracker();
+ this.bufferStateTracker = context.getBufferStateTracker();
+ this.glStateTracker = context.getGLStateTracker();
+ this.glProfile = glp;
+}
+
+/**
+ * Provides platform-independent access to the wglAllocateMemoryNV /
+ * glXAllocateMemoryNV extension.
+ */
+public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
+ return _context.glAllocateMemoryNV(arg0, arg1, arg2, arg3);
+}
+
+//
+// Helpers for ensuring the correct amount of texture data
+//
+
+/** Returns the number of bytes required to fill in the appropriate
+ texture. This is computed as closely as possible based on the
+ pixel pack or unpack parameters. The logic in this routine is
+ based on code in the SGI OpenGL sample implementation. */
+
+private int imageSizeInBytes(int format, int type, int w, int h, int d,
+ boolean pack) {
+ int elements = 0;
+ int esize = 0;
+
+ if (w < 0) return 0;
+ if (h < 0) return 0;
+ if (d < 0) return 0;
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_DEPTH_COMPONENT:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ case GL_BGR:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ elements = 4;
+ break;
+ /* FIXME ??
+ case GL_HILO_NV:
+ elements = 2;
+ break; */
+ default:
+ return 0;
+ }
+ switch (type) {
+ case GL_BITMAP:
+ if (format == GL_COLOR_INDEX) {
+ return (d * (h * ((w+7)/8)));
+ } else {
+ return 0;
+ }
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return 0;
+ }
+ return imageSizeInBytes(elements * esize, w, h, d, pack);
+}
+
+private GLBufferSizeTracker bufferSizeTracker;
+private GLBufferStateTracker bufferStateTracker;
+private GLStateTracker glStateTracker;
+
+private boolean bufferObjectExtensionsInitialized = false;
+private boolean haveARBPixelBufferObject;
+private boolean haveEXTPixelBufferObject;
+private boolean haveGL15;
+private boolean haveGL21;
+private boolean haveARBVertexBufferObject;
+
+private void initBufferObjectExtensionChecks() {
+ if (bufferObjectExtensionsInitialized)
+ return;
+ bufferObjectExtensionsInitialized = true;
+ haveARBPixelBufferObject = isExtensionAvailable("GL_ARB_pixel_buffer_object");
+ haveEXTPixelBufferObject = isExtensionAvailable("GL_EXT_pixel_buffer_object");
+ haveGL15 = isExtensionAvailable("GL_VERSION_1_5");
+ haveGL21 = isExtensionAvailable("GL_VERSION_2_1");
+ haveARBVertexBufferObject = isExtensionAvailable("GL_ARB_vertex_buffer_object");
+}
+
+private boolean checkBufferObject(boolean extension1,
+ boolean extension2,
+ boolean extension3,
+ boolean enabled,
+ int state,
+ String kind, boolean throwException) {
+ if (inBeginEndPair) {
+ throw new GLException("May not call this between glBegin and glEnd");
+ }
+ boolean avail = (extension1 || extension2 || extension3);
+ if (!avail) {
+ if (!enabled)
+ return true;
+ if(throwException) {
+ throw new GLException("Required extensions not available to call this function");
+ }
+ return false;
+ }
+ int buffer = bufferStateTracker.getBoundBufferObject(state, this);
+ if (enabled) {
+ if (buffer == 0) {
+ if(throwException) {
+ throw new GLException(kind + " must be enabled to call this method");
+ }
+ return false;
+ }
+ } else {
+ if (buffer != 0) {
+ if(throwException) {
+ throw new GLException(kind + " must be disabled to call this method");
+ }
+ return false;
+ }
+ }
+ return true;
+}
+
+private boolean checkArrayVBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ false,
+ GL.GL_ARRAY_BUFFER,
+ "array vertex_buffer_object", throwException);
+}
+
+private boolean checkArrayVBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ true,
+ GL.GL_ARRAY_BUFFER,
+ "array vertex_buffer_object", throwException);
+}
+
+private boolean checkElementVBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ false,
+ GL.GL_ELEMENT_ARRAY_BUFFER,
+ "element vertex_buffer_object", throwException);
+}
+
+private boolean checkElementVBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ true,
+ GL.GL_ELEMENT_ARRAY_BUFFER,
+ "element vertex_buffer_object", throwException);
+}
+
+private boolean checkUnpackPBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveARBPixelBufferObject,
+ haveEXTPixelBufferObject,
+ haveGL21,
+ false,
+ GL2.GL_PIXEL_UNPACK_BUFFER,
+ "unpack pixel_buffer_object", throwException);
+}
+
+private boolean checkUnpackPBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveARBPixelBufferObject,
+ haveEXTPixelBufferObject,
+ haveGL21,
+ true,
+ GL2.GL_PIXEL_UNPACK_BUFFER,
+ "unpack pixel_buffer_object", throwException);
+}
+
+private boolean checkPackPBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveARBPixelBufferObject,
+ haveEXTPixelBufferObject,
+ haveGL21,
+ false,
+ GL2.GL_PIXEL_PACK_BUFFER,
+ "pack pixel_buffer_object", throwException);
+}
+
+private boolean checkPackPBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveARBPixelBufferObject,
+ haveEXTPixelBufferObject,
+ haveGL21,
+ true,
+ GL2.GL_PIXEL_PACK_BUFFER,
+ "pack pixel_buffer_object", throwException);
+}
+
+public boolean glIsPBOPackEnabled() {
+ return checkPackPBOEnabled(false);
+}
+
+public boolean glIsPBOUnpackEnabled() {
+ return checkUnpackPBOEnabled(false);
+}
+
+// Attempt to return the same ByteBuffer object from glMapBuffer if
+// the vertex buffer object's base address and size haven't changed
+private static class ARBVBOKey {
+ private long addr;
+ private int capacity;
+
+ ARBVBOKey(long addr, int capacity) {
+ this.addr = addr;
+ this.capacity = capacity;
+ }
+
+ public int hashCode() {
+ return (int) addr;
+ }
+
+ public boolean equals(Object o) {
+ if ((o == null) || (!(o instanceof ARBVBOKey))) {
+ return false;
+ }
+
+ ARBVBOKey other = (ARBVBOKey) o;
+ return ((addr == other.addr) && (capacity == other.capacity));
+ }
+}
+
+private Map/*
LPVOID glMapBuffer(GLenum target, GLenum access);
*/
+public java.nio.ByteBuffer glMapBuffer(int target, int access) {
+ final long __addr_ = ((GL2ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer;
+ if (__addr_ == 0) {
+ throw new GLException("Method \"glMapBuffer\" not available");
+ }
+ int sz = bufferSizeTracker.getBufferSize(bufferStateTracker,
+ target,
+ this);
+ long addr;
+ addr = dispatch_glMapBuffer(target, access, __addr_);
+ if (addr == 0 || sz == 0) {
+ return null;
+ }
+ ARBVBOKey key = new ARBVBOKey(addr, sz);
+ ByteBuffer _res = (ByteBuffer) arbVBOCache.get(key);
+ if (_res == null) {
+ _res = newDirectByteBuffer(addr, sz);
+ InternalBufferUtil.nativeOrder(_res);
+ arbVBOCache.put(key, _res);
+ }
+ _res.position(0);
+ return _res;
+}
+
+/** Encapsulates function pointer for OpenGL function
: LPVOID glMapBuffer(GLenum target, GLenum access);
*/
+native private long dispatch_glMapBuffer(int target, int access, long glProcAddress);
+
+native private ByteBuffer newDirectByteBuffer(long addr, int capacity);
+
+ /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
+ public void glShaderBinary(int n, java.nio.IntBuffer shaders, int binaryformat, java.nio.Buffer binary, int length) {
+ throw new GLException("Method \"glShaderBinary\" not available");
+ }
+
+ /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
+ public void glShaderBinary(int n, int[] shaders, int shaders_offset, int binaryformat, java.nio.Buffer binary, int length) {
+ throw new GLException("Method \"glShaderBinary\" not available");
+ }
+
+ public void glReleaseShaderCompiler() {
+ // nothing to do
+ }
+
+ public void glVertexPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.isVBO()) {
+ glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
+ } else {
+ glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+ }
+ public void glColorPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.isVBO()) {
+ glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
+ } else {
+ glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+
+ }
+ public void glNormalPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.getComponentNumber()!=3) {
+ throw new GLException("Only 3 components per normal allowed");
+ }
+ if(array.isVBO()) {
+ glNormalPointer(array.getComponentType(), array.getStride(), array.getOffset());
+ } else {
+ glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+ }
+ public void glTexCoordPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.isVBO()) {
+ glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
+ } else {
+ glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+ }
+
diff --git a/make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2es12.java b/make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2es12.java
new file mode 100644
index 000000000..aed442da3
--- /dev/null
+++ b/make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2es12.java
@@ -0,0 +1,353 @@
+// Tracks glBegin/glEnd calls to determine whether it is legal to
+// query Vertex Buffer Object state
+private boolean inBeginEndPair;
+
+/* FIXME: refactor dependence on Java 2D / JOGL bridge
+
+// Tracks creation and destruction of server-side OpenGL objects when
+// the Java2D/OpenGL pipeline is enabled and it is using frame buffer
+// objects (FBOs) to do its rendering
+private GLObjectTracker tracker;
+
+public void setObjectTracker(GLObjectTracker tracker) {
+ this.tracker = tracker;
+}
+
+*/
+
+public GL2ES12Impl(GLProfile glp, GLContextImpl context) {
+ this._context = context;
+ this.bufferSizeTracker = context.getBufferSizeTracker();
+ this.bufferStateTracker = context.getBufferStateTracker();
+ this.glStateTracker = context.getGLStateTracker();
+ this.isGL2ES2 = glp.isGL2ES2();
+ this.glProfile = glp;
+}
+
+private boolean isGL2ES2;
+
+public boolean isFunctionAvailable(String glFunctionName) {
+ return _context.isFunctionAvailable(glFunctionName);
+}
+
+public boolean isExtensionAvailable(String glExtensionName) {
+ return _context.isExtensionAvailable(glExtensionName);
+}
+
+public Object getExtension(String extensionName) {
+ // At this point we don't expose any extensions using this mechanism
+ return null;
+}
+
+/** Returns the context this GL object is associated with for better
+ error checking by DebugGL. */
+public GLContext getContext() {
+ return _context;
+}
+
+private GLContextImpl _context;
+
+public void setSwapInterval(int interval) {
+ _context.setSwapInterval(interval);
+}
+
+public int getSwapInterval() {
+ return _context.getSwapInterval();
+}
+
+public Object getPlatformGLExtensions() {
+ return _context.getPlatformGLExtensions();
+}
+
+//
+// Helpers for ensuring the correct amount of texture data
+//
+
+/** Returns the number of bytes required to fill in the appropriate
+ texture. This is computed as closely as possible based on the
+ pixel pack or unpack parameters. The logic in this routine is
+ based on code in the SGI OpenGL sample implementation. */
+
+private int imageSizeInBytes(int format, int type, int w, int h, int d,
+ boolean pack) {
+ int elements = 0;
+ int esize = 0;
+
+ if (w < 0) return 0;
+ if (h < 0) return 0;
+ if (d < 0) return 0;
+ switch (format) {
+ case GL_STENCIL_INDEX:
+ elements = 1;
+ break;
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_DEPTH_COMPONENT:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ elements = 4;
+ break;
+ /* FIXME ??
+ case GL_HILO_NV:
+ elements = 2;
+ break; */
+ default:
+ return 0;
+ }
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ default:
+ return 0;
+ }
+ return imageSizeInBytes(elements * esize, w, h, d, pack);
+}
+
+private GLBufferSizeTracker bufferSizeTracker;
+private GLBufferStateTracker bufferStateTracker;
+private GLStateTracker glStateTracker;
+
+private boolean bufferObjectExtensionsInitialized = false;
+private boolean haveGL15;
+private boolean haveGL21;
+private boolean haveARBVertexBufferObject;
+
+private void initBufferObjectExtensionChecks() {
+ if (bufferObjectExtensionsInitialized)
+ return;
+ bufferObjectExtensionsInitialized = true;
+ haveGL15 = isExtensionAvailable("GL_VERSION_1_5");
+ haveGL21 = isExtensionAvailable("GL_VERSION_2_1");
+ haveARBVertexBufferObject = isExtensionAvailable("GL_ARB_vertex_buffer_object");
+}
+
+private boolean checkBufferObject(boolean extension1,
+ boolean extension2,
+ boolean extension3,
+ boolean enabled,
+ int state,
+ String kind, boolean throwException) {
+ if (inBeginEndPair) {
+ throw new GLException("May not call this between glBegin and glEnd");
+ }
+ boolean avail = (extension1 || extension2 || extension3);
+ if (!avail) {
+ if (!enabled)
+ return true;
+ if(throwException) {
+ throw new GLException("Required extensions not available to call this function");
+ }
+ return false;
+ }
+ int buffer = bufferStateTracker.getBoundBufferObject(state, this);
+ if (enabled) {
+ if (buffer == 0) {
+ if(throwException) {
+ throw new GLException(kind + " must be enabled to call this method");
+ }
+ return false;
+ }
+ } else {
+ if (buffer != 0) {
+ if(throwException) {
+ throw new GLException(kind + " must be disabled to call this method");
+ }
+ return false;
+ }
+ }
+ return true;
+}
+
+private boolean checkArrayVBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ false,
+ GL.GL_ARRAY_BUFFER,
+ "array vertex_buffer_object", throwException);
+}
+
+private boolean checkArrayVBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ true,
+ GL.GL_ARRAY_BUFFER,
+ "array vertex_buffer_object", throwException);
+}
+
+private boolean checkElementVBODisabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ false,
+ GL.GL_ELEMENT_ARRAY_BUFFER,
+ "element vertex_buffer_object", throwException);
+}
+
+private boolean checkElementVBOEnabled(boolean throwException) {
+ initBufferObjectExtensionChecks();
+ return checkBufferObject(haveGL15,
+ haveARBVertexBufferObject,
+ false,
+ true,
+ GL.GL_ELEMENT_ARRAY_BUFFER,
+ "element vertex_buffer_object", throwException);
+}
+
+private boolean checkUnpackPBODisabled(boolean throwException) {
+ // PBO n/a for ES 1.1 or ES 2.0
+ return true;
+}
+
+private boolean checkUnpackPBOEnabled(boolean throwException) {
+ // PBO n/a for ES 1.1 or ES 2.0
+ return false;
+}
+
+private boolean checkPackPBODisabled(boolean throwException) {
+ // PBO n/a for ES 1.1 or ES 2.0
+ return true;
+}
+
+private boolean checkPackPBOEnabled(boolean throwException) {
+ // PBO n/a for ES 1.1 or ES 2.0
+ return false;
+}
+
+// Attempt to return the same ByteBuffer object from glMapBuffer if
+// the vertex buffer object's base address and size haven't changed
+private static class ARBVBOKey {
+ private long addr;
+ private int capacity;
+
+ ARBVBOKey(long addr, int capacity) {
+ this.addr = addr;
+ this.capacity = capacity;
+ }
+
+ public int hashCode() {
+ return (int) addr;
+ }
+
+ public boolean equals(Object o) {
+ if ((o == null) || (!(o instanceof ARBVBOKey))) {
+ return false;
+ }
+
+ ARBVBOKey other = (ARBVBOKey) o;
+ return ((addr == other.addr) && (capacity == other.capacity));
+ }
+}
+
+private Map/*
LPVOID glMapBuffer(GLenum target, GLenum access);
*/
+public java.nio.ByteBuffer glMapBuffer(int target, int access) {
+ final long __addr_ = ((GL2ES12ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer;
+ if (__addr_ == 0) {
+ throw new GLException("Method \"glMapBuffer\" not available");
+ }
+ int sz = bufferSizeTracker.getBufferSize(bufferStateTracker,
+ target,
+ this);
+ long addr;
+ addr = dispatch_glMapBuffer(target, access, __addr_);
+ if (addr == 0 || sz == 0) {
+ return null;
+ }
+ ARBVBOKey key = new ARBVBOKey(addr, sz);
+ ByteBuffer _res = (ByteBuffer) arbVBOCache.get(key);
+ if (_res == null) {
+ _res = newDirectByteBuffer(addr, sz);
+ InternalBufferUtil.nativeOrder(_res);
+ arbVBOCache.put(key, _res);
+ }
+ _res.position(0);
+ return _res;
+}
+
+/** Encapsulates function pointer for OpenGL function
: LPVOID glMapBuffer(GLenum target, GLenum access);
*/
+native private long dispatch_glMapBuffer(int target, int access, long glProcAddress);
+
+native private ByteBuffer newDirectByteBuffer(long addr, int capacity);
+
+ /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
+ public void glShaderBinary(int n, java.nio.IntBuffer shaders, int binaryformat, java.nio.Buffer binary, int length) {
+ throw new GLException("Method \"glShaderBinary\" not available");
+ }
+
+ /** Dummy implementation for the ES 2.0 function:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
Always throws a GLException! */
+ public void glShaderBinary(int n, int[] shaders, int shaders_offset, int binaryformat, java.nio.Buffer binary, int length) {
+ throw new GLException("Method \"glShaderBinary\" not available");
+ }
+
+ public void glReleaseShaderCompiler() {
+ // nothing to do
+ }
+
+ public void glVertexPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.isVBO()) {
+ glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
+ } else {
+ glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+ }
+ public void glColorPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.isVBO()) {
+ glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
+ } else {
+ glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+
+ }
+ public void glNormalPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.getComponentNumber()!=3) {
+ throw new GLException("Only 3 components per normal allowed");
+ }
+ if(array.isVBO()) {
+ glNormalPointer(array.getComponentType(), array.getStride(), array.getOffset());
+ } else {
+ glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+ }
+ public void glTexCoordPointer(GLArrayData array) {
+ if(array.getComponentNumber()==0) return;
+ if(array.isVBO()) {
+ glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset());
+ } else {
+ glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
+ }
+ }
+
+
diff --git a/make/config/nativewindow/x11-CustomJavaCode.java b/make/config/nativewindow/x11-CustomJavaCode.java
index 57f37bee7..44bb1e8d0 100644
--- a/make/config/nativewindow/x11-CustomJavaCode.java
+++ b/make/config/nativewindow/x11-CustomJavaCode.java
@@ -26,9 +26,8 @@
public static native long DefaultVisualID(long display, int screen);
- /**
public static native long CreateDummyWindow(long display, int screen_index, long visualID);
- public static native void DestroyDummyWindow(long display, long window); */
+ public static native void DestroyDummyWindow(long display, long window);
public static native long dlopen(String name);
public static native long dlsym(String name);
diff --git a/make/stub_includes/opengl/gl4.c b/make/stub_includes/opengl/gl4.c
index cf8a709f7..5e9d87ccd 100644
--- a/make/stub_includes/opengl/gl4.c
+++ b/make/stub_includes/opengl/gl4.c
@@ -1,11 +1,11 @@
#define GLAPI
-// Define GL4_PROTOTYPES so that the OpenGL prototypes in
+// Define GL3_PROTOTYPES so that the OpenGL prototypes in
// "gl3.h" are parsed.
-#define GL4_PROTOTYPES
+#define GL3_PROTOTYPES
-// Define GL_GL4EXT_PROTOTYPES so that the OpenGL extension prototypes in
+// Define GL_GL3EXT_PROTOTYPES so that the OpenGL extension prototypes in
// "gl3ext.h" are parsed.
-#define GL_GL4EXT_PROTOTYPES
+#define GL_GL3EXT_PROTOTYPES
-#include ARB_create_context
- * mechanism to create a context.
- * The implementation shall verify this context, ie issue a
- * MakeCurrent
call if necessary.
- *
- * @param share the shared context or null
- * @param direct flag if direct is requested
- * @param ctxOptionFlags ARB_create_context
related, see references below
- * @param major major number
- * @param minor minor number
- * @return the valid context if successfull, or null
- *
- * @see #CTX_PROFILE_COMPAT
- * @see #CTX_OPTION_FORWARD
- * @see #CTX_OPTION_DEBUG
- */
- protected abstract long createContextARBImpl(long share, boolean direct, int ctxOptionFlags,
- int major, int minor);
+ public final GL getGL() {
+ return gl;
+ }
- private long createContextARB(long share, boolean direct, int ctxOptionFlags,
- int majorMax, int minorMax,
- int majorMin, int minorMin,
- int major[], int minor[]) {
- major[0]=majorMax;
- minor[0]=minorMax;
- long _context=0;
+ public GL setGL(GL gl) {
+ if(DEBUG) {
+ String sgl1 = (null!=this.gl)?this.gl.getClass().toString()+", "+this.gl.toString():new String("ARB_create_context
- * mechanism to create a context.
- */
- protected long createContextARB(long share, boolean direct,
- int major[], int minor[], int ctp[])
- {
- AbstractGraphicsConfiguration config = drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
- GLProfile glp = glCaps.getGLProfile();
- long _context = 0;
+ protected abstract void releaseImpl() throws GLException;
- ctp[0] = CTX_IS_ARB_CREATED | CTX_PROFILE_CORE | CTX_OPTION_ANY; // default
- boolean isBackwardCompatibility = glp.isGL2() || glp.isGL3bc() || glp.isGL4bc() ;
- int majorMin, minorMin;
- int majorMax, minorMax;
- if( glp.isGL4() ) {
- // ?? majorMax=GLProfile.getMaxMajor(); minorMax=GLProfile.getMaxMinor(majorMax);
- majorMax=4; minorMax=GLProfile.getMaxMinor(majorMax);
- majorMin=4; minorMin=0;
- } else if( glp.isGL3() ) {
- majorMax=3; minorMax=GLProfile.getMaxMinor(majorMax);
- majorMin=3; minorMin=1;
- } else /* if( glp.isGL2() ) */ {
- majorMax=3; minorMax=0;
- majorMin=1; minorMin=1; // our minimum desktop OpenGL runtime requirements
+ public void destroy() {
+ if (lock.isHeld()) {
+ // release current context
+ release();
}
- // Try the requested ..
- if(isBackwardCompatibility) {
- ctp[0] &= ~CTX_PROFILE_CORE ;
- ctp[0] |= CTX_PROFILE_COMPAT ;
- }
- _context = createContextARB(share, direct, ctp[0],
- /* max */ majorMax, minorMax,
- /* min */ majorMin, minorMin,
- /* res */ major, minor);
-
- if(0==_context && !isBackwardCompatibility) {
- ctp[0] &= ~CTX_PROFILE_COMPAT ;
- ctp[0] |= CTX_PROFILE_CORE ;
- ctp[0] &= ~CTX_OPTION_ANY ;
- ctp[0] |= CTX_OPTION_FORWARD ;
- _context = createContextARB(share, direct, ctp[0],
- /* max */ majorMax, minorMax,
- /* min */ majorMin, minorMin,
- /* res */ major, minor);
- if(0==_context) {
- // Try a compatible one .. even though not requested .. last resort
- ctp[0] &= ~CTX_PROFILE_CORE ;
- ctp[0] |= CTX_PROFILE_COMPAT ;
- ctp[0] &= ~CTX_OPTION_FORWARD ;
- ctp[0] |= CTX_OPTION_ANY ;
- _context = createContextARB(share, direct, ctp[0],
- /* max */ majorMax, minorMax,
- /* min */ majorMin, minorMin,
- /* res */ major, minor);
- }
+
+ // Must hold the lock around the destroy operation to make sure we
+ // don't destroy the context out from under another thread rendering to it
+ lock.lock();
+ try {
+ /* FIXME: refactor dependence on Java 2D / JOGL bridge
+ if (tracker != null) {
+ // Don't need to do anything for contexts that haven't been
+ // created yet
+ if (isCreated()) {
+ // If we are tracking creation and destruction of server-side
+ // OpenGL objects, we must decrement the reference count of the
+ // GLObjectTracker upon context destruction.
+ //
+ // Note that we can only eagerly delete these server-side
+ // objects if there is another context currrent right now
+ // which shares textures and display lists with this one.
+ tracker.unref(deletedObjectTracker);
+ }
+ }
+ */
+
+ // Because we don't know how many other contexts we might be
+ // sharing with (and it seems too complicated to implement the
+ // GLObjectTracker's ref/unref scheme for the buffer-related
+ // optimizations), simply clear the cache of known buffers' sizes
+ // when we destroy contexts
+ if (bufferSizeTracker != null) {
+ bufferSizeTracker.clearCachedBufferSizes();
+ }
+
+ if (bufferStateTracker != null) {
+ bufferStateTracker.clearBufferObjectState();
+ }
+
+ if (glStateTracker != null) {
+ glStateTracker.clearStates(false);
+ }
+
+ destroyImpl();
+ } finally {
+ lock.unlock();
}
- return _context;
}
+ protected abstract void destroyImpl() throws GLException;
+
+ //----------------------------------------------------------------------
+ //
+
+ /**
+ * MakeCurrent functionality, which also issues the creation of the actual OpenGL context.
+ * The complete callgraph for general OpenGL context creation is:
+ *
+ *
ARB_create_context
is supported:
+ *
+ *
+ *
+ *
+ * Once at startup, ie triggered by the singleton {@link GLDrawableImpl} constructor,
+ * calling {@link #createContextARB} will query all available OpenGL versions:
+ *
+ *
FOR ALL GL* DO
:
+ *
+ *
+ *
+ *
+ *
+ *
+ * @see #makeCurrentImpl
+ * @see #create
+ * @see #createContextARB
+ * @see #createContextARBImpl
+ * @see #mapVersionAvailable
+ * @see #destroyContextARBImpl
+ */
public int makeCurrent() throws GLException {
// Support calls to makeCurrent() over and over again with
// different contexts without releasing them
@@ -287,103 +317,206 @@ public abstract class GLContextImpl extends GLContext {
return res;
}
+ /**
+ * @see #makeCurrent
+ */
protected abstract int makeCurrentImpl() throws GLException;
- public void release() throws GLException {
- if (!lock.isHeld()) {
- throw new GLException("Context not current on current thread");
- }
- setCurrent(null);
- try {
- releaseImpl();
- } finally {
- lock.unlock();
- }
- }
+ /**
+ * @see #makeCurrent
+ */
+ protected abstract void create() throws GLException ;
- protected abstract void releaseImpl() throws GLException;
+ /**
+ * Platform dependent but harmonized implementation of the ARB_create_context
+ * mechanism to create a context.
+ *
+ * This method is called from {@link #createContextARB}.
+ *
+ * The implementation shall verify this context with a
+ * MakeContextCurrent
call.
+ *
+ * @param share the shared context or null
+ * @param direct flag if direct is requested
+ * @param ctxOptionFlags ARB_create_context
related, see references below
+ * @param major major number
+ * @param minor minor number
+ * @return the valid context if successfull, or null
+ *
+ * @see #makeCurrent
+ * @see #CTX_PROFILE_COMPAT
+ * @see #CTX_OPTION_FORWARD
+ * @see #CTX_OPTION_DEBUG
+ * @see #makeCurrentImpl
+ * @see #create
+ * @see #createContextARB
+ * @see #createContextARBImpl
+ * @see #destroyContextARBImpl
+ */
+ protected abstract long createContextARBImpl(long share, boolean direct, int ctxOptionFlags,
+ int major, int minor);
- public void destroy() {
- if (lock.isHeld()) {
- // release current context
- release();
- }
+ /**
+ * Destroy the context created by {@link #createContextARBImpl}.
+ *
+ * @see #makeCurrent
+ * @see #makeCurrentImpl
+ * @see #create
+ * @see #createContextARB
+ * @see #createContextARBImpl
+ * @see #destroyContextARBImpl
+ */
+ protected abstract void destroyContextARBImpl(long context);
- // Must hold the lock around the destroy operation to make sure we
- // don't destroy the context out from under another thread rendering to it
- lock.lock();
- try {
- /* FIXME: refactor dependence on Java 2D / JOGL bridge
- if (tracker != null) {
- // Don't need to do anything for contexts that haven't been
- // created yet
- if (isCreated()) {
- // If we are tracking creation and destruction of server-side
- // OpenGL objects, we must decrement the reference count of the
- // GLObjectTracker upon context destruction.
- //
- // Note that we can only eagerly delete these server-side
- // objects if there is another context currrent right now
- // which shares textures and display lists with this one.
- tracker.unref(deletedObjectTracker);
+ /**
+ * Platform independent part of using the ARB_create_context
+ * mechanism to create a context.
+ *
+ * The implementation of {@link #create} shall use this protocol in case the platform supports ARB_create_context
.
+ *
+ * This method may call {@link #createContextARBImpl} and {@link #destroyContextARBImpl}.
+ *
+ * This method will also query all available native OpenGL context when first called,
+ * usually the first call should happen with the shared GLContext of the DrawableFactory.
+ *
+ * @see #makeCurrentImpl
+ * @see #create
+ * @see #createContextARB
+ * @see #createContextARBImpl
+ * @see #destroyContextARBImpl
+ */
+ protected long createContextARB(long share, boolean direct,
+ int major[], int minor[], int ctp[])
+ {
+ AbstractGraphicsConfiguration config = drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
+ GLProfile glp = glCaps.getGLProfile();
+ long _context = 0;
+
+ if( !mappedVersionsAvailableSet ) {
+ synchronized(mappedVersionsAvailableLock) {
+ if( !mappedVersionsAvailableSet ) {
+ createContextARBMapVersionsAvailable(4, false /* compat */); // GL4
+ createContextARBMapVersionsAvailable(4, true /* compat */); // GL4bc
+ createContextARBMapVersionsAvailable(3, false /* compat */); // GL3
+ createContextARBMapVersionsAvailable(3, true /* compat */); // GL3bc
+ createContextARBMapVersionsAvailable(2, true /* compat */); // GL2
+ mappedVersionsAvailableSet=true;
+ }
}
- }
- */
-
- // Because we don't know how many other contexts we might be
- // sharing with (and it seems too complicated to implement the
- // GLObjectTracker's ref/unref scheme for the buffer-related
- // optimizations), simply clear the cache of known buffers' sizes
- // when we destroy contexts
- if (bufferSizeTracker != null) {
- bufferSizeTracker.clearCachedBufferSizes();
- }
+ }
- if (bufferStateTracker != null) {
- bufferStateTracker.clearBufferObjectState();
- }
-
- if (glStateTracker != null) {
- glStateTracker.clearStates(false);
- }
-
- destroyImpl();
- } finally {
- lock.unlock();
+ int reqMajor;
+ if(glp.isGL4()) {
+ reqMajor=4;
+ } else if (glp.isGL3()) {
+ reqMajor=3;
+ } else /* if (glp.isGL2()) */ {
+ reqMajor=2;
}
+ boolean compat = glp.isGL2(); // incl GL3bc and GL4bc
+
+ int key = compose8bit(reqMajor, compat?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, 0, 0);
+ int val = mappedVersionsAvailable.get( key );
+ long _ctx = 0;
+ if(val>0) {
+ int _major = getComposed8bit(val, 1);
+ int _minor = getComposed8bit(val, 2);
+ int _ctp = getComposed8bit(val, 3);
+
+ _ctx = createContextARBImpl(share, direct, _ctp, _major, _minor);
+ if(0!=_ctx) {
+ setGLFunctionAvailability(true, _major, _minor, _ctp);
+ }
+ }
+ return _ctx;
}
- protected abstract void destroyImpl() throws GLException;
+ private void createContextARBMapVersionsAvailable(int reqMajor, boolean compat)
+ {
+ long _context;
+ int ctp = CTX_IS_ARB_CREATED | CTX_PROFILE_CORE | CTX_OPTION_ANY; // default
+ if(compat) {
+ ctp &= ~CTX_PROFILE_CORE ;
+ ctp |= CTX_PROFILE_COMPAT ;
+ }
- // This is only needed for Mac OS X on-screen contexts
- protected void update() throws GLException {
+ // FIXME GL3GL4:
+ // To avoid OpenGL implementation bugs and raise compatibility
+ // within JOGL, we map to the proper GL version.
+ // This may change later when GL3 and GL4 drivers become more mature!
+ // Bug: To ensure GL profile compatibility within the JOGL application
+ // Bug: we always try to map against the highest GL version,
+ // Bug: so the use can always cast to a higher one
+ // Bug: int majorMax=GLContext.getMaxMajor();
+ // Bug: int minorMax=GLContext.getMaxMinor(majorMax);
+ int majorMax, minorMax;
+ int majorMin, minorMin;
+ int major[] = new int[1];
+ int minor[] = new int[1];
+ if( 4 == reqMajor ) {
+ majorMax=4; minorMax=GLContext.getMaxMinor(majorMax);
+ majorMin=4; minorMin=0;
+ } else if( 3 == reqMajor ) {
+ majorMax=3; minorMax=GLContext.getMaxMinor(majorMax);
+ majorMin=3; minorMin=1;
+ } else /* if( glp.isGL2() ) */ {
+ majorMax=3; minorMax=0;
+ majorMin=1; minorMin=1; // our minimum desktop OpenGL runtime requirements
+ }
+ _context = createContextARBVersions(0, true, ctp,
+ /* max */ majorMax, minorMax,
+ /* min */ majorMin, minorMin,
+ /* res */ major, minor);
+
+ if(0==_context && !compat) {
+ ctp &= ~CTX_PROFILE_COMPAT ;
+ ctp |= CTX_PROFILE_CORE ;
+ ctp &= ~CTX_OPTION_ANY ;
+ ctp |= CTX_OPTION_FORWARD ;
+ _context = createContextARBVersions(0, true, ctp,
+ /* max */ majorMax, minorMax,
+ /* min */ majorMin, minorMin,
+ /* res */ major, minor);
+ if(0==_context) {
+ // Try a compatible one .. even though not requested .. last resort
+ ctp &= ~CTX_PROFILE_CORE ;
+ ctp |= CTX_PROFILE_COMPAT ;
+ ctp &= ~CTX_OPTION_FORWARD ;
+ ctp |= CTX_OPTION_ANY ;
+ _context = createContextARBVersions(0, true, ctp,
+ /* max */ majorMax, minorMax,
+ /* min */ majorMin, minorMin,
+ /* res */ major, minor);
+ }
+ }
+ if(0!=_context) {
+ destroyContextARBImpl(_context);
+ mapVersionAvailable(reqMajor, compat, major[0], minor[0], ctp);
+ }
}
- public boolean isSynchronized() {
- return !lock.getFailFastMode();
- }
+ private long createContextARBVersions(long share, boolean direct, int ctxOptionFlags,
+ int majorMax, int minorMax,
+ int majorMin, int minorMin,
+ int major[], int minor[]) {
+ major[0]=majorMax;
+ minor[0]=minorMax;
+ long _context=0;
- public void setSynchronized(boolean isSynchronized) {
- lock.setFailFastMode(!isSynchronized);
- }
+ while ( 0==_context &&
+ GLContext.isValidGLVersion(major[0], minor[0]) &&
+ ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) ) {
- public final GL getGL() {
- return gl;
- }
+ _context = createContextARBImpl(share, direct, ctxOptionFlags, major[0], minor[0]);
- public GL setGL(GL gl) {
- if(DEBUG) {
- String sgl1 = (null!=this.gl)?this.gl.getClass().toString()+", "+this.gl.toString():new String("ARB_create_context
related: core profile */
protected static final int CTX_PROFILE_CORE = 1 << 2;
/** ARB_create_context
related: flag forward compatible */
- protected static final int CTX_OPTION_FORWARD = 1 << 3;
+ protected static final int CTX_PROFILE_ES = 1 << 3;
+ /** ARB_create_context
related: flag forward compatible */
+ protected static final int CTX_OPTION_FORWARD = 1 << 4;
/** ARB_create_context
related: not flag forward compatible */
- protected static final int CTX_OPTION_ANY = 1 << 4;
+ protected static final int CTX_OPTION_ANY = 1 << 5;
/** ARB_create_context
related: flag debug */
- protected static final int CTX_OPTION_DEBUG = 1 << 5;
+ protected static final int CTX_OPTION_DEBUG = 1 << 6;
+
+
+ public final boolean isGL4bc() {
+ return ctxMajorVersion>=4 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES));
+ }
+
+ public final boolean isGL4() {
+ return ctxMajorVersion>=4 && 0==(ctxOptions & (CTX_PROFILE_ES));
+ }
+
+ public final boolean isGL3bc() {
+ return ctxMajorVersion>=3 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES));
+ }
+
+ public final boolean isGL3() {
+ return ctxMajorVersion>=3 && 0==(ctxOptions & (CTX_PROFILE_ES));
+ }
+
+ public final boolean isGL2() {
+ return ctxMajorVersion>=1 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES));
+ }
+
+ public final boolean isGLES1() {
+ return ctxMajorVersion==1 && CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES);
+ }
+
+ public final boolean isGLES2() {
+ return ctxMajorVersion==2 && CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES);
+ }
+
+ public final boolean isGLES() {
+ return CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES);
+ }
+
+ public final boolean isGL2ES1() {
+ return isGL2() || isGLES1() ;
+ }
+
+ public final boolean isGL2ES2() {
+ return isGL2() || isGL3() || isGLES2() ;
+ }
+
+ public final boolean isGL2GL3() {
+ return isGL2() || isGL3();
+ }
+
+ public final boolean hasGLSL() {
+ return isGL2ES2() ;
+ }
+
+ public static final int GL_VERSIONS[][] = {
+ /* 0.*/ { -1 },
+ /* 1.*/ { 0, 1, 2, 3, 4, 5 },
+ /* 2.*/ { 0, 1 },
+ /* 3.*/ { 0, 1, 2, 3 },
+ /* 4.*/ { 0 } };
+
+ public static final int getMaxMajor() {
+ return GL_VERSIONS.length-1;
+ }
+
+ public static final int getMaxMinor(int major) {
+ if(1>major || major>=GL_VERSIONS.length) return -1;
+ return GL_VERSIONS[major].length-1;
+ }
+
+ public static final boolean isValidGLVersion(int major, int minor) {
+ if(1>major || major>=GL_VERSIONS.length) return false;
+ if(0>minor || minor>=GL_VERSIONS[major].length) return false;
+ return true;
+ }
+
+ public static final boolean decrementGLVersion(int major[], int minor[]) {
+ if(null==major || major.length<1 ||null==minor || minor.length<1) {
+ throw new GLException("invalid array arguments");
+ }
+ int m = major[0];
+ int n = minor[0];
+ if(!isValidGLVersion(m, n)) return false;
+
+ // decrement ..
+ n -= 1;
+ if(n < 0) {
+ m -= 1;
+ n = GL_VERSIONS[m].length-1;
+ }
+ if(!isValidGLVersion(m, n)) return false;
+ major[0]=m;
+ minor[0]=n;
+
+ return true;
+ }
+
+ public static final boolean isGLVersionAvailable(int major, boolean compatibility) {
+ int key = compose8bit(major, compatibility?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, 0, 0);
+ int val = mappedVersionsAvailable.get( key );
+ return val>0;
+ }
+ public static final boolean isGL4bcAvailable() { return isGLVersionAvailable(4, true); }
+ public static final boolean isGL4Available() { return isGLVersionAvailable(4, false); }
+ public static final boolean isGL3bcAvailable() { return isGLVersionAvailable(3, true); }
+ public static final boolean isGL3Available() { return isGLVersionAvailable(3, false); }
+ public static final boolean isGL2Available() { return isGLVersionAvailable(2, true); }
+
+ protected static final IntIntHashMap mappedVersionsAvailable;
+ protected static volatile boolean mappedVersionsAvailableSet;
+ protected static Object mappedVersionsAvailableLock;
+
+ static {
+ mappedVersionsAvailableLock = new Object();
+ mappedVersionsAvailableSet = false;
+ mappedVersionsAvailable = new IntIntHashMap();
+ mappedVersionsAvailable.setKeyNotFoundValue(-1);
+ }
+
+ /**
+ * Called by {@link GLContextImpl#createContextARBMapVersionsAvailable} not intendet to be used by
+ * implementations. However, if {@link #createContextARB} is not being used within the
+ * {@link GLDrawableImpl} constructor, GLProfile has to map the available versions.
+ *
+ * @see #createContextARBMapVersionsAvailable
+ */
+ protected static void mapVersionAvailable(int reqMajor, boolean reqCompat, int resMajor, int resMinor, int resCtp)
+ {
+ int key = compose8bit(reqMajor, reqCompat?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, 0, 0);
+ int val = compose8bit(resMajor, resMinor, resCtp, 0);
+ mappedVersionsAvailable.put( key, val );
+ }
+
+ protected static int compose8bit(int one, int two, int three, int four) {
+ return ( ( one & 0x000000FF ) << 24 ) |
+ ( ( two & 0x000000FF ) << 16 ) |
+ ( ( three & 0x000000FF ) << 8 ) |
+ ( ( four & 0x000000FF ) ) ;
+ }
+
+ protected static int getComposed8bit(int bits32, int which ) {
+ switch (which) {
+ case 1: return ( bits32 & 0xFF000000 ) >> 24 ;
+ case 2: return ( bits32 & 0x00FF0000 ) >> 16 ;
+ case 3: return ( bits32 & 0x0000FF00 ) >> 8 ;
+ case 4: return ( bits32 & 0xFF0000FF ) ;
+ }
+ throw new GLException("argument which out of range: "+which);
+ }
+
+ protected static String composed8BitToString(int bits32, boolean hex1, boolean hex2, boolean hex3, boolean hex4) {
+ int a = getComposed8bit(bits32, 1);
+ int b = getComposed8bit(bits32, 2);
+ int c = getComposed8bit(bits32, 3);
+ int d = getComposed8bit(bits32, 4);
+ return "["+toString(a, hex1)+", "+toString(b, hex2)+", "+toString(c, hex3)+", "+toString(d, hex4)+"]";
+ }
+
+ protected static String toString(int val, boolean hex) {
+ if(hex) {
+ return "0x" + Integer.toHexString(val);
+ }
+ return String.valueOf(val);
+ }
+
+ protected static String toHexString(int hex) {
+ return "0x" + Integer.toHexString(hex);
+ }
+
+ protected static String toHexString(long hex) {
+ return "0x" + Long.toHexString(hex);
+ }
+
}
+
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index 80c2c10e2..b02bffb61 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -42,8 +42,9 @@ package javax.media.opengl;
import javax.media.nativewindow.*;
import java.security.*;
+import com.jogamp.common.JogampRuntimeException;
+import com.jogamp.common.util.*;
import com.jogamp.opengl.impl.*;
-import com.jogamp.nativewindow.impl.NWReflection;
/**
+ *
+ *
*/
- public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL2GL3, GL4bc, GL3bc, GL4, GL3 };
+ public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL3bc, GL4bc, GL2GL3, GL3, GL4, GL2ES2, GLES2, GL2ES1, GLES1 };
/**
- * All GL2ES2 Profiles in the order of default detection: GL2ES2, GL2, GLES2, GL3
+ * Order of maximum fixed function profiles
+ *
+ *
+ *
+ *
+ */
+ public static final String[] GL_PROFILE_LIST_MAX_FIXEDFUNC = new String[] { GL4bc, GL3bc, GL2, GL2ES1, GLES1 };
+
+ /**
+ * Order of maximum programmable shader profiles
+ *
+ *
+ *
+ *
+ */
+ public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER = new String[] { GL4, GL4bc, GL3, GL3bc, GL2, GL2ES2, GLES2 };
+
+ /**
+ * All GL2ES2 Profiles in the order of default detection.
+ *
+ * FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available!
+ *
+ *
+ *
+ *
*/
- public static final String[] GL_PROFILE_LIST_GL2ES2 = new String[] { GL2ES2, GL2, GLES2, GL4bc, GL3bc, GL4, GL3 };
+ public static final String[] GL_PROFILE_LIST_GL2ES2 = new String[] { GL2ES2, GL2, GL3, GL4, GLES2 };
/**
- * All GL2ES1 Profiles in the order of default detection: GL2ES1, GL2, GLES1
+ * All GL2ES1 Profiles in the order of default detection.
+ *
+ * FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available!
+ *
+ *
+ *
+ *
*/
- public static final String[] GL_PROFILE_LIST_GL2ES1 = new String[] { GL2ES1, GL2, GLES1 };
+ public static final String[] GL_PROFILE_LIST_GL2ES1 = new String[] { GL2ES1, GL2, GL3bc, GL4bc, GLES1 };
/** Returns a default GLProfile object, reflecting the best for the running platform.
* It selects the first of the set {@link GLProfile#GL_PROFILE_LIST_ALL}
+ * @see #GL_PROFILE_LIST_ALL
*/
public static final GLProfile getDefault() {
if(null==defaultGLProfile) {
@@ -119,22 +229,30 @@ public class GLProfile implements Cloneable {
return defaultGLProfile;
}
- /** Returns a GLProfile object.
- * Verfifies the given profile and chooses an apropriate implementation.
- * A generic value of null
or GL
will result in
- * the default profile.
+ /**
+ * Returns the highest profile, implementing the fixed function pipeline
+ * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MAX_FIXEDFUNC}
*
* @throws GLException if no implementation for the given profile is found.
+ * @see #GL_PROFILE_LIST_MAX_FIXEDFUNC
*/
- public static final GLProfile get(String profile)
+ public static final GLProfile getMaxFixedFunc()
throws GLException
{
- if(null==profile || profile.equals("GL")) return getDefault();
- GLProfile glProfile = (GLProfile) mappedProfiles.get(profile);
- if(null==glProfile) {
- throw new GLException("No implementation for profile "+profile+" available");
- }
- return glProfile;
+ return get(GL_PROFILE_LIST_MAX_FIXEDFUNC);
+ }
+
+ /**
+ * Returns the highest profile, implementing the programmable shader pipeline.
+ * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MAX_PROGSHADER}
+ *
+ * @throws GLException if no implementation for the given profile is found.
+ * @see #GL_PROFILE_LIST_MAX_PROGSHADER
+ */
+ public static final GLProfile getMaxProgrammable()
+ throws GLException
+ {
+ return get(GL_PROFILE_LIST_MAX_PROGSHADER);
}
/**
@@ -142,6 +260,7 @@ public class GLProfile implements Cloneable {
* It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES1}
*
* @throws GLException if no implementation for the given profile is found.
+ * @see #GL_PROFILE_LIST_GL2ES1
*/
public static final GLProfile getGL2ES1()
throws GLException
@@ -154,6 +273,7 @@ public class GLProfile implements Cloneable {
* It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES2}
*
* @throws GLException if no implementation for the given profile is found.
+ * @see #GL_PROFILE_LIST_GL2ES2
*/
public static final GLProfile getGL2ES2()
throws GLException
@@ -161,6 +281,24 @@ public class GLProfile implements Cloneable {
return get(GL_PROFILE_LIST_GL2ES2);
}
+ /** Returns a GLProfile object.
+ * Verfifies the given profile and chooses an apropriate implementation.
+ * A generic value of null
or GL
will result in
+ * the default profile.
+ *
+ * @throws GLException if no implementation for the given profile is found.
+ */
+ public static final GLProfile get(String profile)
+ throws GLException
+ {
+ if(null==profile || profile.equals("GL")) return getDefault();
+ GLProfile glProfile = (GLProfile) mappedProfiles.get(profile);
+ if(null==glProfile) {
+ throw new GLException("No implementation for profile "+profile+" available");
+ }
+ return glProfile;
+ }
+
/**
* Returns the first profile from the given list,
* where an implementation is available.
@@ -200,18 +338,12 @@ public class GLProfile implements Cloneable {
}
private static final String getGLImplBaseClassName(String profileImpl) {
- if(GL4bc.equals(profileImpl)) {
+ if ( GL4bc.equals(profileImpl) ||
+ GL4.equals(profileImpl) ||
+ GL3bc.equals(profileImpl) ||
+ GL3.equals(profileImpl) ||
+ GL2.equals(profileImpl) ) {
return "com.jogamp.opengl.impl.gl4.GL4bc";
- } else if(GL4.equals(profileImpl)) {
- return "com.jogamp.opengl.impl.gl4.GL4";
- } else if(GL3bc.equals(profileImpl)) {
- return "com.jogamp.opengl.impl.gl3.GL3bc";
- } else if(GL3.equals(profileImpl)) {
- return "com.jogamp.opengl.impl.gl3.GL3";
- } else if(GL2.equals(profileImpl)) {
- return "com.jogamp.opengl.impl.gl2.GL2";
- } else if(GL2ES12.equals(profileImpl)) {
- return "com.jogamp.opengl.impl.gl2es12.GL2ES12";
} else if(GLES1.equals(profileImpl) || GL2ES1.equals(profileImpl)) {
return "com.jogamp.opengl.impl.es1.GLES1";
} else if(GLES2.equals(profileImpl) || GL2ES2.equals(profileImpl)) {
@@ -285,7 +417,7 @@ public class GLProfile implements Cloneable {
return isGL4() || isGL3bc() || GL3.equals(profile);
}
- /** Indicates whether this profile is capable of GL2. */
+ /** Indicates whether this context is a GL2 context */
public final boolean isGL2() {
return isGL3bc() || GL2.equals(profile);
}
@@ -315,34 +447,9 @@ public class GLProfile implements Cloneable {
return GL2GL3.equals(profile) || isGL2() || isGL3() ;
}
- /** Indicates whether this profile uses the native desktop OpenGL GL4bc implementations. */
- public final boolean usesNativeGL4bc() {
- return GL4bc.equals(profileImpl);
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL4 implementations. */
- public final boolean usesNativeGL4() {
- return usesNativeGL4bc() || GL4.equals(profileImpl);
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL3bc implementations. */
- public final boolean usesNativeGL3bc() {
- return GL3bc.equals(profileImpl);
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL3 implementations. */
- public final boolean usesNativeGL3() {
- return usesNativeGL3bc() || GL3.equals(profileImpl);
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL2 implementations. */
- public final boolean usesNativeGL2() {
- return GL2.equals(profileImpl) || GL2ES12.equals(profileImpl) ;
- }
-
- /** Indicates whether this profile uses the native desktop OpenGL GL2 or GL3 implementations. */
- public final boolean usesNativeGL2GL3() {
- return usesNativeGL2() || usesNativeGL3() || usesNativeGL4();
+ /** Indicates whether this profile supports GLSL. */
+ public final boolean hasGLSL() {
+ return isGL2ES2() ;
}
/** Indicates whether this profile uses the native OpenGL ES1 implementations. */
@@ -360,11 +467,6 @@ public class GLProfile implements Cloneable {
return usesNativeGLES2() || usesNativeGLES1();
}
- /** Indicates whether this profile supports GLSL. */
- public final boolean hasGLSL() {
- return isGL2ES2() ;
- }
-
/**
* General validation if type is a valid GL data type
* for the current profile
@@ -665,70 +767,23 @@ public class GLProfile implements Cloneable {
return "GLProfile[" + profile + "/" + profileImpl + "]";
}
- public static final int GL_VERSIONS[][] = {
- /* 0.*/ { -1 },
- /* 1.*/ { 0, 1, 2, 3, 4, 5 },
- /* 2.*/ { 0, 1 },
- /* 3.*/ { 0, 1, 2, 3 },
- /* 4.*/ { 0 } };
-
- public static final int getMaxMajor() {
- return GL_VERSIONS.length-1;
- }
-
- public static final int getMaxMinor(int major) {
- if(1>major || major>=GL_VERSIONS.length) return -1;
- return GL_VERSIONS[major].length-1;
- }
-
- public static final boolean isValidGLVersion(int major, int minor) {
- if(1>major || major>=GL_VERSIONS.length) return false;
- if(0>minor || minor>=GL_VERSIONS[major].length) return false;
- return true;
- }
-
- public static final boolean decrementGLVersion(int major[], int minor[]) {
- if(null==major || major.length<1 ||null==minor || minor.length<1) {
- throw new GLException("invalid array arguments");
- }
- int m = major[0];
- int n = minor[0];
- if(!isValidGLVersion(m, n)) return false;
-
- // decrement ..
- n -= 1;
- if(n < 0) {
- m -= 1;
- n = GL_VERSIONS[m].length-1;
- }
- if(!isValidGLVersion(m, n)) return false;
- major[0]=m;
- minor[0]=n;
-
- return true;
- }
-
- // The intersection between desktop OpenGL and the union of the OpenGL ES profiles
- // This is here only to avoid having separate GL2ES1Impl and GL2ES2Impl classes
- private static final String GL2ES12 = "GL2ES12";
-
private static final boolean isAWTAvailable;
private static final boolean isAWTJOGLAvailable;
- private static final boolean hasGL4bcImpl;
- private static final boolean hasGL4Impl;
- private static final boolean hasGL3bcImpl;
- private static final boolean hasGL3Impl;
- private static final boolean hasGL2Impl;
- private static final boolean hasGL2ES12Impl;
- private static final boolean hasGLES2Impl;
- private static final boolean hasGLES1Impl;
+ private static /*final*/ boolean hasGL234Impl;
+ private static /*final*/ boolean hasGL4bcImpl;
+ private static /*final*/ boolean hasGL4Impl;
+ private static /*final*/ boolean hasGL3bcImpl;
+ private static /*final*/ boolean hasGL3Impl;
+ private static /*final*/ boolean hasGL2Impl;
+ private static /*final*/ boolean hasGLES2Impl;
+ private static /*final*/ boolean hasGLES1Impl;
/** The JVM/process wide default GL profile **/
- private static GLProfile defaultGLProfile;
+ private static /*final*/ GLProfile defaultGLProfile;
/** All GLProfiles */
- private static final HashMap/*